From: Alan Knowles Date: Fri, 16 Nov 2018 04:31:10 +0000 (+0800) Subject: sync X-Git-Url: http://git.roojs.org/?p=gitlive;a=commitdiff_plain;h=9e641e366549656621a3e4fc4950b62c4b395650 sync --- diff --git a/Clones.bjs b/Clones.bjs index b7c91c24..30b9b23e 100644 --- a/Clones.bjs +++ b/Clones.bjs @@ -12,14 +12,14 @@ "delete_event" : "(self, event) => {\n this.el.hide();\n return true; \n //test \n}\n ", "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, + "boolean deletable" : true, + "default_width" : 1024, + "| void show" : "() {\n\n \n this.el.set_deletable(true);\n this.el.set_gravity(Gdk.Gravity.NORTH);\n this.el.move((Gdk.Screen.width() / 2 ) -400 ,0);\n \n this.el.set_default_size(\n\t\t\tint.min(1024,Gdk.Screen.width()),\n\t\t\tint.max(500,Gdk.Screen.width() - 300)\n\t);\n \n this.el.show_all();\n _this.reposStore.load();\n this.el.set_keep_above(true);\n this.el.run();\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, - "$ modal" : true, "$ xns" : "Gtk", + "boolean modal" : true, "border_width" : 3, "items" : [ { @@ -29,6 +29,7 @@ "Gtk.Orientation orientation" : "Gtk.Orientation.VERTICAL", "items" : [ { + "bool homogeneous" : true, "* pack" : "pack_start,false,false,0", "xtype" : "Box", "$ xns" : "Gtk", @@ -38,7 +39,7 @@ "listeners" : { "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", + "label" : "Add Repository", "* pack" : "add", "xtype" : "Button", "$ xns" : "Gtk" @@ -50,11 +51,12 @@ "label" : "Branches", "* pack" : "add", "xtype" : "Button", - "$ xns" : "Gtk" + "$ xns" : "Gtk", + "bool visible" : false }, { "listeners" : { - "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}" + "clicked" : "() => {\n\n\tvar rv = _this.reposView;\n\tvar rs = _this.reposStore;\n\tvar s =rv.el.get_selection();\n\tif (s.count_selected_rows() != 1) {\n\t\treturn;\n\t}\n\tGtk.TreeIter iter;\n\tGtk.TreeModel tm;\n\ts.get_selected(out tm, out iter);\n\tGLib.Value val;\n tm.get_value(iter, 6, out val);\n var git_working_dir = (string)val;\n \n var repo = GitRepo.singleton().get(git_working_dir);\n \n // if you hit merge.... in master..\n // ignore..\n if (repo.currentBranch.name == \"master\") {\n \treturn;\n\t}\n\tMergeBranch.singleton().show(repo.activeTicket, repo);\n\t_this.reposStore.load();\n\t\n \n \n}\n\n" }, "label" : "Merge", "* pack" : "add", @@ -68,7 +70,8 @@ "label" : "Switch Branch", "* pack" : "add", "xtype" : "Button", - "$ xns" : "Gtk" + "$ xns" : "Gtk", + "bool visible" : false }, { "listeners" : { @@ -92,13 +95,17 @@ "items" : [ { "listeners" : { + "row_activated" : "(path, col) => {\n\tGLib.debug(\"row activated: %s\", col.title);\n\tif (col.title != \"Current Branch\") {\n\t\treturn;\n\t}\n\t\n\t//\n\t\n\tGtk.TreeIter iter;\n\t_this.reposStore.el.get_iter(out iter, path);\n\tGLib.Value val;\n _this.reposStore.el.get_value(iter, 6, out val);\n var git_working_dir = (string)val;\n \n var repo = GitRepo.singleton().get(git_working_dir);\n \n Gdk.Rectangle rect;\n _this.reposView.el.get_cell_area(path, col, out rect);\n RepoStatusPopover.singleton().show(this.el, rect, repo);\n \n \n \n}", "cursor_changed" : "() => {\n // SEE SELECTION.CHANGED\n /*\n \n return;\n \n if (this.el.get_selection().count_selected_rows() < 1) {\n //nothing? - clea it?\n return;\n }\n var ret = {}; \n var model = this.get('/changedFilesStore');\n\n var s = this.el.get_selection();\n var files = [];\n s.selected_foreach(function(model,p,iter) {\n \n files.push( model.get_value(iter, 0).value.get_string());\n \n });\n this.get('/patchview').showDiff(files); \n //var value = ''+ ret.model.get_value(ret.iter, 1).value.get_string();\n //print(\"OUT?\" + value);// id..\n // load the list in the right grid..\n \n return true;\n*/\n}" }, "id" : "reposView", "* init" : " \n{\n var selection = this.el.get_selection();\n selection.set_mode( Gtk.SelectionMode.SINGLE);\n\n\n var description = new Pango.FontDescription();\n description.set_size(10000);\n this.el.override_font(description);\n \n}\n", + "bool activate_on_single_click" : true, "xtype" : "TreeView", "* pack" : "add", + "int search_column" : 0, "$ xns" : "Gtk", + "Gtk.TreeViewGridLines enable_grid_lines" : "Gtk.TreeViewGridLines.HORIZONTAL", "items" : [ { "int n_columns" : 10, @@ -107,7 +114,7 @@ "$ pathToRepo" : "function(path) {\n\n var tr= this.repos;\n\n \n for(var i =0 ; i < tr.length; i++) {\n if (tr[i].repopath == path) {\n return tr[i];\n }\n } \n return false; \n}\n", "xtype" : "ListStore", "* pack" : "set_model", - "| void load" : "()\n{\n //this.insert(citer,iter,0);\n print(\"getting list\");\n var tr = GitRepo.list();\n \n this.el.clear();\n \n // fixme .. sort by last updated ...\n \n \n for(var i =0 ; i < tr.length; i++) {\n\t var repo = tr.index(i);\n\t repo.loadBranches();\n\t \n\t Gtk.TreeIter iter;\n\t this.el.append(out iter);\n \n \n //print(JSON.stringify(ret,null,4));\n //tr[i].getBranches();\n //tr[i].getStatus();\n //var hi;\n //try {\n //tr[i].debug=1;\n // hi = tr[i].history('/', 1, 'branch', tr[i].currentBranch.name );\n// print(JSON.stringify(hi,null,4));\n // } catch(e) { print(e);}\n \n this.el.set_value(iter, 0, repo.name );\n this.el.set_value( iter, 1, repo.currentBranch.name );\n this.el.set_value( iter, 2, repo.branchesToString() );\n// this.el.set_value(ret.iter, 2, '' + repo.branches.map(\n// function(e) { return e.name; \n// }).join(', ') \n // );\n// this.el.set_value(iter, 3, '' + (!hi ? '??' : hi[0].changed_raw)); \n this.el.set_value(iter, 4, repo.is_autocommit() ); \n this.el.set_value(iter, 5, repo.is_autopush() ); \n this.el.set_value(iter, 6, repo.git_working_dir ); \n // highlight color.\n var cb = repo.currentBranch;\n //print(JSON.stringify(cb,null,4));\n var col = \"#ffffff\";\n /*\n if (cb.lastrev != cb.remoterev) {\n col = '#ff0000';\n }\n if (tr[i].hasLocalChanges) {\n col = '#0000ff';\n }\n if ((cb.lastrev != cb.remoterev) && (tr[i].hasLocalChanges)) {\n col = '#ff00ff';\n }\n */\n this.el.set_value(iter, 7, col ); \n var ticket = repo.activeTicket;\n \n this.el.set_value(iter, 8, repo.is_auto_branch() ); \n this.el.set_value(iter, 9, ticket == null ? \"\" : ticket.id ); \n \n \n } \n this.el.set_sort_column_id (0, Gtk.SortType.ASCENDING);\n} ", + "| void load" : "()\n{\n //this.insert(citer,iter,0);\n print(\"getting list\");\n var tr = GitRepo.list();\n \n this.el.clear();\n \n // fixme .. sort by last updated ...\n \n \n for(var i =0 ; i < tr.length; i++) {\n\t var repo = tr.index(i);\n\t // this is done before we display stuff...\n\t //repo.loadBranches();\n\t //repo.loadStatus();\n\t \n\t Gtk.TreeIter iter;\n\t this.el.append(out iter);\n \n //print(JSON.stringify(ret,null,4));\n //tr[i].getBranches();\n //tr[i].getStatus();\n //var hi;\n //try {\n //tr[i].debug=1;\n // hi = tr[i].history('/', 1, 'branch', tr[i].currentBranch.name );\n// print(JSON.stringify(hi,null,4));\n // } catch(e) { print(e);}\n \n this.el.set_value(iter, 0, repo.name );\n this.el.set_value( iter, 1, repo.currentBranch.name );\n this.el.set_value( iter, 2, repo.branchesToString() );\n// this.el.set_value(ret.iter, 2, '' + repo.branches.map(\n// function(e) { return e.name; \n// }).join(', ') \n // );\n// this.el.set_value(iter, 3, '' + (!hi ? '??' : hi[0].changed_raw)); \n this.el.set_value(iter, 4, repo.is_autocommit() ); \n this.el.set_value(iter, 5, repo.is_autopush() ); \n this.el.set_value(iter, 6, repo.git_working_dir ); \n // highlight color.\n var cb = repo.currentBranch;\n //print(JSON.stringify(cb,null,4));\n var col = \"#ffffff\";\n \n if (cb.lastrev != cb.remoterev) {\n col = \"#f2dede\";\n this.el.set_value( iter, 1, repo.currentBranch.name +\"\\nRemote != Local\" );\n }\n if (repo.has_local_changes) {\n col = \"#d9edf7\";\n this.el.set_value( iter, 1, repo.currentBranch.name +\"\\nHas uncommitted changes\" );\n }\n if ((cb.lastrev != cb.remoterev) && (repo.has_local_changes)) {\n col = \"#fcf8e3\";\n this.el.set_value( iter, 1, repo.currentBranch.name +\"\\nRemote != Local\\nHas uncommitted changes\" ); \n }\n \n this.el.set_value(iter, 7, col ); \n var ticket = repo.activeTicket;\n \n this.el.set_value(iter, 8, repo.is_auto_branch() ); \n this.el.set_value(iter, 9, ticket == null ? \"\" : ticket.id ); \n \n \n } \n this.el.set_sort_column_id (0, Gtk.SortType.ASCENDING);\n} ", "$ xns" : "Gtk" }, { @@ -267,14 +274,6 @@ ] } ] - }, - { - "label" : "Close", - "id" : "ok_button", - "bool expand" : false, - "* pack" : "add_action_widget,1 ", - "xtype" : "Button", - "$ xns" : "Gtk" } ] } diff --git a/Clones.vala b/Clones.vala index d5e29183..3a187ecb 100644 --- a/Clones.vala +++ b/Clones.vala @@ -30,7 +30,6 @@ public class Clones : Object public Xcls_cr_last_updated cr_last_updated; public Xcls_tv_all_branches tv_all_branches; public Xcls_cr_all_branches cr_all_branches; - public Xcls_ok_button ok_button; // my vars (def) @@ -46,15 +45,12 @@ public class Clones : Object this.el.title = "Manage Clones"; this.el.border_width = 3; this.el.default_height = 500; - this.el.default_width = 800; + this.el.default_width = 1024; this.el.deletable = true; this.el.modal = true; var child_0 = new Xcls_Box2( _this ); child_0.ref(); this.el.get_content_area().add ( child_0.el ); - var child_1 = new Xcls_ok_button( _this ); - child_1.ref(); - this.el.add_action_widget ( child_1.el , 1 ); //listeners this.el.delete_event.connect( (self, event) => { @@ -73,11 +69,19 @@ public class Clones : Object public void show () { - this.el.set_deletable(false); + this.el.set_deletable(true); this.el.set_gravity(Gdk.Gravity.NORTH); this.el.move((Gdk.Screen.width() / 2 ) -400 ,0); + + this.el.set_default_size( + int.min(1024,Gdk.Screen.width()), + int.max(500,Gdk.Screen.width() - 300) + ); + this.el.show_all(); _this.reposStore.load(); + this.el.set_keep_above(true); + this.el.run(); // load clones.. // this.get('/reposStore').load(); @@ -138,6 +142,7 @@ public class Clones : Object // my vars (dec) // set gobject values + this.el.homogeneous = true; var child_0 = new Xcls_Button4( _this ); child_0.ref(); this.el.add ( child_0.el ); @@ -174,7 +179,7 @@ public class Clones : Object // my vars (dec) // set gobject values - this.el.label = "Remotes / Clones"; + this.el.label = "Add Repository"; //listeners this.el.clicked.connect( () => { @@ -243,6 +248,7 @@ public class Clones : Object // set gobject values this.el.label = "Branches"; + this.el.visible = false; //listeners this.el.clicked.connect( () => { @@ -319,48 +325,31 @@ public class Clones : Object //listeners this.el.clicked.connect( () => { - /* - var rv = this.get('/reposView'); - var rs = this.get('/reposStore'); - if (rv.el.get_selection().count_selected_rows() != 1) { - //nothing? - // error condition. - return; - } - var Merger = imports.Merger.Merger; - - - var ret = {}; - var s = rv.el.get_selection(); - var path = ''; - s.selected_foreach(function(model,p,iter) { - - path = model.get_value(iter, 6).value.get_string(); - - }); - - var repo = false; - rs.repos.forEach(function(r) { - if (r.repopath == path) { - repo = r; - - } - - }); - Merger.repo = repo; - Merger.el.set_transient_for(Clones.el); - Clones.el.set_title("Manage Clones - " + repo.repopath); - Merger.show(); - Clones.el.set_title("Manage Clones"); - - - - + var rv = _this.reposView; + var rs = _this.reposStore; + var s =rv.el.get_selection(); + if (s.count_selected_rows() != 1) { + return; + } + Gtk.TreeIter iter; + Gtk.TreeModel tm; + s.get_selected(out tm, out iter); + GLib.Value val; + tm.get_value(iter, 6, out val); + var git_working_dir = (string)val; - - */ + var repo = GitRepo.singleton().get(git_working_dir); + // if you hit merge.... in master.. + // ignore.. + if (repo.currentBranch.name == "master") { + return; + } + MergeBranch.singleton().show(repo.activeTicket, repo); + _this.reposStore.load(); + + }); } @@ -386,6 +375,7 @@ public class Clones : Object // set gobject values this.el.label = "Switch Branch"; + this.el.visible = false; //listeners this.el.clicked.connect( () => { @@ -487,6 +477,9 @@ public class Clones : Object // my vars (dec) // set gobject values + this.el.search_column = 0; + this.el.activate_on_single_click = true; + this.el.enable_grid_lines = Gtk.TreeViewGridLines.HORIZONTAL; var child_0 = new Xcls_reposStore( _this ); child_0.ref(); this.el.set_model ( child_0.el ); @@ -529,6 +522,29 @@ public class Clones : Object } //listeners + this.el.row_activated.connect( (path, col) => { + GLib.debug("row activated: %s", col.title); + if (col.title != "Current Branch") { + return; + } + + // + + Gtk.TreeIter iter; + _this.reposStore.el.get_iter(out iter, path); + GLib.Value val; + _this.reposStore.el.get_value(iter, 6, out val); + var git_working_dir = (string)val; + + var repo = GitRepo.singleton().get(git_working_dir); + + Gdk.Rectangle rect; + _this.reposView.el.get_cell_area(path, col, out rect); + RepoStatusPopover.singleton().show(this.el, rect, repo); + + + + }); this.el.cursor_changed.connect( () => { // SEE SELECTION.CHANGED /* @@ -605,12 +621,13 @@ public class Clones : Object for(var i =0 ; i < tr.length; i++) { var repo = tr.index(i); - repo.loadBranches(); + // this is done before we display stuff... + //repo.loadBranches(); + //repo.loadStatus(); Gtk.TreeIter iter; this.el.append(out iter); - //print(JSON.stringify(ret,null,4)); //tr[i].getBranches(); //tr[i].getStatus(); @@ -636,17 +653,20 @@ public class Clones : Object var cb = repo.currentBranch; //print(JSON.stringify(cb,null,4)); var col = "#ffffff"; - /* + if (cb.lastrev != cb.remoterev) { - col = '#ff0000'; + col = "#f2dede"; + this.el.set_value( iter, 1, repo.currentBranch.name +"\nRemote != Local" ); } - if (tr[i].hasLocalChanges) { - col = '#0000ff'; + if (repo.has_local_changes) { + col = "#d9edf7"; + this.el.set_value( iter, 1, repo.currentBranch.name +"\nHas uncommitted changes" ); } - if ((cb.lastrev != cb.remoterev) && (tr[i].hasLocalChanges)) { - col = '#ff00ff'; + if ((cb.lastrev != cb.remoterev) && (repo.has_local_changes)) { + col = "#fcf8e3"; + this.el.set_value( iter, 1, repo.currentBranch.name +"\nRemote != Local\nHas uncommitted changes" ); } - */ + this.el.set_value(iter, 7, col ); var ticket = repo.activeTicket; @@ -1181,29 +1201,4 @@ public class Clones : Object - public class Xcls_ok_button : Object - { - public Gtk.Button el; - private Clones _this; - - - // my vars (def) - - // ctor - public Xcls_ok_button(Clones _owner ) - { - _this = _owner; - _this.ok_button = this; - this.el = new Gtk.Button(); - - // my vars (dec) - - // set gobject values - this.el.expand = false; - this.el.label = "Close"; - } - - // user defined functions - } - } diff --git a/GitBranch.vala b/GitBranch.vala index 0a0a63c7..a30808be 100644 --- a/GitBranch.vala +++ b/GitBranch.vala @@ -32,14 +32,111 @@ public class GitBranch : Object public bool active = false; public string lastrev = ""; public string name = ""; + public bool is_remote; public string remote = ""; public string remoterev = ""; + public string toString() + { + return + "active: " + (active ? "true" : "false") + "\n" + + "is_remote: " + (is_remote ? "true" : "false") + "\n" + + "lastrev: " + lastrev + "\n" + + "name: " + name + "\n" + + "remote: " + remote + "\n" + + "remoterev: " + remoterev + "\n"; + } + + public GitBranch(GitRepo repo) { this.repo = repo; } + public static void loadBranches(GitRepo repo) + { + repo.branches = new Gee.HashMap(); + + var branches = new Gee.HashMap(); + var local = new Gee.HashMap(); + var remotes = new Gee.HashMap(); + + // repo.git( { "fetch", "-a" } ); == done async before... + + string[] cmd = { "branch", "--no-color", "--verbose", "--no-abbrev" , "-a" }; + var res = repo.git( cmd ); + var lines = res.split("\n"); + for (var i = 0; i < lines.length ; i++) { + var br = new GitBranch(repo); + if (!br.parseBranchListItem(lines[i])) { + continue; + } + GLib.debug("add branch %s", br.realName()); + if (!br.is_remote) { + local.set(br.name, br); + } else { + remotes.set(br.remote, br); + } + + branches.set(br.realName(), br); + if (br.active) { + repo.currentBranch = br; + } + } + + var bl = repo.git({ + "for-each-ref", + "--format", "%(refname:short):remotes/%(upstream:short)", + "refs/heads" + }).split("\n"); + + foreach(var line in bl) { + if (line.length < 1) continue; + + var ar = line.split(":remotes/"); + var lname= ar[0]; + var rname = "remotes/" + ar[1]; + + //print(rname); + // we should always have a local version of it. + if (branches.has_key(lname)) { + branches.get(lname).remote = rname; + } + + if (!branches.has_key(rname)) { + continue; + } + branches.get(lname).remoterev = branches.get(rname).lastrev; + // flag it for not adding.. + + branches.get(rname).name = lname; + } + foreach(var br in local.values) { + GLib.debug("BRANCH:\n%s\n" , br.toString()); + } + + /* + this bit of the code tries to turn a local branch into a track of a remote one. + -- that's probably not a good idea. + var r_replace = new Regex("^remotes/"); + var o_replace = new Regex("^origin/"); + foreach(var r in remotes.values) { + if (r.name.length >0) { + return; + } + var name = r_replace.replace(r.name, r.name.length,0, ""); + name = o_replace.replace(name, name.length,0, ""); + name = name.replace("/", "."); + + } + */ + repo.branches = local; + + + + } + + public bool parseBranchListItem(string str) { if (str.length < 1) { @@ -51,9 +148,10 @@ public class GitBranch : Object if (parts[1] == "->") { // it's an alias.. eg. remotes/origin/HEAD -> origin/master.. return false; } - + this.is_remote = false; this.lastrev = parts[1]; if (parts[0].has_prefix("remotes/")) { + this.is_remote = true; this.remote = parts[0]; } else { this.name = parts[0]; @@ -62,7 +160,7 @@ public class GitBranch : Object } public string realName() { - return this.name == "" ? this.remote : this.name; + return this.is_remote ? this.remote : this.name; } public void create() diff --git a/GitMonitor.vala b/GitMonitor.vala index 798971c4..7e42154a 100644 --- a/GitMonitor.vala +++ b/GitMonitor.vala @@ -54,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(); diff --git a/GitRepo.vala b/GitRepo.vala index cf962d63..a0725927 100644 --- a/GitRepo.vala +++ b/GitRepo.vala @@ -18,12 +18,18 @@ public class GitRepo : Object public string gitdir; public string git_working_dir; public bool debug = false; + public bool has_local_changes = false; + public string git_status; + public string git_diff; public Gee.HashMap ignore_files; public GitBranch currentBranch; - + public Gee.HashMap branches; // accessed in GitBranch.. public RooTicket? activeTicket; - + public Gee.HashMap cache; + + + public static GitRepo singleton() { if (_GitRepo == null) { @@ -49,7 +55,7 @@ public class GitRepo : Object } - public Gee.HashMap cache; + @@ -168,6 +174,7 @@ public class GitRepo : Object } this.loadBranches(); this.loadActiveTicket(); + this.loadStatus(); } public bool is_wip_branch() @@ -241,29 +248,18 @@ public class GitRepo : Object } - - Gee.HashMap branches; + public void loadStatus() + { + var r = this.git({ "status" , "--porcelain" }); + this.git_status = r; + this.has_local_changes = r.length > 0; + this.git_diff = this.git({ "diff" , "HEAD", "--no-color" }); + } + public void loadBranches() { - this.branches = new Gee.HashMap(); - - string[] cmd = { "branch", "--no-color", "--verbose", "--no-abbrev" , "-a" }; - var res = this.git( cmd ); - var lines = res.split("\n"); - for (var i = 0; i < lines.length ; i++) { - var br = new GitBranch(this); - if (!br.parseBranchListItem(lines[i])) { - continue; - } - GLib.debug("add branch %s", br.realName()); - - branches.set(br.realName(), br); - if (br.active) { - this.currentBranch = br; - } - } - + GitBranch.loadBranches(this); } @@ -276,7 +272,7 @@ public class GitRepo : Object if (br.name == "") { continue; } - ret += ret.length > 0 ? "," : ""; + ret += ret.length > 0 ? "\n" : ""; ret += br.name; } @@ -426,66 +422,12 @@ public class GitRepo : Object public bool createBranchNamed(string branchname) { - var stash = false; + if (this.branches.has_key(branchname)) { - // this is where it get's tricky... - try { - string[] cmd = { "ls-files" , "-m" }; // list the modified files.. - var ret = this.git(cmd); - stash = ret.length> 1 ; - - - cmd = { "stash" }; - if (stash) { this.git(cmd); } - - cmd = { "checkout", branchname }; - this.git(cmd); - } catch(Error e) { - GitMonitor.gitmonitor.pauseError(e.message); - return false; - } - try { - if (branchname != "master") { - string[] cmd = { "merge", "master" }; - this.git(cmd); - this.push(); - //cmd = { "commit", "-a" , "-m", "merge master changes" }; - //git chethis.git( cmd ); - } - - } catch(Error e) { - string[] cmd = { "checkout", "master" }; - this.git(cmd); - GitMonitor.gitmonitor.pauseError( - "Use\n\na) git checkout %s\nb) git mergetool\nc) git commit\nd) git push\n d) stash pop \ne) start gitlive again\n".printf( - branchname) - + e.message - ); - return false; - - } - try { - string[] cmd = { "stash", "pop" }; - if (stash) { this.git(cmd); } - } catch(Error ee) { - GitMonitor.gitmonitor.pauseError(ee.message); - return false; - } - this.push(); + this.switchToExistingBranchNamed(branchname); } else { - try { - - string[] cmd = { "checkout", "-b" , branchname }; - this.git(cmd); - - cmd = { "push", "-u" , "origin" ,"HEAD" }; - this.git(cmd); - - } catch(Error ee) { - GitMonitor.gitmonitor.pauseError(ee.message); - return false; - } + this.createNewBranchNamed(branchname); } var notification = new Notify.Notification( @@ -503,6 +445,107 @@ public class GitRepo : Object //GitMonitor.gitmonitor.runQueue(); // no point - we have hidden the queue.. return true; } + bool switchToExistingBranchNamed(string branchname) + { + var stash = false; + // this is where it get's tricky... + string files = ""; + try { + string[] cmd = { "ls-files" , "-m" }; // list the modified files.. + files = this.git(cmd); + stash = files.length> 1 ; + + + cmd = { "stash" }; + if (stash) { this.git(cmd); } + + this.pull(); + + cmd = { "checkout", branchname }; + this.git(cmd); + } catch(Error e) { + GitMonitor.gitmonitor.pauseError(e.message); + return false; + } + try { + if (branchname != "master") { + string[] cmd = { "merge", "master" }; + this.git(cmd); + this.push(); + + } + + } catch(Error e) { + string[] cmd = { "checkout", "master" }; + this.git(cmd); + GitMonitor.gitmonitor.pauseError( + "Use\n\na) git checkout %s\nb) git mergetool\nc) git commit\nd) git push\n d) stash pop \ne) start gitlive again\n".printf( + branchname) + + e.message + ); + return false; + + } + try { + string[] cmd = { "stash", "pop" }; + if (stash) { + this.git(cmd); + var fl = files.split("\n"); + cmd = { "commit", "-m" , "Changed " + string.joinv("",fl) }; + foreach(var f in fl) { + if (f.length < 1) continue; + cmd += f; + } + this.git(cmd); + } + + + + } catch(Error ee) { + GitMonitor.gitmonitor.pauseError(ee.message); + return false; + } + this.push(); + return true; + + } + + + + bool createNewBranchNamed(string branchname) + { + var stash = false; + try { + string[] cmd = { "ls-files" , "-m" }; // list the modified files.. + var files = this.git(cmd); + stash = files.length> 1 ; + + cmd = { "checkout", "-b" , branchname }; + this.git(cmd); + + cmd = { "push", "-u" , "origin" ,"HEAD" }; + this.git(cmd); + if (stash) { + + var fl = files.split("\n"); + cmd = { "commit", "-m" , "Changed " + string.joinv("",fl) }; + foreach(var f in fl) { + if (f.length < 1) continue; + cmd += f; + } + this.git(cmd); + this.push(); + } + + + } catch(Error ee) { + GitMonitor.gitmonitor.pauseError(ee.message); + return false; + } + return true; + + } + /** @@ -647,7 +690,7 @@ public class GitRepo : Object public void pull_async(GitAsyncCallback cb) { - string[] cmd = { "pull" , "--no-edit" }; + string[] cmd = { "pull" , "--no-edit" }; this.git_async( cmd , cb); @@ -711,7 +754,7 @@ public class GitRepo : Object var cfg = new SpawnConfig(this.git_working_dir , args , env); - + //cfg.debug = true; // may throw error... var sp = new Spawn(cfg); @@ -778,4 +821,52 @@ public class GitRepo : Object } + + + + + public void update_async(GitAsyncCallback cb) + { + string[] cmd = { "fetch" , "--all" }; + this.git_async( cmd , cb); + + } + + + static uint update_all_total = 0; + static string update_all_after = ""; + + public static void updateAll(string after) + { + update_all_after = after; + var tr = GitRepo.singleton().cache; + + + update_all_total = tr.size; + foreach(var repo in tr.values) { + repo.update_async(updateAllCallback); + } + + } + public static void updateAllCallback(GitRepo repo, int err, string res) + { + repo.loadBranches(); + repo.loadStatus(); + + update_all_total--; + if (update_all_total > 0 ) { + return; + } + switch (update_all_after) { + case "show_clones": + Clones.singleton().show(); + break; + default: + break; + } + return; + } + + + } diff --git a/Makefile.am b/Makefile.am index 0137963f..70af8b46 100644 --- a/Makefile.am +++ b/Makefile.am @@ -14,8 +14,9 @@ Gitlive_PKGS = \ --pkg libwnck-3.0 \ --pkg gee-0.8 \ --pkg libcanberra \ - --pkg libsoup-2.4 \ - --pkg json-glib-1.0 + --pkg libsoup-2.4 \ + --pkg json-glib-1.0 \ + --pkg gtksourceview-3.0 Gitlive_SOURCES = \ Gitlive.vala \ @@ -31,7 +32,8 @@ Gitlive_SOURCES = \ WindowLog.vala \ Clones.vala \ NewBranch.vala \ - MergeBranch.vala + MergeBranch.vala \ + RepoStatusPopover.vala diff --git a/MergeBranch.bjs b/MergeBranch.bjs index 37ea9e4c..4e589ef6 100644 --- a/MergeBranch.bjs +++ b/MergeBranch.bjs @@ -10,14 +10,15 @@ { "listeners" : { "delete_event" : "(self, event) => {\n this.el.hide();\n return true; \n //test \n}\n ", - "response" : " (self, response_id) => { \n \n\tGLib.debug(\"got %d\", (int) response_id);\n\tif (response_id == 0) {\n\t _this.el.hide();\t\n\t this.running = false; \n \tGitMonitor.gitmonitor.start();\n\t \treturn;\n\t}\n\t /*\n\t// have they selected a ticket..\n\t// make that the current active ticket?\n\t// we really need to store locally what ticket is being worked on..\n\t// in theory we could be working on multiple project and not merging..\n\t// -- each repo would have their active ticket (only one per repo)\n\t// -- so we could just store that in there\n\t// -- initial load can check the contents of the ticket files on first scan.\n\tvar ticket_id = _this.ticketsel.selectedTicketId();\n\t\n if (this.repo != null) {\n \tvar bn = _this.name.el.get_text();\n \tif (ticket_id != \"\" ) {\n\t\t\tthis.repo.setActiveTicket( RooTicket.singleton().getById(ticket_id), bn);\n\t\t} else {\n\t\t\tthis.repo.createBranchNamed(bn);\n\t\t}\n }\n\t*/\n\t\n\tGitRepo.doMerges(\n\t\t_this.actionsel.selectedAction(), \n\t\t_this.ticketsel.selectedTicketId(),\n\t\t_this.name.el.get_text()\n\t);\n\t\n\tthis.running = false; \n\n\t \n\t_this.el.hide();\t\n \tGitMonitor.gitmonitor.start();\n\n\t \n}", + "response" : " (self, response_id) => { \n \n\tGLib.debug(\"got %d\", (int) response_id);\n\tif (response_id == 0) {\n\t _this.el.hide();\t\n\t this.running = false; \n \tGitMonitor.gitmonitor.start();\n\t \treturn;\n\t}\n\t /*\n\t// have they selected a ticket..\n\t// make that the current active ticket?\n\t// we really need to store locally what ticket is being worked on..\n\t// in theory we could be working on multiple project and not merging..\n\t// -- each repo would have their active ticket (only one per repo)\n\t// -- so we could just store that in there\n\t// -- initial load can check the contents of the ticket files on first scan.\n\tvar ticket_id = _this.ticketsel.selectedTicketId();\n\t\n if (this.repo != null) {\n \tvar bn = _this.name.el.get_text();\n \tif (ticket_id != \"\" ) {\n\t\t\tthis.repo.setActiveTicket( RooTicket.singleton().getById(ticket_id), bn);\n\t\t} else {\n\t\t\tthis.repo.createBranchNamed(bn);\n\t\t}\n }\n\t*/\n\t\n\tif (this.repo != null) {\n\t\trepo.doMerge(\n\t\t\t_this.actionsel.selectedAction(), \n\t\t\t_this.ticketsel.selectedTicketId(),\n\t\t\t_this.name.el.get_text()\n\t\t);\n\t\n\t} else {\n\t\tGitRepo.doMerges(\n\t\t\t_this.actionsel.selectedAction(), \n\t\t\t_this.ticketsel.selectedTicketId(),\n\t\t\t_this.name.el.get_text()\n\t\t);\n\t}\n\tthis.running = false; \n\n\t \n\t_this.el.hide();\t\n \tGitMonitor.gitmonitor.start();\n\n\t \n}", "show" : "(self) => {\n \n\n //test\n}" }, "default_width" : 500, "$ deletable" : true, + "# GitRepo repo" : "", "title" : "Merge Branch", "xtype" : "Dialog", - "| void show" : "( RooTicket ticket ) \n{\n // this.el.set_gravity(Gdk.Gravity.NORTH);\n if (this.running) {\n \treturn;\n\t}\n\tGitMonitor.gitmonitor.stop();\n\t\n this.ticket = ticket;\n \n\tthis.el.move((Gdk.Screen.width() / 2)- 250 ,0);\n \tGLib.debug(\"Loading tickets\"); \n\n\n this.el.show_all();\n \t_this.dbmodel.loadTickets();\n \t_this.actionmodel.loadActions();\n\n\n}", + "| void show" : "( RooTicket ticket, GitRepo? repo ) \n{\n // this.el.set_gravity(Gdk.Gravity.NORTH);\n if (this.running) {\n \treturn;\n\t}\n\tGitMonitor.gitmonitor.stop();\n\t\n this.ticket = ticket;\n this.repo = repo;\n \n\tthis.el.move((Gdk.Screen.width() / 2)- 250 ,0);\n \tGLib.debug(\"Loading tickets\"); \n\n\n this.el.show_all();\n \t_this.dbmodel.loadTickets();\n \t_this.actionmodel.loadActions();\n\n\n}", "default_height" : 200, "# RooTicket? ticket" : "null", "$ xns" : "Gtk", @@ -31,8 +32,8 @@ "items" : [ { "bool homogeneous" : false, - "* pack" : "pack_start,false,false,0", "xtype" : "Table", + "* pack" : "pack_start,false,false,0", "uint column_spacing" : 2, "n_columns" : 2, "$ xns" : "Gtk", @@ -63,14 +64,14 @@ "items" : [ { "id" : "actioncellrenderer", - "* pack" : "pack_start,true", "xtype" : "CellRendererText", + "* pack" : "pack_start,true", "$ xns" : "Gtk" }, { "id" : "actionmodel", - "* pack" : "set_model", "xtype" : "ListStore", + "* pack" : "set_model", "$ columns" : "typeof(string),typeof(string)", "n_columns" : 2, "$ xns" : "Gtk", @@ -102,14 +103,14 @@ "items" : [ { "id" : "dbcellrenderer", - "xtype" : "CellRendererText", "* pack" : "pack_start,true", + "xtype" : "CellRendererText", "$ xns" : "Gtk" }, { "id" : "dbmodel", - "xtype" : "ListStore", "* pack" : "set_model", + "xtype" : "ListStore", "| void loadTickets" : " () {\n\n RooTicket.singleton().loadTickets();\n \n _this.ticketsel.loading = true;\n\n this.el.clear(); \n Gtk.TreeIter iter;\n var el = this.el;\n \n el.append(out iter);\n el.set_value(iter, 0, \"\");\n el.set_value(iter, 1, \"-- select a ticket --\");\n \n _this.ticketsel.el.set_active_iter(iter);\n \n if (_this.ticket != null && _this.ticket.id == \"-1\") {\n\t\tel.append(out iter);\n\t\tel.set_value(iter, 0, \"-1\");\n\t\tel.set_value(iter, 1, \"Temporary Branch - No ticket specified/relivant\");\n _this.ticketsel.el.set_active_iter(iter);\t\n }\n \n \n \n \n var tickets = RooTicket.singleton().tickets;\n foreach(var ticket in tickets) {\n \n el.append(out iter);\n\n el.set_value(iter, 0, ticket.id);\n el.set_value(iter, 1, \"#%s [%s] %s\".printf( ticket.id, ticket.project_id_name , ticket.summary));\n\t\tif (_this.ticket != null && _this.ticket.id == ticket.id) {\n\t\t _this.ticketsel.el.set_active_iter(iter);\n\t }\n \n }\n \n _this.ticketsel.loading = false;\n //this.el.set_sort_column_id(0, Gtk.SortType.ASCENDING); \n \n}\n", "$ columns" : "typeof(string),typeof(string)", "n_columns" : 2, @@ -140,15 +141,15 @@ }, { "label" : "Cancel", - "xtype" : "Button", "* pack" : "add_action_widget,0", + "xtype" : "Button", "Gtk.ReliefStyle relief" : "Gtk.ReliefStyle.NONE", "$ xns" : "Gtk" }, { "label" : "Do Merge", - "xtype" : "Button", "* pack" : "add_action_widget,1", + "xtype" : "Button", "$ xns" : "Gtk" } ] diff --git a/MergeBranch.vala b/MergeBranch.vala index a0aa781b..77fb77fe 100644 --- a/MergeBranch.vala +++ b/MergeBranch.vala @@ -21,6 +21,7 @@ public class MergeBranch : Object public Xcls_name name; // my vars (def) + public GitRepo repo; public RooTicket? ticket; public bool running; @@ -85,12 +86,20 @@ public class MergeBranch : Object } */ - GitRepo.doMerges( - _this.actionsel.selectedAction(), - _this.ticketsel.selectedTicketId(), - _this.name.el.get_text() - ); + if (this.repo != null) { + repo.doMerge( + _this.actionsel.selectedAction(), + _this.ticketsel.selectedTicketId(), + _this.name.el.get_text() + ); + } else { + GitRepo.doMerges( + _this.actionsel.selectedAction(), + _this.ticketsel.selectedTicketId(), + _this.name.el.get_text() + ); + } this.running = false; @@ -107,7 +116,7 @@ public class MergeBranch : Object } // user defined functions - public void show ( RooTicket ticket ) + public void show ( RooTicket ticket, GitRepo? repo ) { // this.el.set_gravity(Gdk.Gravity.NORTH); if (this.running) { @@ -116,6 +125,7 @@ public class MergeBranch : Object GitMonitor.gitmonitor.stop(); this.ticket = ticket; + this.repo = repo; this.el.move((Gdk.Screen.width() / 2)- 250 ,0); GLib.debug("Loading tickets"); diff --git a/NewBranch.bjs b/NewBranch.bjs index a9c59a8c..85263cab 100644 --- a/NewBranch.bjs +++ b/NewBranch.bjs @@ -10,7 +10,7 @@ { "listeners" : { "delete_event" : "(self, event) => {\n this.el.hide();\n return true; \n //test \n}\n ", - "response" : " (self, response_id) => { \n \n\tGLib.debug(\"got %d\", (int) response_id);\n\tif (response_id == 0) {\n\t _this.el.hide();\t\n\t this.running = false; \n\t \treturn;\n\t}\n\t \n\t// have they selected a ticket..\n\t// make that the current active ticket?\n\t// we really need to store locally what ticket is being worked on..\n\t// in theory we could be working on multiple project and not merging..\n\t// -- each repo would have their active ticket (only one per repo)\n\t// -- so we could just store that in there\n\t// -- initial load can check the contents of the ticket files on first scan.\n\tvar ticket_id = _this.ticketsel.selectedTicketId();\n\t\n if (this.repo != null) {\n \tvar bn = _this.name.el.get_text();\n \tif (ticket_id != \"\" ) {\n\t\t\tthis.repo.setActiveTicket( RooTicket.singleton().getById(ticket_id), bn);\n\t\t} else {\n\t\t\tthis.repo.setActiveTicket( RooTicket.singleton().getById(\"-1\"), bn);\n\t\t}\n }\n\n this.running = false; \n\n\tthis.el.hide();\n\t \n\t \n\n\t \n}", + "response" : " (self, response_id) => { \n \n\tGLib.debug(\"got %d\", (int) response_id);\n\tif (response_id == 0) {\n\t _this.el.hide();\t\n\t this.running = false; \n\t \treturn;\n\t}\n\t \n\t// have they selected a ticket..\n\t// make that the current active ticket?\n\t// we really need to store locally what ticket is being worked on..\n\t// in theory we could be working on multiple project and not merging..\n\t// -- each repo would have their active ticket (only one per repo)\n\t// -- so we could just store that in there\n\t// -- initial load can check the contents of the ticket files on first scan.\n\tvar ticket_id = _this.ticketsel.selectedTicketId();\n\t\n if (this.repo != null) {\n \tvar bn = _this.name.el.get_text();\n\n\t\tvar res = this.repo.setActiveTicket(\t\t\t\n\t\t\t RooTicket.singleton().getById(ticket_id != \"\" ? ticket_id : \"-1\"), bn\n\t\t );\n\t\t if (res) {\n\t\t \t// start the monitoring..\n\t\t \t GitMonitor.gitmonitor.start();\n\t\t \t \n\t\t }\n }\n \n\n this.running = false; \n\n\tthis.el.hide();\n\t \n\t \n\n\t \n}", "show" : "(self) => {\n \n\n //test\n}" }, "default_width" : 500, @@ -18,7 +18,7 @@ "title" : "Create a working branch ", "xtype" : "Dialog", "# GitRepo? repo" : "null", - "| void show" : "( GitRepo repo, Gee.ArrayList queue ) \n{\n // this.el.set_gravity(Gdk.Gravity.NORTH);\n if (this.running) { // should not happen!!\n \tGLib.error(\"new branch show called, when already being displayed?\");\n\t}\n\tthis.queue = queue;\n\t\n\tthis.running = true;\n\tGitMonitor.gitmonitor.stop();\n\t\n this.repo = repo;\n \n\tthis.el.move((Gdk.Screen.width() / 2)- 250 ,0);\n \tGLib.debug(\"Loading tickets\"); \n\n\n this.el.show_all();\n \t_this.dbmodel.loadTickets();\n\n}", + "| void show" : "( GitRepo repo, Gee.ArrayList queue ) \n{\n // this.el.set_gravity(Gdk.Gravity.NORTH);\n if (this.running) { // should not happen!!\n \tGLib.error(\"new branch show called, when already being displayed?\");\n\t}\n\tthis.queue = queue;\n\t\n\tthis.running = true;\n\tGitMonitor.gitmonitor.stop();\n\t\n this.repo = repo;\n \n\tthis.el.move((Gdk.Screen.width() / 2)- 250 ,0);\n \tGLib.debug(\"Loading tickets\"); \n\n\n this.el.show_all();\n this.el.set_keep_above(true);\n \t_this.dbmodel.loadTickets();\n \tthis.el.run();\n\n}", "default_height" : 200, "$ xns" : "Gtk", "# bool running" : false, @@ -32,8 +32,8 @@ "items" : [ { "bool homogeneous" : false, - "xtype" : "Table", "* pack" : "pack_start,false,false,0", + "xtype" : "Table", "uint column_spacing" : 2, "n_columns" : 2, "$ xns" : "Gtk", @@ -64,14 +64,14 @@ "items" : [ { "id" : "dbcellrenderer", - "* pack" : "pack_start,true", "xtype" : "CellRendererText", + "* pack" : "pack_start,true", "$ xns" : "Gtk" }, { "id" : "dbmodel", - "* pack" : "set_model", "xtype" : "ListStore", + "* pack" : "set_model", "| void loadTickets" : " () {\n\n RooTicket.singleton().loadTickets();\n \n _this.ticketsel.loading = true;\n\n this.el.clear(); \n Gtk.TreeIter iter;\n var el = this.el;\n \n el.append(out iter);\n\n \n el.set_value(iter, 0, \"\");\n el.set_value(iter, 1, \"-- select a ticket --\");\n \n _this.ticketsel.el.set_active_iter(iter);\n var tickets = RooTicket.singleton().tickets;\n foreach(var ticket in tickets) {\n \n el.append(out iter);\n \n el.set_value(iter, 0, ticket.id);\n el.set_value(iter, 1, \"#%s [%s] %s\".printf( ticket.id, ticket.project_id_name , ticket.summary));\n \n //if (data.get(i) == cur) {\n // _this.build_module.el.set_active_iter(iter);\n // }\n \n }\n \n _this.ticketsel.loading = false;\n //this.el.set_sort_column_id(0, Gtk.SortType.ASCENDING); \n \n}\n", "$ columns" : "typeof(string),typeof(string)", "n_columns" : 2, @@ -101,15 +101,15 @@ }, { "label" : "Do not create Branch", - "* pack" : "add_action_widget,0", "xtype" : "Button", + "* pack" : "add_action_widget,0", "Gtk.ReliefStyle relief" : "Gtk.ReliefStyle.NONE", "$ xns" : "Gtk" }, { "label" : "Create Branch", - "* pack" : "add_action_widget,1", "xtype" : "Button", + "* pack" : "add_action_widget,1", "$ xns" : "Gtk" } ] diff --git a/NewBranch.vala b/NewBranch.vala index 602922ed..c55d3de7 100644 --- a/NewBranch.vala +++ b/NewBranch.vala @@ -75,12 +75,17 @@ public class NewBranch : Object if (this.repo != null) { var bn = _this.name.el.get_text(); - if (ticket_id != "" ) { - this.repo.setActiveTicket( RooTicket.singleton().getById(ticket_id), bn); - } else { - this.repo.setActiveTicket( RooTicket.singleton().getById("-1"), bn); - } + + var res = this.repo.setActiveTicket( + RooTicket.singleton().getById(ticket_id != "" ? ticket_id : "-1"), bn + ); + if (res) { + // start the monitoring.. + GitMonitor.gitmonitor.start(); + + } } + this.running = false; @@ -116,7 +121,9 @@ public class NewBranch : Object this.el.show_all(); + this.el.set_keep_above(true); _this.dbmodel.loadTickets(); + this.el.run(); } public class Xcls_VBox2 : Object diff --git a/Spawn.vala b/Spawn.vala index 738ea44d..1ff51e88 100644 --- a/Spawn.vala +++ b/Spawn.vala @@ -223,9 +223,45 @@ public class Spawn : Object if (this.cfg.debug) { - stdout.printf("cd %s; %s\n" , this.cfg.cwd , string.joinv(" ", this.cfg.args)); + GLib.debug("cd %s; %s\n" , this.cfg.cwd , string.joinv(" ", this.cfg.args)); } + // stdout: + if (!this.cfg.async) { + string ls_stdout; + string ls_stderr; + int ls_status; + + Process.spawn_sync ( + this.cfg.cwd, + this.cfg.args, + this.cfg.env, + SpawnFlags.SEARCH_PATH, + null, + out ls_stdout, + out ls_stderr, + out ls_status + ); + this.output = ls_stdout; + this.stderr = ls_stderr; + this.result = ls_status; + if (this.cfg.exceptions && this.result != 0) { + var errstr = string.joinv(" ", this.cfg.args) + "\n"; + errstr += this.output; + errstr += this.output.length > 0 ? "\n" : ""; + errstr += this.stderr; + //print("Throwing execute error:%s\n", errstr); + throw new SpawnError.EXECUTE_ERROR(errstr); + //this.toString = function() { return this.stderr; }; + ///throw new Exception this; // we throw self... + } + return; + + } + + + + Process.spawn_async_with_pipes ( this.cfg.cwd, this.cfg.args, @@ -237,14 +273,14 @@ public class Spawn : Object out standard_output, out standard_error); - // stdout: + //print(JSON.stringify(gret)); if (this.cfg.debug) { - stdout.printf("PID: %d\n" ,this.pid); + GLib.debug("PID: %d\n" ,this.pid); } this.ref(); // additional ref - cleared on tidyup... @@ -295,7 +331,7 @@ public class Spawn : Object if (this.pid > -1) { // child can exit before we get this far.. if (this.cfg.input != null) { - if (this.cfg.debug) print("Trying to call listeners"); + if (this.cfg.debug) GLib.debug("Trying to call listeners"); try { this.write(this.cfg.input()); // this probably needs to be a bit smarter... @@ -324,12 +360,14 @@ public class Spawn : Object if (this.pid > -1) { //print("starting main loop"); - //if (this.cfg.debug) { - // - // } + if (this.cfg.debug) { + GLib.debug("starting main loop"); + } this.ctx = new MainLoop (); this.ctx.run(); // wait fore exit? - + if (this.cfg.debug) { + GLib.debug(" main loop done"); + } //print("main_loop done!"); } else { this.tidyup(); // tidyup get's called in main loop. @@ -383,6 +421,10 @@ public class Spawn : Object private void tidyup() { + if (this.cfg.debug) { + GLib.debug("tidyup"); + } + //print("Tidyup\n"); if (this.pid > -1) { Process.close_pid(this.pid); // hopefully kills it.. diff --git a/StatusIcon.vala b/StatusIcon.vala index 137d7504..efedebaa 100644 --- a/StatusIcon.vala +++ b/StatusIcon.vala @@ -225,7 +225,7 @@ public class StatusIconA : StatusIcon { this.label = ("Merge [%s] #%s %s".printf(r.name, t.id , t.summary)); this.activate.connect(() => { - MergeBranch.singleton().show(this.ticket); + MergeBranch.singleton().show(this.ticket, null); // show merge dialog.. }); @@ -459,7 +459,9 @@ public class StatusIconA : StatusIcon { this.accel_group = null; this.activate.connect( () => { - Clones.singleton().show(); + GitRepo.updateAll("show_clones"); + + // Clones.singleton().show(); }); } diff --git a/config1.builder b/config1.builder index 55088b03..8b546603 100644 --- a/config1.builder +++ b/config1.builder @@ -18,7 +18,8 @@ "..//gitlive/NewBranch.vala", "..//gitlive/GitMonitorQueue.vala", "..//gitlive/RooTicket.vala", - "..//gitlive/MergeBranch.vala" + "..//gitlive/MergeBranch.vala", + "..//gitlive/RepoStatusPopover.vala" ], "packages" : [ ] @@ -41,7 +42,8 @@ "gdk-3.0", "gtk+-3.0", "json-glib-1.0", - "libsoup-2.4" + "libsoup-2.4", + "gtksourceview-3.0" ] } ] \ No newline at end of file diff --git a/configure.ac b/configure.ac index f9666ddc..11ab1335 100644 --- a/configure.ac +++ b/configure.ac @@ -26,6 +26,7 @@ PKG_CHECK_MODULES(GITLIVE, [ glib-2.0 >= 2.24.1 gobject-2.0 >= 2.24.1 gtk+-3.0 >= 3.11.3 + gtksourceview-3.0 libnotify libwnck-3.0 libcanberra