GitRepo.vala
[gitlive] / GitRepo.vala
index 7507d59..c8ddda2 100644 (file)
@@ -57,11 +57,12 @@ public class GitRepo : Object
      *
      * @argument {Array} files the files to add.
      */
-    public string add ( Array<GitMonitorQueue> files )
+    public string add ( Array<GitMonitorQueue> files ) throws Error, SpawnError
     {
         // should really find out if these are untracked files each..
         // we run multiple versions to make sure that if one failes, it does not ignore the whole lot..
         // not sure if that is how git works.. but just be certian.
+        var ret = "";
         for (var i = 0; i < files.length;i++) {
             var f = files.index(i).vname;
             try {
@@ -72,6 +73,7 @@ public class GitRepo : Object
             }        
 
         }
+        return ret;
     }
     
       /**
@@ -80,7 +82,7 @@ public class GitRepo : Object
      *
      * @argument {Array} files the files to add.
      */
-    public string remove  ( Array<GitMonitorQueue> files )
+    public string remove  ( Array<GitMonitorQueue> files ) throws Error, SpawnError
     {
         // this may fail if files do not exist..
         // should really find out if these are untracked files each..
@@ -116,7 +118,7 @@ public class GitRepo : Object
      * 
      */
      
-    public string commit ( string message, Array<GitMonitorQueue> files  )
+    public string commit ( string message, Array<GitMonitorQueue> files  ) throws Error, SpawnError
     {
         
 
@@ -138,13 +140,13 @@ public class GitRepo : Object
             
         }
         */
-        var args = { "commit", "-m", };
-        arg +=  (message.length > 0  ? message : "Changed" );
+        string[] args = { "commit", "-m", };
+        args +=  (message.length > 0  ? message : "Changed" );
         for (var i = 0; i< files.length ; i++ ) {
             args += files.index(i).vname; // full path?
         }
          
-        return this.git(args, env);
+        return this.git(args);
     }
     
     /**
@@ -155,10 +157,12 @@ public class GitRepo : Object
      * -- maybe later it will have a few options and do more stuff..
      *
      */
-    public string pull ()
+    public string pull () throws Error, SpawnError
     {
         // should probably hand error conditions better... 
-        return this.git({ "pull" });
+        string[] cmd = { "pull" };
+        return this.git( cmd );
+
         
         
     }
@@ -170,7 +174,7 @@ public class GitRepo : Object
      * -- maybe later it will have a few options and do more stuff..
      *
      */
-    public string push ()
+    public string push () throws Error, SpawnError
     {
         // should 
         return this.git({ "push" });
@@ -183,7 +187,7 @@ public class GitRepo : Object
      *
      */
     
-    public string git(string[] args_in, string[] env = {}) throws Error, SpawnError
+    public string git(string[] args_in, ?string[] env) throws Error, SpawnError
     {
         // convert arguments.
         
@@ -193,6 +197,9 @@ public class GitRepo : Object
         args +=  this.gitdir;
         args +=  "--no-pager";
 
+        if (env == null) {
+            env = {};
+        }
 
         //if (this.gitdir != this.repopath) {
         //    args +=   "--work-tree";
@@ -207,8 +214,8 @@ public class GitRepo : Object
          
             print(  string.joinv (", ", args)); 
         }
-        
-        env +=  ("HOME=" + Environment.get_home_dir() );
+        string  home = "HOME=" + Environment.get_home_dir() ;
+        env +=  home ;
         // do not need to set gitpath..
         //if (File.exists(this.repo + '/.git/config')) {
             //env.push("GITPATH=" + this.repo );