X-Git-Url: http://git.roojs.org/?p=gitlive;a=blobdiff_plain;f=GitMonitor.vala;h=7e42154a36ed151ddd550430b44291e697db7edc;hp=17dedfc4b088556a3a554729748265f8d7e6f8ce;hb=24f29cdf6887c0f05430d83cffaebf69bfa40083;hpb=2501c49cbcd0cc3205b84bc1e33b08faf0e5b8ef diff --git a/GitMonitor.vala b/GitMonitor.vala index 17dedfc4..7e42154a 100644 --- a/GitMonitor.vala +++ b/GitMonitor.vala @@ -1,7 +1,25 @@ +/** +The monitor suffers from various issues - basically event flows while it's running... + +normall operations + +- monitors for file changes + -- adds to QUEUE when occurs. + +- queue runs in background. + - if it's got stuff in it.. + - COMMIT (normally) + - now?? - if on master - try and branch + == do user selection, until we have branched + == then start monitoring again.. + +*/ + + public class GitMonitor : Monitor @@ -36,13 +54,19 @@ public class GitMonitor : Monitor if (this.queue.size < 1 || this.queueRunning) { return true; } + var first = this.queue.get(0); + var delay = true; + if (!first.repo.is_wip_branch() && first.repo.is_auto_branch()) { + delay = false; + } + var last = -1 * this.lastAdd.difference(new DateTime.now(new TimeZone.local())); // stdout.printf("LAST RUN: %s (expect %s) \n" , // last.to_string(), (5 * TimeSpan.SECOND).to_string() ); - if (last < 5 * TimeSpan.SECOND) { // wait 5 seconds before running. ???? + if (delay && last < 5 * TimeSpan.SECOND) { // wait 5 seconds before running. ???? return true; } //_this.lastAdd = new Date(); @@ -111,6 +135,12 @@ public class GitMonitor : Monitor } + public void restoreQueue( Gee.ArrayList queue) + { + //used to restore teh queue after switch branches?/ - breaks our privte queue idea.. + this.queue = queue; + } + /* public new void resume () { this.paused = false; @@ -226,8 +256,11 @@ public class GitMonitor : Monitor } foreach(var q in this.queue) { - if (!q.shouldIgnore() && !q.repo.is_wip_branch()) { - NewBranch.singleton().show(q.repo); + if (!q.shouldIgnore() && !q.repo.is_wip_branch() && q.repo.is_auto_branch()) { + var oldq = this.queue; + this.queue = new Gee.ArrayList(); + NewBranch.singleton().show(q.repo, oldq); + return; } @@ -235,7 +268,7 @@ public class GitMonitor : Monitor - GLib.debug("GitMonitor.runQueue\n"); + GLib.debug("GitMonitor.runQueue size =%d\n", this.queue.size); this.queueRunning = true; @@ -272,7 +305,7 @@ public class GitMonitor : Monitor var gitpath = cmd.gitpath; var repo = GitRepo.get( gitpath ); - if ( !repo.is_wip_branch()) { + if ( !repo.is_wip_branch() && repo.is_auto_branch()) { leave_queued.add(cmd); continue; } @@ -568,11 +601,6 @@ public class GitMonitor : Monitor cmd.action = "commit"; cmd.message = cmd.vname; this.queue.add(cmd); - - - if (!cmd.shouldIgnore() && !cmd.repo.is_wip_branch()) { - NewBranch.singleton().show(cmd.repo); - } } @@ -599,11 +627,6 @@ public class GitMonitor : Monitor cmd.commit_all = true; this.queue.add(cmd); - - if (!cmd.shouldIgnore() && !cmd.repo.is_wip_branch()) { - NewBranch.singleton().show(cmd.repo); - } - } public override void onCreated(MonitorNamePathDir src) { @@ -660,10 +683,6 @@ public class GitMonitor : Monitor cmd.action = "commit"; cmd.message = "Attribute changed " + cmd.vname; this.queue.add(cmd); - - if (!cmd.shouldIgnore() && !cmd.repo.is_wip_branch()) { - NewBranch.singleton().show(cmd.repo); - } } public override void onMoved(MonitorNamePathDir src,MonitorNamePathDir dest) @@ -696,12 +715,9 @@ public class GitMonitor : Monitor if (cmd_d.shouldIgnore()) { this.onDeleted(src); - - return; } - - + GLib.debug("RM: %s", cmd_s.vname); cmd_s.action = "rm"; this.queue.add(cmd_s); @@ -720,17 +736,9 @@ public class GitMonitor : Monitor cmd.message = cmd_d.vname; } - this.queue.add(cmd); - if (!cmd.shouldIgnore() && !cmd.repo.is_wip_branch()) { - NewBranch.singleton().show(cmd.repo); - } - // this is where it get's complicated... - // as we might be moving across repo's... - - - + }