GitMonitor.vala
[gitlive] / GitMonitor.vala
index 3756781..130fb48 100644 (file)
@@ -42,7 +42,7 @@ public class GitMonitorQueue : MonitorNamePathDir {
         
         }
 
-        public bool shouldIgnore(GitMonitor gm)
+        public bool shouldIgnore()
         {
             
             
@@ -163,7 +163,7 @@ public class GitMonitor : Monitor
               
                 var notification = new Notify.Notification(
                     "Git Live",
-                    "%s\nMonitoring %d Directories".printf(GitMonitor.gitlive, this.monitors.length), 
+                    "%s\nMonitoring %u Directories".printf(GitMonitor.gitlive, this.monitors.length), 
                      "dialog-information"
                 );
         
@@ -194,7 +194,7 @@ public class GitMonitor : Monitor
         
             this.runQueue();
             return true;
-        },null,null);
+        });
         
       
     }
@@ -261,7 +261,7 @@ public class GitMonitor : Monitor
         
         string[] success = {};
         string[] failure = {};
-        var repos = new Array<GitRepo>(); //??
+       //var repos = new Array<GitRepo>(); //??
         var done = new Array<GitMonitorQueue>();
         
         // first build a array of repo's to work with
@@ -274,12 +274,13 @@ public class GitMonitor : Monitor
         
         for(var i = 0; i < cmds.length; i++) {
            
+            var cmd = cmds.index(i);
         
             var gitpath = cmd.gitpath; 
-            var ix  = GitRepo.indexOf(this.repos,  cmd.gitpath);
+            var ix  = GitRepo.indexOf(repo_list,  cmd.gitpath);
             if (ix < 0) {
                 repo_list.append_val(new GitRepo( gitpath ));
-                ix = GitRepo.indexOf(this.repos,  cmd.gitpath);
+                ix = GitRepo.indexOf(repo_list,  cmd.gitpath);
             }
             
 
@@ -320,12 +321,12 @@ public class GitMonitor : Monitor
                         break;
                     
                     case "rm":
-                        if (GitMonitorQueue.indexOfAdd(add_files, cmd.rm) > -1 ) {
+                        if (GitMonitorQueue.indexOfAdd(add_files, cmd.vname) > -1 ) {
                            break;
                         }
                         
                         // if file exists, do not try and delete it.
-                        if (FileUtils.test(cmd.rm, FileTest.EXISTS)) {
+                        if (FileUtils.test(cmd.vname, FileTest.EXISTS)) {
                             break;
                         }
                         
@@ -348,18 +349,18 @@ public class GitMonitor : Monitor
             
             //repo.debug = 1;
             // these can fail... at present... as we wildcard stuff.
-            stdout.printf("ADD : %d files"  , add_files.length);
+            stdout.printf("ADD : %u files"  , add_files.length);
             
             // make sure added files do not get removed..
 
             var remove_files_f = new Array<GitMonitorQueue>();
             for(var ii = 0;ii < remove_files.length;ii++) {
-                if (GitMonitorQueue.indexOfAdd(add_files,  remove_files.index(ii).rm) > -1 ) {
+                if (GitMonitorQueue.indexOfAdd(add_files,  remove_files.index(ii).vname) > -1 ) {
                      continue;
                 }
                 remove_files_f.append_val(remove_files.index(ii));
             };
-            stdout.printf("REMOVE : %d files"  , remove_files.length);
+            stdout.printf("REMOVE : %u files"  , remove_files.length);
              
             // make sure monitoring is paused so it does not recursively pick up
             // deletions
@@ -369,10 +370,13 @@ public class GitMonitor : Monitor
                 repo.add(add_files);
             } catch(Error e) {
                 failure +=  e.message;
-                
             }  
             try {
-            repo.remove(remove_files_f);
+                 repo.remove(remove_files_f);
+            } catch(Error e) {
+                failure +=  e.message;
+            }  
+
             this.paused = false;
             
             
@@ -393,7 +397,7 @@ public class GitMonitor : Monitor
          
         try {
             // catch notification failures.. so we can carry on..
-            if (success.length) {
+            if (success.length > 0) {
 
                 
                 var notification = new Notify.Notification(
@@ -407,14 +411,14 @@ public class GitMonitor : Monitor
                 notification.show();   
             }
             
-            if (failure.length) {
+            if (failure.length > 0) {
 
-                var notification = new Notify.Notification({
-                    summary: "Git Live ERROR!!",
+                var notification = new Notify.Notification(
+                      "Git Live ERROR!!",
                     string.joinv("\n",failure),
                     "dialog-information"
                     
-                });
+                );
     
                 notification.set_timeout(5); // show errros for longer
                 notification.show();   
@@ -439,7 +443,7 @@ public class GitMonitor : Monitor
    
 
 
-    public void onChanged(MonitorNamePathDir src) 
+    public new void onChanged(MonitorNamePathDir src) 
     { 
         return; // always ignore this..?
         //this.parsePath(src);
@@ -451,11 +455,11 @@ public class GitMonitor : Monitor
      *  results in  git add  + git commit..
      *
      */
-    public void onChangesDoneHint(MonitorNamePathDir src)  
+    public new void onChangesDoneHint(MonitorNamePathDir src)  
     { 
         
         if (this.paused) {
-            return true;
+            return;
         }
             
 
@@ -485,17 +489,17 @@ public class GitMonitor : Monitor
 
         this.queue.append_val(cmd);
 
-        var cmd = new GitMonitorQueue(src);
+        cmd = new GitMonitorQueue(src);
         cmd.action = "commit";
-        cmd.message = src.vpath;
+        cmd.message = cmd.vname;
         this.queue.append_val(cmd);
  
          
     }
-    public void onDeleted(MonitorNamePathDir src) 
+    public new void onDeleted(MonitorNamePathDir src) 
    { 
         if (this.paused) {
-            return true;
+            return;
         }
         this.lastAdd = new DateTime.now(new TimeZone.local()); 
         var cmd = new GitMonitorQueue(src);
@@ -505,21 +509,20 @@ public class GitMonitor : Monitor
         // should check if monitor needs removing..
         // it should also check if it was a directory.. - so we dont have to commit all..
         cmd.action = "rm";
-        cmd.rm = src.vpath;
         this.queue.append_val(cmd);
 
-        var cmd = new GitMonitorQueue(src);
+        cmd = new GitMonitorQueue(src);
         cmd.action = "commit";
-        cmd.message = src.vpath;
+        cmd.message = cmd.vname;
         cmd.commit_all = true;
 
         this.queue.append_val(cmd);
  
     }
-    public void onCreated(MonitorNamePathDir src) {
+    public new void onCreated(MonitorNamePathDir src) {
 
         if (this.paused) {
-            return true;
+            return;
         }
         this.lastAdd = new DateTime.now(new TimeZone.local()); 
         var cmd = new GitMonitorQueue(src);
@@ -546,10 +549,10 @@ public class GitMonitor : Monitor
 
     }
 
-    public void onAttributeChanged(MonitorNamePathDir src) { 
+    public new void onAttributeChanged(MonitorNamePathDir src) { 
 
         if (this.paused) {
-            return true;
+            return;
         }
         this.lastAdd = new DateTime.now(new TimeZone.local()); 
         var cmd = new GitMonitorQueue(src);
@@ -559,15 +562,18 @@ public class GitMonitor : Monitor
         cmd.action = "add";
         this.queue.append_val(cmd);
 
-        var cmd = new GitMonitorQueue(src);
+        cmd = new GitMonitorQueue(src);
         cmd.action = "commit";
         cmd.message = "Attribute changed " + cmd.vpath;
         this.queue.append_val(cmd);
     }
 
 
-   public void onMoved(MonitorNamePathDir src,MonitorNamePathDir dest)  
+   public new void onMoved(MonitorNamePathDir src,MonitorNamePathDir dest)  
     { 
+        if (this.paused) {
+            return;
+        }
         this.lastAdd = new DateTime.now(new TimeZone.local()); 
         var cmd_s = new GitMonitorQueue(src);