Attribute changed Makefile
[gitlive] / GitMonitor.vala
index f6a6446..d8ca8eb 100644 (file)
@@ -114,7 +114,33 @@ public class GitMonitorQueue : MonitorNamePathDir {
             }
             return string.joinv("\n",ret);
         }
-
+        public static string queueArrayToString(Array<GitMonitorQueue> list) {
+            var ret = "";
+            for(var i =0; i < list.length; i++) {
+                
+                ret += (ret.length > 0 ? ", " : "") + list.index(i).vname;
+            }
+            return ret;
+            
+        }
+        
+        public static bool  queueHas(Array<GitMonitorQueue> list , GitMonitorQueue cmd_s, string action) {
+            for(var i =0; i < list.length; i++) {
+                var test = list.index(i);
+                if (list.index(i).gitpath != cmd_s.gitpath) {
+                    continue;
+                }
+                if (list.index(i).vname != cmd_s.vname) {
+                    continue;
+                }
+                if (list.index(i).action != action) {
+                    continue;
+                }
+                return true;
+            }
+            return false;
+        }
+        
 }
 
 
@@ -358,7 +384,7 @@ public class GitMonitor : Monitor
                         break;
                     
                     case "rm":
-                        if (GitMonitorQueue.indexOfAdd(add_files, cmd.vname) > -1 ) {
+                        if (GitMonitorQueue.indexOfAdd(remove_files, cmd.vname) > -1 ) {
                            break;
                         }
                         
@@ -382,7 +408,8 @@ public class GitMonitor : Monitor
                         break;
                 } 
             }
-            
+            print( "ADD : %s\n", GitMonitorQueue.queueArrayToString(add_files));
+            print( "REMOVE FILES: %s\n", GitMonitorQueue.queueArrayToString(remove_files));
             //repo.debug = 1;
             // these can fail... at present... as we wildcard stuff.
            
@@ -415,8 +442,8 @@ public class GitMonitor : Monitor
                 add_files_f.append_val(add_files.index(ii));
             };
             
-            print("ADD : %u files\n"  , add_files_f.length);
-            print("REMOVE: %u files\n"  , remove_files_f.length);
+            print( "ADD : %s\n", GitMonitorQueue.queueArrayToString(add_files_f));
+            print( "REMOVE FILES: %s\n", GitMonitorQueue.queueArrayToString(remove_files_f));
            
             
             // make sure monitoring is paused so it does not recursively pick up
@@ -430,7 +457,7 @@ public class GitMonitor : Monitor
             
             // -- DO STUFF..            
             try {
-                repo.add(add_files);
+                repo.add(add_files_f);
             } catch(Error e) {
                 failure +=  e.message;
             }  
@@ -670,12 +697,15 @@ public class GitMonitor : Monitor
 
             return;
         }
-         
+        
+        
+        print("RM: %s\n", cmd_s.vname);
         cmd_s.action = "rm";
         this.queue.append_val(cmd_s);
 
-
+        
+        
+        print("ADD: %s\n", cmd_d.vname);
         cmd_d.action = "add";
         this.queue.append_val(cmd_d);
 
@@ -683,6 +713,10 @@ public class GitMonitor : Monitor
         var cmd = new GitMonitorQueue(dest);
         cmd.action = "commit";
         cmd.message = "MOVED " + cmd_s.vname + " to " + cmd_d.vname;
+        if (GitMonitorQueue.queueHas(this.queue, cmd_s, "add")) {
+            cmd.message = cmd_d.vname;
+        }
+        
         this.queue.append_val(cmd);