GitMonitor.vala
[gitlive] / GitMonitor.vala
1
2  
3
4 public class GitMonitorQueue : MonitorNamePathDir {
5                 // name = basename
6                 // path = full path..
7                 // dir = dir path
8         
9                 public string gitpath;
10                 public string vdir;  // relative path (within git)
11                 public string vname;  // relative filename (within git)
12                 public string message ; // for commit
13                 public bool commit_all;
14                  
15                 public GitMonitorQueue(MonitorNamePathDir f) {
16
17                         base(f.name, f.path, f.dir);
18  
19                         this.message = "";
20                         this.commit_all = false;
21                         
22                         var vpath_ar = this.dir.substring(GitMonitor.gitlive.length +1).split("/", 0);
23                         
24                         if (vpath_ar[0].length < 1) {
25
26                                 this.gitpath = "";
27                                 this.vdir = "";
28                                 this.vname = "";
29                         }        
30
31
32                         this.gitpath = GitMonitor.gitlive + "/" + vpath_ar[0];
33                         
34                         string[]  vpath = {};
35                         for (var i = 1; i< vpath_ar.length; i++) {
36                                 vpath += vpath_ar[i];
37                         }
38
39                         this.vdir =  string.joinv("/", vpath);
40
41                         this.vname =  this.vdir + (this.vdir.length > 0 ? "/" : "") + this.name;
42                         
43                          
44 /*
45                         stdout.printf(
46                                         "NEW GitMonitorQueue\nname: %s\npath: %s\ndir: %s\n" + 
47                                         "gitpath: %s\nvdir: %s\nvname: %s\n",
48                                         this.name, this.path, this.dir,
49                                         this.gitpath, this.vdir, this.vname
50                         );
51 */
52
53                         //f.repo = new imports.Scm.Git.Repo({ repopath: f.gitpath })
54                 
55                 
56                 }
57
58                 public bool shouldIgnore()
59                 {
60                         
61                  
62                         // vim.. what a seriously brain dead program..
63                         if (this.name == "4913") {
64                                 return true;
65                         }
66                         
67                         if (this.name[0] == '.') {
68                                 // except!
69                                 if (this.name == ".htaccess") {
70                                         return false;
71                                 }
72                                 if (this.name == ".gitignore") {
73                                         return false;
74                                 }
75                                 return true;
76                         }
77                         
78                         
79                         if (this.name[this.name.length -1] == '~') {
80                                 return true;
81                         }
82                         // netbeans / android studio.. silly temp files..
83                         
84                         if (Regex.match_simple("___jb_old___$", this.name)) {
85                             return true;
86                         }
87                         if (Regex.match_simple("___jb_bak___$", this.name)) {
88                             return true;
89                         }
90                         //if (f.name.match(/^nbproject/)) {
91                         //    return true;
92                         //}
93                         // ignore anything in top level!!!!
94                         if (this.gitpath.length < 1) {
95                                 return true;
96                         }
97                         
98                         return false;
99                 }
100                 
101                 /** -- statics --*/
102                 
103                 public static int indexOfAdd( Array<GitMonitorQueue> add_files, string add)
104                 {
105                         for(var i =0; i < add_files.length; i++) {
106                                 if (add_files.index(i).vname == add) {
107                                         return i;
108                                 }
109                         }
110                         return -1;
111                 }
112                 public static  int indexOfMessage(Array<GitMonitorQueue> messages, string message)  {
113                         for(var i =0; i < messages.length; i++) {
114                                 if (messages.index(i).message == message) {
115                                         return i;
116                                 }
117                         }
118                         return -1;
119                 }
120                 public static string messageToString(Array<GitMonitorQueue> messages ) {
121                         string[] ret = {};
122                         for(var i =0; i < messages.length; i++) {
123                                 ret+= messages.index(i).message;
124                         }
125                         return string.joinv("\n",ret);
126                 }
127                 public static string queueArrayToString(Array<GitMonitorQueue> list) {
128                         var ret = "";
129                         for(var i =0; i < list.length; i++) {
130                                 
131                                 ret += (ret.length > 0 ? ", " : "") + list.index(i).vname;
132                         }
133                         return ret;
134                         
135                 }
136                 
137                 public static bool  queueHas(Array<GitMonitorQueue> list , GitMonitorQueue cmd_s, string action) {
138                         for(var i =0; i < list.length; i++) {
139                                 var test = list.index(i);
140                                 if (list.index(i).gitpath != cmd_s.gitpath) {
141                                         continue;
142                                 }
143                                 if (list.index(i).vname != cmd_s.vname) {
144                                         continue;
145                                 }
146                                 if (list.index(i).action != action) {
147                                         continue;
148                                 }
149                                 return true;
150                         }
151                         return false;
152                 }
153                 public string fullpath()
154                 {
155                         return this.gitpath + "/" + this.vname;
156                 }
157                 
158                         
159                         
160 }
161
162
163
164 public class GitMonitor : Monitor
165 {
166
167         public static GitMonitor gitmonitor;
168         /**
169          * @property {String} the "gitlive" directory, normally ~/gitlive
170          *  dset by OWNER... - we should do this as a CTOR.
171          *  
172          */
173         public static string gitlive;
174         
175         
176         public Array<GitMonitorQueue> queue ;
177         public bool queueRunning = false;
178         
179         public DateTime lastAdd;
180
181  
182
183         public GitMonitor () {
184         
185         
186         
187                 this.queue = new Array<GitMonitorQueue>();
188                 GitMonitor.gitmonitor = this;
189                 
190  
191
192                 
193                 Timeout.add_full(Priority.LOW, 1000, () => {
194                         
195                         //print("TIMEOUT queue length = %d, is_runing = %s\n", (int)this.queue.length , this.queueRunning ? "Y" : "N");
196
197                         //stdout.printf("QL %u: QR: %d\n", this.queue.length, this.queueRunning ? 1 : 0);
198                         if (this.queue.length < 1  || this.queueRunning) {
199                                 return true;
200                         }
201                         
202                         var last = -1 * this.lastAdd.difference(new DateTime.now(new TimeZone.local()));
203  
204                         // stdout.printf("LAST RUN: %s (expect %s) \n" ,
205                         //         last.to_string(),   (5 * TimeSpan.SECOND).to_string() );
206  
207                         if (last < 5 * TimeSpan.SECOND) { // wait 5 seconds before running. ????
208                                 return true;
209                         }
210                         //_this.lastAdd = new Date();
211                         //return 1;
212                 
213                         this.runQueue();
214                         return true; //
215                 });
216                 
217                 
218         }
219
220         public new void pauseError(string failure) 
221         {
222         
223                 var notification = new Notify.Notification(
224                           "Git Live ERROR!!",
225                         failure,
226                         "dialog-information"
227                         
228                 );
229                         
230                 notification.set_timeout(60); // show errros for longer
231                 notification.show();
232                 
233         Canberra.Context context;
234         Canberra.Proplist props;
235
236         Canberra.Context.create (out context);
237         Canberra.Proplist.create (out props);
238
239         props.sets (Canberra.PROP_EVENT_ID, "phone-outgoing-busy");
240         props.sets (Canberra.PROP_EVENT_DESCRIPTION, "Gitlive stopped on error");
241  
242
243         context.play_full (0, props, null);
244
245
246                         
247         
248                 this.paused = true;
249                 this.queueRunning = false;
250                 // what does this do to the old one...
251                 this.queue = new Array<GitMonitorQueue> ();
252                 this.stop();
253                 StatusIconA.statusicon.pauseError();
254                 
255                 var m = new Gtk.MessageDialog(null, Gtk.DialogFlags.MODAL,Gtk.MessageType.ERROR,Gtk.ButtonsType.CLOSE,
256                         "A Serious problem occured running git, you will probably have to resolve this manually\n" + 
257                         "Committing is paused now, so fix the problem, close this window, then press start again\n\n\n" + 
258                         failure
259                 );
260                 m.set_keep_above(true);
261                 m.show();
262                 m.set_position(Gtk.WindowPosition.CENTER);
263                 m.response.connect( (id_pressed) => {
264                         m.hide();
265                 });
266                 
267         }
268  
269         public new void pause() {
270                 this.paused = true;
271                 // what does this do to the old one...
272                 this.queue = new Array<GitMonitorQueue> ();
273                 StatusIconA.statusicon.pause();
274
275         }
276         
277         /*
278         public new void resume () {
279                 this.paused = false;
280                 this.queue = new Array<GitMonitorQueue> ();
281                 StatusIconA.statusicon.resume();
282                 
283                 
284         }
285         */
286         /**
287          * Start the monitoring
288          * and run the queue every 500 milliseconds..
289          *
290          */
291         public new void start() 
292         {
293                 StatusIconA.statusicon.refreshing();
294                 
295                  
296                 this.lastAdd = new DateTime.now(new TimeZone.local()); 
297                 
298                 Timeout.add_full(Priority.LOW, 500, () => {
299                         //stdout.printf("GitMonitor.start :: top.length = %u\n", this.top.length);
300                         // call this.monitor on each of 'top'
301                         for(int i = 0; i < this.top.length ; i++) {
302
303                                 this.monitor(this.top.index(i) );
304                         }
305                         StatusIconA.statusicon.resume();
306                     this.paused = false;
307                    
308                         
309                         try {
310
311                           
312                                 var notification = new Notify.Notification(
313                                         "Git Live",
314                                         "%s\nMonitoring %u Directories".printf(GitMonitor.gitlive, this.monitors.length), 
315                                          "dialog-information"
316                                 );
317                 
318                                 notification.set_timeout(5);
319                                 notification.show();
320                         } catch(Error e) {
321                                 GLib.debug("Error sending notification to screen: %s\n",e.message);
322                         }
323                         return false; // do not keep doing this..
324
325                 });
326                 
327
328                 
329                  
330         }
331
332
333         public new void stop() {
334                 StatusIconA.statusicon.pause();
335                 base.stop();
336         }
337         
338         
339         public new void monitor (string path,  int depth = 0)
340         {
341                 
342                 //var depth = typeof(depth) == 'number'  ? depth *1 : 0;
343                 
344                  
345                 // if we are not at top level.. and there is a .git directory  (it's a submodule .. ignore) 
346                 if (depth > 1 && FileUtils.test(path + "/.git" , FileTest.IS_DIR)) {
347                         return;
348                 }
349                 
350                 if (depth == 1) {
351                         // FIXME - check if repo is flagged as not autocommit..
352                         //var repo = imports.Scm.Repo.Repo.get(path);
353                         //if (!repo || !repo.autocommit()) {
354                         //    return;
355                         //} 
356                 }
357                 
358                 
359                 // check if the repo is to be monitored.
360                 //print("PATH : " + path);
361                 
362                 
363                 base.monitor(path, depth);
364         }
365
366         
367
368         /**
369          * run the queue.
370          * - pulls the items off the queue 
371          *    (as commands run concurrently and new items may get added while it's running)
372          * - runs the queue items
373          * - pushes upstream.
374          * 
375          */
376         public void runQueue()
377         {
378                 
379                 if (this.paused) {
380                         return;
381                 }
382                 GLib.debug("GitMonitor.runQueue\n");
383
384                 this.queueRunning = true;
385
386                 var cmds = new Array<GitMonitorQueue>();
387
388                 for(var i = 0; i < this.queue.length; i++) {
389                         cmds.append_val(this.queue.index(i));
390                 }
391
392                 this.queue = new Array<GitMonitorQueue>();// empty queue!
393
394                 
395                 string[] success = {};
396                 string[] failure = {};
397            //var repos = new Array<GitRepo>(); //??
398                 //var done = new Array<GitMonitorQueue>();
399                 
400                 // first build a array of repo's to work with
401                 var repo_list = new Array<GitRepo>();
402                 
403                 // pull and group.
404                 
405                 //print(JSON.stringify(cmds));
406                 // make sure nothing get's added to the queue where we are doing this..
407
408                 this.paused = true;
409
410                 GLib.debug("GitMonitor.runQueue - creating repos\n");
411                 
412                 for(var i = 0; i < cmds.length; i++) {
413                    
414                         var cmd = cmds.index(i);
415                 
416                         var gitpath = cmd.gitpath; 
417                         GLib.debug("GitMonitor.runQueue - finding %s\n", cmd.gitpath);
418                 
419                         var ix  = GitRepo.indexOf(repo_list,  cmd.gitpath);
420                         if (ix < 0) {
421                                 repo_list.append_val(new GitRepo( gitpath ));
422                                 ix = GitRepo.indexOf(repo_list,  cmd.gitpath);
423                         }
424                         GLib.debug("GitMonitor.runQueue - adding to repolist %d\n", ix);
425
426                         //if (typeof(repo_list[gitpath]) == 'undefined') {
427                         //    repo_list[gitpath] = new imports.Scm.Git.Repo.Repo( { repopath : gitpath });
428                         //    repo_list[gitpath].cmds = [];
429                          //   repo_list[gitpath].pull();
430                         //}
431                         repo_list.index(ix).cmds.append_val(cmd);
432
433                 }
434                 this.paused = false;
435                 // build add, remove and commit message list..
436
437                 GLib.debug("GitMonitor.runQueue - creating actions\n");
438                 
439                 for(var i = 0;i < repo_list.length;i++) {
440          
441                         var repo = repo_list.index(i);
442
443                         var add_files = new Array<GitMonitorQueue>();
444                         var add_files_f = new Array<GitMonitorQueue>();
445                         var remove_files = new Array<GitMonitorQueue>();
446                         var messages = new Array<GitMonitorQueue>();
447                         //print(JSON.stringify(repo.cmds,null,4));
448                         
449                         for(var ii = 0;ii < repo.cmds.length;ii++) {
450                                 var cmd = repo.cmds.index(ii);
451         
452                                 if (repo.is_ignore(cmd.vname)) {
453                                         continue;
454                                 }
455         
456                                 
457                                 switch(cmd.action) {
458                                         case "add" :
459                                                 
460                                                 if (GitMonitorQueue.indexOfAdd(add_files, cmd.vname) > -1) {
461                                                    break;
462                                                 }
463                                                 
464                                                 add_files.append_val(cmd);
465                                                 break;
466                                         
467                                         case "rm":
468                                                 if (GitMonitorQueue.indexOfAdd(remove_files, cmd.vname) > -1 ) {
469                                                    break;
470                                                 }
471                                                 
472                                                 // if file exists, do not try and delete it.
473                                                 if (FileUtils.test(cmd.fullpath(), FileTest.EXISTS)) {
474                                                         break;
475                                                 }
476                                                 
477                                                 remove_files.append_val(cmd);
478                                                 break;
479                                         
480                                         case "commit" :
481                                                 if (GitMonitorQueue.indexOfMessage(messages, cmd.message) > -1 ) {
482                                                    break;
483                                                 }
484                                                 messages.append_val(cmd);
485                                                 
486                                                 break;
487                                         default:
488                                                 stdout.printf("Opps unmatched action %s\n", cmd.action);
489                                                 break;
490                                 } 
491                         }
492                         GLib.debug( "ADD : %s\n", GitMonitorQueue.queueArrayToString(add_files));
493                         GLib.debug( "REMOVE FILES: %s\n", GitMonitorQueue.queueArrayToString(remove_files));
494                         
495                         //repo.debug = 1;
496                         // these can fail... at present... as we wildcard stuff.
497                    
498                         // make sure added files do not get removed.. ?? 
499                         /*
500                         var remove_files_f = new Array<GitMonitorQueue>();
501                         for(var ii = 0;ii < remove_files.length;ii++) {
502                                 if (GitMonitorQueue.indexOfAdd(add_files,  remove_files.index(ii).vname) > -1 ) {
503                                          continue;
504                                 }
505                                 remove_files_f.append_val(remove_files.index(ii));
506                         };
507                         stdout.printf("REMOVE : %u files\n"  , remove_files_f.length);
508                         */
509                         
510                         // if file was added, then removed, 
511                         var remove_files_f = new Array<GitMonitorQueue>();
512                         for(var ii = 0;ii < remove_files.length;ii++) {
513                                 
514                                 
515                                 
516                                 if (GitMonitorQueue.indexOfAdd(add_files,  remove_files.index(ii).vname) > -1 ) {
517                                         // in add and remove - do not remvove
518                                         continue;
519                                 }
520                                 remove_files_f.append_val(remove_files.index(ii));
521                         };
522                         for(var ii = 0;ii < add_files.length;ii++) {
523                                 if (GitMonitorQueue.indexOfAdd(remove_files,  add_files.index(ii).vname) > -1 ) {
524                                         // the add file is in the remove list, and it does not exist - do not add it..
525                                         print("check exists ? %s\n",add_files.index(ii).fullpath());
526                                         
527                                         if (!FileUtils.test(add_files.index(ii).fullpath(), FileTest.EXISTS)) {
528                                                         continue;
529                                         }
530                                          
531                                 }
532                                 
533                                 
534                                 
535                                 add_files_f.append_val(add_files.index(ii));
536                         };
537                         
538                         GLib.debug( "ADD : %s\n", GitMonitorQueue.queueArrayToString(add_files_f));
539                         GLib.debug( "REMOVE FILES: %s\n", GitMonitorQueue.queueArrayToString(remove_files_f));
540                     
541                     if (add_files_f.length < 1 && remove_files_f.length < 1) {
542                                 continue;
543                     }
544                     
545                         // make sure monitoring is paused so it does not recursively pick up
546                         // deletions
547                         this.paused = true; 
548                           
549                           
550                         try {
551                                 
552                                 repo.pull();
553                         } catch(Error e) {
554                                 this.pauseError(e.message);
555                                 //failure +=  e.message;
556                                 //print("Pull failed:\n");
557                                 return;
558                         }
559                                                                         
560                         // -- DO STUFF..            
561                         try {
562                                 repo.add(add_files_f);
563                         } catch(Error e) {
564                                 this.pauseError(e.message);
565                                 return;
566                                 failure +=  e.message;
567                                 GLib.debug("Add failed:\n");
568                         }  
569                         try {
570                                  repo.remove(remove_files_f);
571                         } catch(Error e) {
572                                 this.pauseError(e.message);
573                                 return;
574                                 failure +=  e.message;
575                                 GLib.debug("Remove failed:\n");
576                         }  
577
578
579                         try { 
580                                 success += repo.commit(
581                                         GitMonitorQueue.messageToString(messages),
582                                         add_files_f
583                                 );
584                                 success += repo.push();
585
586                         } catch(Error e) {
587                         
588                                 // if the error is 'nothing to commit, working tree clean'
589                                 // then it's not an error, - just continue;
590                                 if (/nothing to commit, working tree clean/.match(e.message)) {
591                                         GLib.debug("%s\n",e.message);
592                                         success += e.message;
593                                         this.paused = false; 
594                                         continue;
595                                 }
596                                 
597                         
598                         
599                                 this.paused = false;                    
600                                 this.pauseError(e.message);
601                                 
602                                 return;
603                                 //failure += e.message;
604                                 //print("Push failed:\n");
605                                 
606                         }   
607                         this.paused = false;                                            
608                 }
609                 
610                 
611                 // finally merge all the commit messages.
612                  
613                 try {
614                         // catch notification failures.. so we can carry on..
615                         if (success.length > 0) {
616
617                                 
618                                 var notification = new Notify.Notification(
619                                         "Git Live Commited",
620                                         string.joinv("\n",success),
621                                          "dialog-information"
622                                         
623                                 );
624         
625                                 notification.set_timeout(5);
626                                 notification.show();   
627                         }
628                         
629                         //if (failure.length > 0) {
630
631                                 // should never get this far...
632                         //      this.pauseError();   
633                         //}
634                 } catch(Error e) {
635                         GLib.debug(e.message);
636                         
637                 }
638                 this.queueRunning = false;
639         }
640         
641
642
643         
644
645         //string[] just_created;
646  
647  
648
649
650
651    
652
653
654         public override  void onChanged(MonitorNamePathDir src) 
655         { 
656                 //print("GitMonitor.onChanged\n");        
657                 return; // always ignore this..?
658                 //this.parsePath(src);
659         }
660         
661
662  
663         /**
664          *  results in  git add  + git commit..
665          *
666          */
667         public override void onChangesDoneHint(MonitorNamePathDir src)  
668         { 
669
670                 if (this.paused) {
671                         return;
672                 }
673                 GLib.debug("GitMonitor.onChangedHint\n");                               
674
675                 this.lastAdd = new DateTime.now(new TimeZone.local()); 
676                 var cmd = new GitMonitorQueue(src);
677                 if (cmd.shouldIgnore()) {
678                         return;
679                 }
680                 
681            
682                 //var add_it = false;
683                 /*
684                 if (this.is_just_created(cmd.path)) {
685                         
686                 if (typeof(this.just_created[src.path]) !='undefined') {
687                         delete this.just_created[src.path];
688                         
689                         this.queue.push( 
690                                 [ src.gitpath,  'add', src.vpath ],
691                                 [ src.gitpath,  'commit',    { message: src.vpath} ] 
692                                 
693                         );
694                  
695                         return;
696                 }
697                 */
698                 cmd.action = "add";
699                 this.queue.append_val(cmd);
700
701                 cmd = new GitMonitorQueue(src);
702                 cmd.action = "commit";
703                 cmd.message = cmd.vname;
704                 this.queue.append_val(cmd);
705  
706                  
707         }
708         public override  void onDeleted(MonitorNamePathDir src) 
709    { 
710
711                 if (this.paused) {
712                         return;
713                 }
714                 GLib.debug("GitMonitor.onDeleted\n");                   
715                 this.lastAdd = new DateTime.now(new TimeZone.local()); 
716                 var cmd = new GitMonitorQueue(src);
717                 if (cmd.shouldIgnore()) {
718                         return;
719                 }
720                 // should check if monitor needs removing..
721                 // it should also check if it was a directory.. - so we dont have to commit all..
722                 cmd.action = "rm";
723                 this.queue.append_val(cmd);
724
725                 cmd = new GitMonitorQueue(src);
726                 cmd.action = "commit";
727                 cmd.message = cmd.vname;
728                 cmd.commit_all = true;
729
730                 this.queue.append_val(cmd);
731  
732         }
733         public override  void onCreated(MonitorNamePathDir src) {
734
735                 if (this.paused) {
736                         return;
737                 }
738                 GLib.debug("GitMonitor.onCreated\n");                   
739                 this.lastAdd = new DateTime.now(new TimeZone.local()); 
740                 var cmd = new GitMonitorQueue(src);
741                 if (cmd.shouldIgnore()) {
742                         return;
743                 }
744
745                 if (!FileUtils.test(src.path, GLib.FileTest.IS_DIR)) {
746                    // this.just_created[src.path] = true;
747                         return; // we do not handle file create flags... - use done hint.
748                 }
749                 // directory has bee created
750                 this.monitor(src.path);
751                 //this.top.append_val(src.path);
752                 //this.monitor(src.path );
753
754
755 // -- no point in adding a dir.. as git does not handle them...
756 //        this.queue.push( 
757   //          [ src.gitpath, 'add' , src.vpath,  { all: true } ],
758  //           [ src.gitpath, 'commit' , { all: true, message: src.vpath} ]
759   //          
760    //     );
761
762         }
763
764         public  override void onAttributeChanged(MonitorNamePathDir src) { 
765
766                 if (this.paused) {
767                         return;
768                 }
769                 GLib.debug("GitMonitor.onAttributeChanged\n");                  
770                 if (src.dir == GitMonitor.gitlive) {
771                    return; // attribute on top level..
772                 }
773                 
774                 this.lastAdd = new DateTime.now(new TimeZone.local()); 
775                 var cmd = new GitMonitorQueue(src);
776                 if (cmd.shouldIgnore()) {
777                         return;
778                 }
779                 cmd.action = "add";
780                 this.queue.append_val(cmd);
781
782                 cmd = new GitMonitorQueue(src);
783                 cmd.action = "commit";
784                 cmd.message = "Attribute changed " + cmd.vname;
785                 this.queue.append_val(cmd);
786         }
787  
788    public  override void onMoved(MonitorNamePathDir src,MonitorNamePathDir dest)  
789         { 
790
791                 if (this.paused) {
792                         return;
793                 }
794                 GLib.debug("GitMonitor.onMoved\n");                     
795                 this.lastAdd = new DateTime.now(new TimeZone.local()); 
796                 var cmd_s = new GitMonitorQueue(src);
797
798                 var cmd_d = new GitMonitorQueue(dest);
799    
800                 
801                 if (cmd_d.gitpath != cmd_s.gitpath) {
802                         this.onDeleted(src);
803                         this.onCreated(dest);
804                         this.onChangesDoneHint(dest);
805                         return;
806                 }
807                 // needs to handle move to/from unsupported types..
808                 
809                 if (cmd_s.shouldIgnore()) {
810                         this.onCreated(dest);
811                         this.onChangesDoneHint(dest);
812                         return;
813
814                 }
815                 if (cmd_d.shouldIgnore()) {
816                         
817                         this.onDeleted(src);
818  
819
820                         return;
821                 }
822                 
823                 
824                 GLib.debug("RM: %s\n", cmd_s.vname);
825                 cmd_s.action = "rm";
826                 this.queue.append_val(cmd_s);
827
828                 
829                 
830                 GLib.debug("ADD: %s\n", cmd_d.vname);
831                 cmd_d.action = "add";
832                 this.queue.append_val(cmd_d);
833
834
835                 var cmd = new GitMonitorQueue(dest);
836                 cmd.action = "commit";
837                 cmd.message = "MOVED " + cmd_s.vname + " to " + cmd_d.vname;
838                 if (GitMonitorQueue.queueHas(this.queue, cmd_s, "add")) {
839                         cmd.message = cmd_d.vname;
840                 }
841                 
842                 this.queue.append_val(cmd);
843
844
845                  
846         }
847            
848 }