GitRepo.vala
[gitlive] / GitRepo.vala
index 93a94e2..13d97b7 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..
@@ -33,7 +35,6 @@ public class GitRepo : Object
     
     }
     
-     
     
     public static   Array<GitRepo> list()
     {
@@ -60,7 +61,7 @@ public class GitRepo : Object
             return list_cache;
             
         }
-         
+        
         FileInfo next_file; 
         
         while (true) {
@@ -124,7 +125,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 +160,28 @@ public class GitRepo : Object
         }
         return ret;
     }
+        
+    public bool is_ignore(string fname) throws Error, SpawnError
+    {
+               if (fname == ".gitignore") {
+                       this.ignore_files.clear();
+               }
+               
+               if (this.ignore_files.has_key(fname)) {
+                       return this.ignore_files.get(fname);
+               }
+               
+               try {
+                       var ret = this.git( { "check-ignore" , fname } );
+                       this.ignore_files.set(fname, ret.length >  0);
+                       return ret.length > 0;
+               } catch (SpawnError e) {
+                       this.ignore_files.set(fname, false);
+                       return false;
+               }
+                
+    } 
+    
     
       /**
      * remove:
@@ -188,6 +211,7 @@ public class GitRepo : Object
 
     }
     
+    
     /**
      * commit:
      * perform a commit.
@@ -244,12 +268,18 @@ public class GitRepo : Object
     public string pull () throws Error, SpawnError
     {
         // should probably hand error conditions better... 
-        string[] cmd = { "pull" , "--no-edit", "origin", "HEAD" };
+        string[] cmd = { "pull" , "--no-edit" };
         return this.git( cmd );
 
         
         
     }
+    
+    public void pull_async(Callback_pull cb) {
+    
+    
+    }
+    
     /**
      * push:
      * Send local changes to remote repo(s)
@@ -264,6 +294,9 @@ public class GitRepo : Object
         return this.git({ "push", "origin", "HEAD" });
         
     }
+    
+    
+    
      /**
      * git:
      * The meaty part.. run spawn.. with git..