X-Git-Url: http://git.roojs.org/?p=gitlive;a=blobdiff_plain;f=GitMonitorQueue.vala;h=00ab4655f9249e7530f0a98aa071a5eaf3b23313;hp=e69de29bb2d1d6434b8b29ae775ad8c2e48c5391;hb=refs%2Fheads%2Fwip_alan_T5623_reset_pull_create_ticket_on;hpb=ac0249e6dd2ead169141df2ca7f3b2afebb45c30 diff --git a/GitMonitorQueue.vala b/GitMonitorQueue.vala index e69de29b..00ab4655 100644 --- a/GitMonitorQueue.vala +++ b/GitMonitorQueue.vala @@ -0,0 +1,161 @@ + + +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 GitRepo repo; + + 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; + + this.repo = GitRepo.get(this.gitpath); + + // trigger the suggestion to start a new branch + + } + + + 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( Gee.ArrayList add_files, string add) + { + for(var i =0; i < add_files.size; i++) { + if (add_files.get(i).vname == add) { + return i; + } + } + return -1; + } + public static int indexOfMessage(Gee.ArrayList messages, string message) { + for(var i =0; i < messages.size; i++) { + if (messages.get(i).message == message) { + return i; + } + } + return -1; + } + public static string messageToString(Gee.ArrayList messages ) { + string[] ret = {}; + for(var i =0; i < messages.size; i++) { + ret+= messages.get(i).message; + } + return string.joinv("\n",ret); + } + public static string queueArrayToString(Gee.ArrayList list) { + var ret = ""; + for(var i =0; i < list.size; i++) { + + ret += (ret.length > 0 ? ", " : "") + list.get(i).vname; + } + return ret; + + } + + public static bool queueHas(Gee.ArrayList list , GitMonitorQueue cmd_s, string action) { + for(var i =0; i < list.size; i++) { + var test = list.get(i); + if (list.get(i).gitpath != cmd_s.gitpath) { + continue; + } + if (list.get(i).vname != cmd_s.vname) { + continue; + } + if (list.get(i).action != action) { + continue; + } + return true; + } + return false; + } + public string fullpath() + { + return this.gitpath + "/" + this.vname; + } + + + +} +