sync
[gitlive] / GitRepo.vala
index 8659ac6..ab17558 100644 (file)
@@ -16,6 +16,8 @@ public class GitRepo : Object
     public string gitdir;
     public string git_working_dir;
     public bool debug = false;
+    
+    public Gee.HashMap<string,bool> ignore_files;
 
     /**
     * index of.. matching gitpath..
@@ -72,7 +74,7 @@ public class GitRepo : Object
                 }
                 
             } catch (Error e) {
-                print(e.message);
+                print("Error: %s\n",e.message);
                 break;
             }
          
@@ -124,7 +126,7 @@ public class GitRepo : Object
     public GitRepo(string path) {
         // cal parent?
         this.name =   File.new_for_path(path).get_basename();
-        
+        this.ignore_files = new Gee.HashMap<string,bool>();
         
         this.git_working_dir = path;
         this.gitdir = path + "/.git";
@@ -159,6 +161,18 @@ public class GitRepo : Object
         }
         return ret;
     }
+        
+    public bool is_ignore(string fname) throws Error, SpawnError
+    {
+               try {
+                       var ret = this.git( { "check-ignore" , fname } );
+                       return ret == fname;
+               } catch (SpawnError e) {
+                       return false;
+               }
+               
+
+    } 
     
       /**
      * remove:
@@ -244,7 +258,7 @@ public class GitRepo : Object
     public string pull () throws Error, SpawnError
     {
         // should probably hand error conditions better... 
-        string[] cmd = { "pull" };
+        string[] cmd = { "pull" , "--no-edit" };
         return this.git( cmd );
 
         
@@ -261,9 +275,12 @@ public class GitRepo : Object
     public string push () throws Error, SpawnError
     {
         // should 
-        return this.git({ "push" });
+        return this.git({ "push", "origin", "HEAD" });
         
     }
+    
+    
+    
      /**
      * git:
      * The meaty part.. run spawn.. with git..
@@ -275,13 +292,12 @@ public class GitRepo : Object
     {
         // convert arguments.
         
-
         string[]  args = { "git" };
         //args +=  "--git-dir";
         //args +=  this.gitdir;
         args +=  "--no-pager";
  
-
         //if (this.gitdir != this.repopath) {
         //    args +=   "--work-tree";
          //   args += this.repopath; 
@@ -293,7 +309,7 @@ public class GitRepo : Object
         //this.lastCmd = args.join(" ");
         //if(this.debug) {
             stdout.printf( "CWD=%s\n",  this.git_working_dir ); 
-            print(  string.joinv (" ", args)); 
+            print( "cmd: %s\n", string.joinv (" ", args)); 
         //}
 
         string[]   env = {};
@@ -305,12 +321,12 @@ public class GitRepo : Object
         //}
         
 
-
         var cfg = new SpawnConfig(this.git_working_dir , args , env);
         
 
        // may throw error...
         var sp = new Spawn(cfg);
+      
 
         stdout.printf( "GOT: %s\n" , sp.output);
         // parse output for some commands ?