From: Alan Knowles Date: Thu, 1 Nov 2018 13:03:53 +0000 (+0800) Subject: sync X-Git-Url: http://git.roojs.org/?p=gitlive;a=commitdiff_plain;h=265adcf86cbf103f51c08f6a02ba486633b148b0 sync --- diff --git a/Clones.bjs b/Clones.bjs index 68cb9b2d..a1630a75 100644 --- a/Clones.bjs +++ b/Clones.bjs @@ -13,8 +13,8 @@ "response" : "(self, response_id) => { \n \n this.el.hide();\n \n}" }, "default_width" : 800, - "| void show" : "() {\n\n \n this.el.set_deletable(false);\n this.el.set_gravity(Gdk.Gravity.NORTH);\n this.el.move((Gdk.Screen.width() / 2 ) -400 ,0);\n this.el.show_all();\n _this.reposStore.load();\n // load clones..\n// this.get('/reposStore').load();\n \n //this.get('/ok_button').el.set_sensitive(false);\n \n // block until we return.\n// var run_ret = this.el.run();\n// if (run_ret < 1 ) {\n// return \"DONE\";\n// }\n// print(\"RUN RETURN : \" + run_ret);\n// return \"DONE\";\n //print(JSON.stringify(this.get('bug').getValue()));\n // return this.get('bug').getValue();\n //this.success = c.success;\n}\n", "$ deletable" : true, + "| void show" : "() {\n\n \n this.el.set_deletable(false);\n this.el.set_gravity(Gdk.Gravity.NORTH);\n this.el.move((Gdk.Screen.width() / 2 ) -400 ,0);\n this.el.show_all();\n _this.reposStore.load();\n // load clones..\n// this.get('/reposStore').load();\n \n //this.get('/ok_button').el.set_sensitive(false);\n \n // block until we return.\n// var run_ret = this.el.run();\n// if (run_ret < 1 ) {\n// return \"DONE\";\n// }\n// print(\"RUN RETURN : \" + run_ret);\n// return \"DONE\";\n //print(JSON.stringify(this.get('bug').getValue()));\n // return this.get('bug').getValue();\n //this.success = c.success;\n}\n", "title" : "Manage Clones", "xtype" : "Dialog", "default_height" : 500, @@ -39,17 +39,17 @@ "clicked" : "() => {\n\n/* var rv = this.get('/reposView');\n var rs = this.get('/reposStore');\n if (rv.el.get_selection().count_selected_rows() != 1) {\n //nothing?\n // error condition.\n return;\n }\n var Remotes = imports.Remotes.Remotes;\n \n \n var ret = {}; \n var s = rv.el.get_selection();\n var path = '';\n s.selected_foreach(function(model,p,iter) {\n \n path = model.get_value(iter, 6).value.get_string();\n \n }); \n\n var repo = false;\n rs.repos.forEach(function(r) {\n if (r.repopath == path) {\n repo = r;\n \n }\n \n });\n Remotes.repo = repo;\n Remotes.el.set_transient_for(Clones.el);\n Clones.el.set_title(\"Manage Clones - \" + repo.repopath);\n Remotes.show();\n Clones.el.set_title(\"Manage Clones\");\n\n */ \n \n \n\n \n \n \n}" }, "label" : "Remotes / Clones", - "* pack" : "add", "xtype" : "Button", + "* pack" : "add", "$ xns" : "Gtk" }, { "listeners" : { - "clicked" : "() => {\n// \n\n\tNewBranch.singleton().show();\n\n/*\n var rv = this.get('/reposView');\n var rs = this.get('/reposStore');\n if (rv.el.get_selection().count_selected_rows() != 1) {\n //nothing?\n // error condition.\n return;\n }\n var Branches = imports.Branches.Branches;\n \n \n var ret = {}; \n var s = rv.el.get_selection();\n var path = '';\n s.selected_foreach(function(model,p,iter) {\n \n path = model.get_value(iter, 6).value.get_string();\n \n }); \n\n var repo = false;\n rs.repos.forEach(function(r) {\n if (r.repopath == path) {\n repo = r;\n \n }\n \n });\n Branches.repo = repo;\n Branches.el.set_transient_for(Clones.el);\n Clones.el.set_title(\"Manage Clones - \" + repo.repopath);\n Branches.show();\n Clones.el.set_title(\"Manage Clones\");\n\n \n \n \n \n\n \n */ \n \n}" + "clicked" : "() => {\n// \n\n\t//NewBranch.singleton().show();\n\n/*\n var rv = this.get('/reposView');\n var rs = this.get('/reposStore');\n if (rv.el.get_selection().count_selected_rows() != 1) {\n //nothing?\n // error condition.\n return;\n }\n var Branches = imports.Branches.Branches;\n \n \n var ret = {}; \n var s = rv.el.get_selection();\n var path = '';\n s.selected_foreach(function(model,p,iter) {\n \n path = model.get_value(iter, 6).value.get_string();\n \n }); \n\n var repo = false;\n rs.repos.forEach(function(r) {\n if (r.repopath == path) {\n repo = r;\n \n }\n \n });\n Branches.repo = repo;\n Branches.el.set_transient_for(Clones.el);\n Clones.el.set_title(\"Manage Clones - \" + repo.repopath);\n Branches.show();\n Clones.el.set_title(\"Manage Clones\");\n\n \n \n \n \n\n \n */ \n \n}" }, "label" : "Branches", - "* pack" : "add", "xtype" : "Button", + "* pack" : "add", "$ xns" : "Gtk" }, { @@ -57,8 +57,8 @@ "clicked" : "() => {\n/*\n var rv = this.get('/reposView');\n var rs = this.get('/reposStore');\n if (rv.el.get_selection().count_selected_rows() != 1) {\n //nothing?\n // error condition.\n return;\n }\n var Merger = imports.Merger.Merger;\n \n \n var ret = {}; \n var s = rv.el.get_selection();\n var path = '';\n s.selected_foreach(function(model,p,iter) {\n \n path = model.get_value(iter, 6).value.get_string();\n \n }); \n\n var repo = false;\n rs.repos.forEach(function(r) {\n if (r.repopath == path) {\n repo = r;\n \n }\n \n });\n Merger.repo = repo;\n Merger.el.set_transient_for(Clones.el);\n Clones.el.set_title(\"Manage Clones - \" + repo.repopath);\n Merger.show();\n Clones.el.set_title(\"Manage Clones\");\n\n \n \n\n \n \n\n */ \n \n \n}" }, "label" : "Merge", - "* pack" : "add", "xtype" : "Button", + "* pack" : "add", "$ xns" : "Gtk" }, { @@ -66,8 +66,8 @@ "clicked" : "() => {\n \n \n \n \n \n \n}" }, "label" : "Switch Branch", - "* pack" : "add", "xtype" : "Button", + "* pack" : "add", "$ xns" : "Gtk" }, { @@ -75,16 +75,16 @@ "clicked" : "() => {\n \n \n \n \n \n \n}" }, "label" : "Pull", - "* pack" : "add", "xtype" : "Button", + "* pack" : "add", "$ xns" : "Gtk" } ] }, { "* init" : " {\n \n this.el.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);\n}\n", - "bool hexpand" : true, "bool expand" : true, + "bool hexpand" : true, "xtype" : "ScrolledWindow", "* pack" : "pack_end,true,true,0", "Gtk.ShadowType shadow_type" : "Gtk.ShadowType.IN", @@ -124,8 +124,8 @@ "toggled" : " (self, path) => {\n/* var ret ={} ;\n var store = this.get('/reposStore');\n store.el.get_iter_from_string(ret, path);\n \n var value = store.el.get_value(ret.iter,4).value.get_boolean();\n \n //print(JSON.stringify(value));\n store.el.set_value(ret.iter,4, !value);\n \n var path = store.el.get_value(ret.iter, 6).value.get_string();\n var repo = imports.Scm.Repo.Repo.get(path);\n repo.autocommit(!value);\n */ \n \n \n}" }, "id" : "cr_autocommit", - "* pack" : "pack_start,false", "xtype" : "CellRendererToggle", + "* pack" : "pack_start,false", "$ xns" : "Gtk", "$ mode" : "Gtk.CellRendererMode.ACTIVATABLE" } @@ -145,8 +145,8 @@ "toggled" : " (self, path) => {\n/* var ret ={} ;\n var store = this.get('/reposStore');\n store.el.get_iter_from_string(ret, path);\n \n var value = store.el.get_value(ret.iter,5).value.get_boolean();\n \n //print(JSON.stringify(value));\n store.el.set_value(ret.iter,5, !value);\n var path = store.el.get_value(ret.iter, 6).value.get_string();\n var repo = imports.Scm.Repo.Repo.get(path);\n repo.autopush(!value);\n */\n}" }, "id" : "cr_autopush", - "* pack" : "pack_start,false", "xtype" : "CellRendererToggle", + "* pack" : "pack_start,false", "$ xns" : "Gtk", "$ mode" : "Gtk.CellRendererMode.ACTIVATABLE" } @@ -154,8 +154,8 @@ }, { "id" : "tv_repo", - "* init" : "\n this.el.add_attribute(_this.cr_repo.el , \"markup\", 0 );\n", "Gtk.SortType sort_order" : "Gtk.SortType.ASCENDING", + "* init" : "\n this.el.add_attribute(_this.cr_repo.el , \"markup\", 0 );\n", "title" : "Repo", "* pack" : "append_column", "xtype" : "TreeViewColumn", @@ -166,8 +166,8 @@ "items" : [ { "id" : "cr_repo", - "* pack" : "pack_start,false", "xtype" : "CellRendererText", + "* pack" : "pack_start,false", "$ xns" : "Gtk" } ] @@ -183,8 +183,8 @@ "items" : [ { "id" : "cr_current_branch", - "* pack" : "pack_start,false", "xtype" : "CellRendererText", + "* pack" : "pack_start,false", "$ xns" : "Gtk" } ] @@ -200,8 +200,8 @@ "items" : [ { "id" : "cr_last_updated", - "* pack" : "pack_start,false", "xtype" : "CellRendererText", + "* pack" : "pack_start,false", "$ xns" : "Gtk" } ] @@ -218,8 +218,8 @@ "items" : [ { "id" : "cr_all_branches", - "* pack" : "pack_start,false", "xtype" : "CellRendererText", + "* pack" : "pack_start,false", "$ xns" : "Gtk" } ] diff --git a/Clones.vala b/Clones.vala index 5543108a..3a91a661 100644 --- a/Clones.vala +++ b/Clones.vala @@ -244,7 +244,7 @@ public class Clones : Object this.el.clicked.connect( () => { // - NewBranch.singleton().show(); + //NewBranch.singleton().show(); /* var rv = this.get('/reposView'); diff --git a/GitMonitor.vala b/GitMonitor.vala index ef2bdca0..7be1ab56 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 { diff --git a/GitMonitorQueue.vala b/GitMonitorQueue.vala new file mode 100644 index 00000000..1af6eca8 --- /dev/null +++ b/GitMonitorQueue.vala @@ -0,0 +1,162 @@ + + +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 + + NewBranch.show(this.repo); + + } + + 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; + } + + + +} + diff --git a/GitRepo.vala b/GitRepo.vala index b03f8346..4e018e54 100644 --- a/GitRepo.vala +++ b/GitRepo.vala @@ -7,9 +7,11 @@ * * */ +static GitRepo _GitRepo; + public class GitRepo : Object { - + public Array cmds; public string name; @@ -20,12 +22,22 @@ public class GitRepo : Object public Gee.HashMap ignore_files; public GitBranch currentBranch; + + public static GitRepo singleton() + { + if (_GitRepo == null) { + _GitRepo = new GitRepo(); + _GitRepo.cache = new Gee.HashMap(); + } + return _GitRepo; + } + /** * index of.. matching gitpath.. */ public static int indexOf( Array repos, string gitpath) { // make a fake object to compare against.. - var test_repo = new GitRepo(gitpath); + var test_repo = GitRepo.get(gitpath); for(var i =0; i < repos.length; i++) { if (repos.index(i).gitdir == test_repo.gitdir) { @@ -36,15 +48,18 @@ public class GitRepo : Object } + public Gee.HashMap cache; + + public static Array list() { - + //if (GitRepo.list_cache != null) { // unowned Array ret = GitRepo.list_cache; // return ret; //} - + var cache = GitRepo.singleton().cache; var list_cache = new Array(); var dir = Environment.get_home_dir() + "/gitlive"; @@ -102,8 +117,8 @@ public class GitRepo : Object continue; } - list_cache.append_val(new GitRepo( sp )) ; - + var rep = GitRepo.get( sp ); + list_cache.append_val(rep); } @@ -111,7 +126,17 @@ public class GitRepo : Object -} + } + + public static GitRepo get(string path) + { + var cache = GitRepo.singleton().cache; + if (cache.has_key(path)) { + return cache.get(path); + } + return new GitRepo(path); + } + @@ -123,7 +148,7 @@ public class GitRepo : Object * */ - public GitRepo(string path) { + private GitRepo(string path) { // cal parent? this.name = File.new_for_path(path).get_basename(); this.ignore_files = new Gee.HashMap(); @@ -134,8 +159,12 @@ public class GitRepo : Object this.gitdir = path; // naked... } this.cmds = new Array (); - //Repo.superclass.constructor.call(this,cfg); + var cache = GitRepo.singleton().cache; + //Repo.superclass.constructor.call(this,cfg); + if ( !cache.has_key(path) ) { + cache.set( path, this); + } } diff --git a/Makefile.am b/Makefile.am index 994a15c6..6cc2b4a0 100644 --- a/Makefile.am +++ b/Makefile.am @@ -21,16 +21,17 @@ Gitlive_SOURCES = \ Gitlive.vala \ Monitor.vala \ GitMonitor.vala \ + GitMonitorQueue.vala \ Spawn.vala \ StatusIcon.vala \ GitRepo.vala \ - GitBranch.vala \ - RooTicket.vala \ + GitBranch.vala \ + RooTicket.vala \ c/xorg_idletime.c \ - WindowLog.vala \ + WindowLog.vala \ Clones.vala \ - NewBranch.vala \ - GitMonitorQueue.vala + NewBranch.vala + diff --git a/RooTicket.vala b/RooTicket.vala index 3b8271f1..f845baaf 100644 --- a/RooTicket.vala +++ b/RooTicket.vala @@ -34,7 +34,7 @@ class RooTicket : Object { // first 5 words of summary.. var regex = new Regex ("[^A-Za-z0-9 ]+"); - var str = regex.replace(this.summary, this.summary.length, 0); + var str = regex.replace(this.summary, this.summary.length,0, ""); string[] words = Regex.split_simple ("[ \t]+", str); var ret = ""; for (var i =0; i< (words.length > 5 ? 5 : words.length); i++) { @@ -42,13 +42,12 @@ class RooTicket : Object ret += words[i]; } return ret; - } public string usernameLocal() { // git username is an email addres... - so this reutrns the local part.. //?? assumes that all members are under the same domain... normally the case...... - return RooTicket.singleton().username.split('@')[0]; + return RooTicket.singleton().username.split("@")[0]; } @@ -151,8 +150,7 @@ class RooTicket : Object } GLib.debug("found password?"); // we are gussing.... - username = bits[3]; - password = bits[5]; + RooTicket.singleton().username = bits[3]; RooTicket.singleton().password = bits[5]; }