X-Git-Url: http://git.roojs.org/?a=blobdiff_plain;f=GitMonitor.vala;h=ef2bdca068cd89a39e7b3f4dc9d38515fa11aef6;hb=a48a0eb41c2ae2effd6bf8f4fa018cab6128ca02;hp=ea9e7ce2536ff7961596c0da88d8a80968a2a48d;hpb=00039b69a5991f423826f4d1ceea2127265650a3;p=gitlive diff --git a/GitMonitor.vala b/GitMonitor.vala index ea9e7ce2..ef2bdca0 100644 --- a/GitMonitor.vala +++ b/GitMonitor.vala @@ -21,12 +21,13 @@ public class GitMonitorQueue : MonitorNamePathDir { var vpath_ar = this.dir.substring(GitMonitor.gitlive.length +1).split("/", 0); - if (vpath_ar[0].length < 1) { + if (vpath_ar.length < 1 || vpath_ar[0].length < 1) { this.gitpath = ""; this.vdir = ""; this.vname = ""; - } + return; + } this.gitpath = GitMonitor.gitlive + "/" + vpath_ar[0]; @@ -40,9 +41,7 @@ public class GitMonitorQueue : MonitorNamePathDir { this.vname = this.vdir + (this.vdir.length > 0 ? "/" : "") + this.name; - - - + /* stdout.printf( "NEW GitMonitorQueue\nname: %s\npath: %s\ndir: %s\n" + @@ -60,30 +59,39 @@ public class GitMonitorQueue : MonitorNamePathDir { public bool shouldIgnore() { - // vim.. what a seriously brain dead program.. if (this.name == "4913") { + GLib.debug("ignore name = 4913"); return true; } + if (this.name[0] == '.') { // except! if (this.name == ".htaccess") { + return false; } - + if (this.name == ".gitignore") { + return false; + } + GLib.debug("ignore name starts with dot %s", this.name); return true; } + if (this.name[this.name.length -1] == '~') { + GLib.debug("ignore name ends with ~"); return true; } // netbeans / android studio.. silly temp files.. if (Regex.match_simple("___jb_old___$", this.name)) { + GLib.debug("ignore name includes jb_old"); return true; } if (Regex.match_simple("___jb_bak___$", this.name)) { + GLib.debug("ignore name includes jb_bkc"); return true; } //if (f.name.match(/^nbproject/)) { @@ -91,6 +99,7 @@ public class GitMonitorQueue : MonitorNamePathDir { //} // ignore anything in top level!!!! if (this.gitpath.length < 1) { + GLib.debug("ignore gitpath length is empty"); return true; } @@ -176,15 +185,22 @@ public class GitMonitor : Monitor public bool queueRunning = false; public DateTime lastAdd; - - + + + public GitMonitor () { + + + this.queue = new Array(); GitMonitor.gitmonitor = this; - Timeout.add_full(Priority.LOW, 1000, () => { + + + + Timeout.add_full(Priority.LOW, 500, () => { - //print("TIMEOUT queue length = %d, is_runing = %s\n", (int)this.queue.length , this.queueRunning ? "Y" : "N"); + //GLib.debug("TIMEOUT queue length = %d, is_runing = %s\n", (int)this.queue.length , this.queueRunning ? "Y" : "N"); //stdout.printf("QL %u: QR: %d\n", this.queue.length, this.queueRunning ? 1 : 0); if (this.queue.length < 1 || this.queueRunning) { @@ -222,7 +238,18 @@ public class GitMonitor : Monitor notification.set_timeout(60); // show errros for longer notification.show(); - + Canberra.Context context; + Canberra.Proplist props; + + Canberra.Context.create (out context); + Canberra.Proplist.create (out props); + + props.sets (Canberra.PROP_EVENT_ID, "phone-outgoing-busy"); + props.sets (Canberra.PROP_EVENT_DESCRIPTION, "Gitlive stopped on error"); + + + context.play_full (0, props, null); + @@ -299,7 +326,7 @@ public class GitMonitor : Monitor notification.set_timeout(5); notification.show(); } catch(Error e) { - print("Error %s\n",e.message); + GLib.debug("Error sending notification to screen: %s",e.message); } return false; // do not keep doing this.. @@ -360,7 +387,7 @@ public class GitMonitor : Monitor if (this.paused) { return; } - print("GitMonitor.runQueue\n"); + GLib.debug("GitMonitor.runQueue\n"); this.queueRunning = true; @@ -388,21 +415,21 @@ public class GitMonitor : Monitor this.paused = true; - print("GitMonitor.runQueue - creating repos\n"); + GLib.debug("GitMonitor.runQueue - creating repos"); for(var i = 0; i < cmds.length; i++) { var cmd = cmds.index(i); var gitpath = cmd.gitpath; - stdout.printf("GitMonitor.runQueue - finding %s\n", cmd.gitpath); + GLib.debug("GitMonitor.runQueue - finding %s", cmd.gitpath); var ix = GitRepo.indexOf(repo_list, cmd.gitpath); if (ix < 0) { repo_list.append_val(new GitRepo( gitpath )); ix = GitRepo.indexOf(repo_list, cmd.gitpath); } - stdout.printf("GitMonitor.runQueue - adding to repolist %d\n", ix); + GLib.debug("GitMonitor.runQueue - adding to repolist %d", ix); //if (typeof(repo_list[gitpath]) == 'undefined') { // repo_list[gitpath] = new imports.Scm.Git.Repo.Repo( { repopath : gitpath }); @@ -415,7 +442,7 @@ public class GitMonitor : Monitor this.paused = false; // build add, remove and commit message list.. - print("GitMonitor.runQueue - creating actions\n"); + GLib.debug("GitMonitor.runQueue - creating actions"); for(var i = 0;i < repo_list.length;i++) { @@ -470,8 +497,8 @@ public class GitMonitor : Monitor break; } } - print( "ADD : %s\n", GitMonitorQueue.queueArrayToString(add_files)); - print( "REMOVE FILES: %s\n", GitMonitorQueue.queueArrayToString(remove_files)); + GLib.debug( "ADD : %s", GitMonitorQueue.queueArrayToString(add_files)); + GLib.debug( "REMOVE FILES: %s", GitMonitorQueue.queueArrayToString(remove_files)); //repo.debug = 1; // these can fail... at present... as we wildcard stuff. @@ -516,14 +543,18 @@ public class GitMonitor : Monitor add_files_f.append_val(add_files.index(ii)); }; - print( "ADD : %s\n", GitMonitorQueue.queueArrayToString(add_files_f)); - print( "REMOVE FILES: %s\n", GitMonitorQueue.queueArrayToString(remove_files_f)); + GLib.debug( "ADD : %s", GitMonitorQueue.queueArrayToString(add_files_f)); + GLib.debug( "REMOVE FILES: %s", GitMonitorQueue.queueArrayToString(remove_files_f)); + + if (add_files_f.length < 1 && remove_files_f.length < 1) { + continue; + } // make sure monitoring is paused so it does not recursively pick up // deletions this.paused = true; - - + + try { repo.pull(); @@ -533,7 +564,7 @@ public class GitMonitor : Monitor //print("Pull failed:\n"); return; } - + // -- DO STUFF.. try { repo.add(add_files_f); @@ -541,7 +572,7 @@ public class GitMonitor : Monitor this.pauseError(e.message); return; failure += e.message; - print("Add failed:\n"); + GLib.debug("Add failed:"); } try { repo.remove(remove_files_f); @@ -549,7 +580,7 @@ public class GitMonitor : Monitor this.pauseError(e.message); return; failure += e.message; - print("Remove failed:\n"); + GLib.debug("Remove failed:"); } @@ -564,9 +595,10 @@ public class GitMonitor : Monitor // if the error is 'nothing to commit, working tree clean' // then it's not an error, - just continue; - if (/nothing to commit, working tree clean/.match(e.message)) { + GLib.debug("%s",e.message); success += e.message; + this.paused = false; continue; } @@ -608,7 +640,7 @@ public class GitMonitor : Monitor // this.pauseError(); //} } catch(Error e) { - print(e.message); + GLib.debug(e.message); } this.queueRunning = false; @@ -646,15 +678,15 @@ public class GitMonitor : Monitor if (this.paused) { return; } - print("GitMonitor.onChangedHint\n"); + GLib.debug("GitMonitor.onChangedHint"); this.lastAdd = new DateTime.now(new TimeZone.local()); var cmd = new GitMonitorQueue(src); if (cmd.shouldIgnore()) { + GLib.debug("GitMonitor.onChangedHint - ignored"); return; } - //var add_it = false; /* if (this.is_just_created(cmd.path)) { @@ -687,7 +719,7 @@ public class GitMonitor : Monitor if (this.paused) { return; } - print("GitMonitor.onDeleted\n"); + GLib.debug("GitMonitor.onDeleted"); this.lastAdd = new DateTime.now(new TimeZone.local()); var cmd = new GitMonitorQueue(src); if (cmd.shouldIgnore()) { @@ -711,7 +743,7 @@ public class GitMonitor : Monitor if (this.paused) { return; } - print("GitMonitor.onCreated\n"); + GLib.debug("GitMonitor.onCreated"); this.lastAdd = new DateTime.now(new TimeZone.local()); var cmd = new GitMonitorQueue(src); if (cmd.shouldIgnore()) { @@ -742,7 +774,7 @@ public class GitMonitor : Monitor if (this.paused) { return; } - print("GitMonitor.onAttributeChanged\n"); + GLib.debug("GitMonitor.onAttributeChanged %s", src.name); if (src.dir == GitMonitor.gitlive) { return; // attribute on top level.. } @@ -767,7 +799,7 @@ public class GitMonitor : Monitor if (this.paused) { return; } - print("GitMonitor.onMoved\n"); + GLib.debug("GitMonitor.onMoved"); this.lastAdd = new DateTime.now(new TimeZone.local()); var cmd_s = new GitMonitorQueue(src); @@ -797,13 +829,13 @@ public class GitMonitor : Monitor } - print("RM: %s\n", cmd_s.vname); + GLib.debug("RM: %s", cmd_s.vname); cmd_s.action = "rm"; this.queue.append_val(cmd_s); - print("ADD: %s\n", cmd_d.vname); + GLib.debug("ADD: %s", cmd_d.vname); cmd_d.action = "add"; this.queue.append_val(cmd_d);