X-Git-Url: http://git.roojs.org/?a=blobdiff_plain;f=GitMonitor.vala;h=4d51102744ef1934bf716b24c8468039a2b9a4a7;hb=9ca55e5b3b07eebe90b2d9c8c254156d1d9e4a74;hp=ef2bdca068cd89a39e7b3f4dc9d38515fa11aef6;hpb=176e7d3b7f26a9a1350d6fa89b10a8fdaed3a7f1;p=gitlive diff --git a/GitMonitor.vala b/GitMonitor.vala index ef2bdca0..4d511027 100644 --- a/GitMonitor.vala +++ b/GitMonitor.vala @@ -1,173 +1,5 @@ - - -public class GitMonitorQueue : MonitorNamePathDir { - // name = basename - // path = full path.. - // dir = dir path - - public string gitpath; - public string vdir; // relative path (within git) - public string vname; // relative filename (within git) - public string message ; // for commit - public bool commit_all; - - public GitMonitorQueue(MonitorNamePathDir f) { - - base(f.name, f.path, f.dir); - - this.message = ""; - this.commit_all = false; - - var vpath_ar = this.dir.substring(GitMonitor.gitlive.length +1).split("/", 0); - - if (vpath_ar.length < 1 || vpath_ar[0].length < 1) { - - this.gitpath = ""; - this.vdir = ""; - this.vname = ""; - return; - } - - - this.gitpath = GitMonitor.gitlive + "/" + vpath_ar[0]; - - string[] vpath = {}; - for (var i = 1; i< vpath_ar.length; i++) { - vpath += vpath_ar[i]; - } - - this.vdir = string.joinv("/", vpath); - - this.vname = this.vdir + (this.vdir.length > 0 ? "/" : "") + this.name; - - -/* - stdout.printf( - "NEW GitMonitorQueue\nname: %s\npath: %s\ndir: %s\n" + - "gitpath: %s\nvdir: %s\nvname: %s\n", - this.name, this.path, this.dir, - this.gitpath, this.vdir, this.vname - ); -*/ - - //f.repo = new imports.Scm.Git.Repo({ repopath: f.gitpath }) - - - } - - 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/)) { - // return true; - //} - // ignore anything in top level!!!! - if (this.gitpath.length < 1) { - GLib.debug("ignore gitpath length is empty"); - return true; - } - - return false; - } - - /** -- statics --*/ - - public static int indexOfAdd( Array add_files, string add) - { - for(var i =0; i < add_files.length; i++) { - if (add_files.index(i).vname == add) { - return i; - } - } - return -1; - } - public static int indexOfMessage(Array messages, string message) { - for(var i =0; i < messages.length; i++) { - if (messages.index(i).message == message) { - return i; - } - } - return -1; - } - public static string messageToString(Array messages ) { - string[] ret = {}; - for(var i =0; i < messages.length; i++) { - ret+= messages.index(i).message; - } - return string.joinv("\n",ret); - } - public static string queueArrayToString(Array 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 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; - } - public string fullpath() - { - return this.gitpath + "/" + this.vname; - } - - - -} - - + public class GitMonitor : Monitor { @@ -188,18 +20,13 @@ public class GitMonitor : Monitor - public GitMonitor () { - - + public GitMonitor () + { this.queue = new Array(); GitMonitor.gitmonitor = this; - - - - Timeout.add_full(Priority.LOW, 500, () => { - + //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); @@ -222,7 +49,6 @@ public class GitMonitor : Monitor return true; // }); - } public new void pauseError(string failure) @@ -422,11 +248,17 @@ public class GitMonitor : Monitor var cmd = cmds.index(i); var gitpath = cmd.gitpath; + + var repo = GitRepo.get( gitpath ); + if ( !repo.isWipBranch()) { + continue; + } + 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 )); + repo_list.append_val( GitRepo.get( gitpath )); ix = GitRepo.indexOf(repo_list, cmd.gitpath); } GLib.debug("GitMonitor.runQueue - adding to repolist %d", ix);