X-Git-Url: http://git.roojs.org/?p=gitlive;a=blobdiff_plain;f=GitMonitor.vala;h=4c79f5ee41dc9e3cf03d390c56f2196300887b03;hp=864e04620de18bef0652134534174f35924531ab;hb=refs%2Fheads%2Fwip_alan_T5782_messing_around_with_libgit2glib;hpb=90a8811292c4a2d78b55edf043d0c2cd844c0608 diff --git a/GitMonitor.vala b/GitMonitor.vala index 864e0462..4c79f5ee 100644 --- a/GitMonitor.vala +++ b/GitMonitor.vala @@ -54,13 +54,21 @@ public class GitMonitor : Monitor if (this.queue.size < 1 || this.queueRunning) { return true; } + var first = this.queue.get(0); + var delay = true; + + // eg. on master.... and is_auto branch + if (first.repo.is_master_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(); @@ -163,24 +171,8 @@ public class GitMonitor : Monitor this.monitor(this.top.index(i) ); } - StatusIconA.statusicon.resume(); - this.paused = false; - - try { - - - var notification = new Notify.Notification( - "Git Live", - "%s\nMonitoring %u Directories".printf(GitMonitor.gitlive, this.monitors.length), - "dialog-information" - ); - - notification.set_timeout(5); - notification.show(); - } catch(Error e) { - GLib.debug("Error sending notification to screen: %s",e.message); - } + return false; // do not keep doing this.. }); @@ -189,7 +181,29 @@ public class GitMonitor : Monitor } + int scanning = 0; + int scancomplete = 0; + public void updateMonitorsComplete() + { + StatusIconA.statusicon.resume(); + this.paused = false; + + + try { + + var notification = new Notify.Notification( + "Git Live", + "%s\nMonitoring %u Directories".printf(GitMonitor.gitlive, this.monitors.length), + "dialog-information" + ); + + notification.set_timeout(5); + notification.show(); + } catch(Error e) { + GLib.debug("Error sending notification to screen: %s",e.message); + } + } public new void stop() { StatusIconA.statusicon.pause(); @@ -197,12 +211,18 @@ public class GitMonitor : Monitor } + // this is called recursively until we end.. + public override void monitor (string path, int depth = 0) { //GLib.debug("GitMonitor : monitor %d %s", depth, path); //var depth = typeof(depth) == 'number' ? depth *1 : 0; + if (depth == 0) { + this.scancomplete = 0; + this.scanning = 0; + } // if we are not at top level.. and there is a .git directory (it's a submodule .. ignore) if (depth > 1 && FileUtils.test(path + "/.git" , FileTest.IS_DIR)) { @@ -214,9 +234,17 @@ public class GitMonitor : Monitor if (!FileUtils.test(path + "/.git" , FileTest.IS_DIR)) { return; // skip non-git directories.. } - - GitRepo.get(path); - + this.scanning++; + GitRepo.get.begin(path, (ojb,res) => { + + GitRepo.get.end(res); + base.monitor(path, depth); + this.scanning--; + if (this.scanning == 0 && this.scancomplete == 1) { + this.updateMonitorsComplete(); + } + }); + return; // FIXME - check if repo is flagged as not autocommit.. //var repo = imports.Scm.Repo.Repo.get(path); //if (!repo || !repo.autocommit()) { @@ -230,6 +258,11 @@ public class GitMonitor : Monitor base.monitor(path, depth); + if (depth == 0) { + this.scancomplete = 1; + } + + } @@ -250,7 +283,7 @@ public class GitMonitor : Monitor } foreach(var q in this.queue) { - if (!q.shouldIgnore() && !q.repo.is_wip_branch()) { + if (!q.shouldIgnore() && q.repo.is_master_branch() && q.repo.is_auto_branch()) { var oldq = this.queue; this.queue = new Gee.ArrayList(); NewBranch.singleton().show(q.repo, oldq); @@ -262,7 +295,7 @@ public class GitMonitor : Monitor - GLib.debug("GitMonitor.runQueue\n"); + GLib.debug("GitMonitor.runQueue size =%d\n", this.queue.size); this.queueRunning = true; @@ -298,8 +331,8 @@ public class GitMonitor : Monitor var gitpath = cmd.gitpath; - var repo = GitRepo.get( gitpath ); - if ( !repo.is_wip_branch()) { + var repo = GitRepo.get_sync( gitpath ); + if ( repo.is_master_branch() && repo.is_auto_branch()) { leave_queued.add(cmd); continue; } @@ -308,7 +341,7 @@ public class GitMonitor : Monitor var ix = GitRepo.indexOf(repo_list, gitpath); if (ix < 0) { - repo_list.append_val( GitRepo.get( gitpath )); + repo_list.append_val( GitRepo.get_sync( gitpath )); ix = GitRepo.indexOf(repo_list, cmd.gitpath); } GLib.debug("GitMonitor.runQueue - adding to repolist %d", ix); @@ -595,9 +628,7 @@ public class GitMonitor : Monitor cmd.action = "commit"; cmd.message = cmd.vname; this.queue.add(cmd); - - - + } public override void onDeleted(MonitorNamePathDir src) @@ -623,9 +654,6 @@ public class GitMonitor : Monitor cmd.commit_all = true; this.queue.add(cmd); - - - } public override void onCreated(MonitorNamePathDir src) { @@ -682,8 +710,6 @@ public class GitMonitor : Monitor cmd.action = "commit"; cmd.message = "Attribute changed " + cmd.vname; this.queue.add(cmd); - - } public override void onMoved(MonitorNamePathDir src,MonitorNamePathDir dest) @@ -716,12 +742,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); @@ -740,14 +763,9 @@ public class GitMonitor : Monitor cmd.message = cmd_d.vname; } - this.queue.add(cmd); - - // this is where it get's complicated... - // as we might be moving across repo's... - - - + + }