"items" : [
{
"listeners" : {
- "row_activated" : "(path, col) => {\n\n\tif (col.title == \"Auto Commit\" || col.title == \"Auto Push\" || col.title == \"Auto 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}",
+ "row_activated" : "(path, col) => {\n\n\tif (col.title == \"Auto Commit\" || col.title == \"Auto Push\" || col.title == \"Auto 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_sync(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",
"items" : [
{
"listeners" : {
- "toggled" : " (self, path) => {\n \n \tGtk.TreeIter iter;\n \t_this.reposStore.el.get_iter_from_string(out iter, path);\n \t\n \tGLib.Value val;\n \tGLib.Value rval;\n \t_this.reposStore.el.get_value(iter, 4, out val);\n \t_this.reposStore.el.get_value(iter, 6, out rval);\n \t\n \tvar repopath = (string)rval;\n \tvar bval = (bool)val;\n \t_this.reposStore.el.set_value(iter, 4, !bval);\n \tGLib.debug(\"got repopath? %s\", repopath);\n \t\n \tvar repo = GitRepo.get(repopath);\n \trepo.set_autocommit(!bval);\n \t\n \t\n \t\n \n}"
+ "toggled" : " (self, path) => {\n \n \tGtk.TreeIter iter;\n \t_this.reposStore.el.get_iter_from_string(out iter, path);\n \t\n \tGLib.Value val;\n \tGLib.Value rval;\n \t_this.reposStore.el.get_value(iter, 4, out val);\n \t_this.reposStore.el.get_value(iter, 6, out rval);\n \t\n \tvar repopath = (string)rval;\n \tvar bval = (bool)val;\n \t_this.reposStore.el.set_value(iter, 4, !bval);\n \tGLib.debug(\"got repopath? %s\", repopath);\n \t\n \tvar repo = GitRepo.get_sync(repopath);\n \trepo.set_autocommit(!bval);\n \t \n \n}"
},
"id" : "cr_autocommit",
"* pack" : "pack_start,false",
"items" : [
{
"listeners" : {
- "toggled" : " (self, path) => {\n \n \tGtk.TreeIter iter;\n \t_this.reposStore.el.get_iter_from_string(out iter, path);\n \t\n \tGLib.Value val;\n \tGLib.Value rval;\n \t_this.reposStore.el.get_value(iter, 5, out val);\n \t_this.reposStore.el.get_value(iter, 6, out rval);\n \t\n \tvar repopath = (string)rval;\n \tvar bval = (bool)val;\n \t_this.reposStore.el.set_value(iter, 5, !bval);\n \tvar repo = GitRepo.get(repopath);\n \trepo.set_autopush(!bval);\n \t\n \t\n \t\n \n}"
+ "toggled" : " (self, path) => {\n \n \tGtk.TreeIter iter;\n \t_this.reposStore.el.get_iter_from_string(out iter, path);\n \t\n \tGLib.Value val;\n \tGLib.Value rval;\n \t_this.reposStore.el.get_value(iter, 5, out val);\n \t_this.reposStore.el.get_value(iter, 6, out rval);\n \t\n \tvar repopath = (string)rval;\n \tvar bval = (bool)val;\n \t_this.reposStore.el.set_value(iter, 5, !bval);\n \tvar repo = GitRepo.get_sync(repopath);\n \trepo.set_autopush(!bval);\n \t\n \t\n \t\n \n}"
},
"id" : "cr_autopush",
"* pack" : "pack_start,false",
"items" : [
{
"listeners" : {
- "toggled" : " (self, path) => {\n \n \tGtk.TreeIter iter;\n \t_this.reposStore.el.get_iter_from_string(out iter, path);\n \t\n \tGLib.Value val;\n \tGLib.Value rval;\n \t_this.reposStore.el.get_value(iter, 8, out val);\n \t_this.reposStore.el.get_value(iter, 6, out rval);\n \t\n \tvar repopath = (string)rval;\n \tvar bval = (bool)val;\n \t_this.reposStore.el.set_value(iter, 8, !bval);\n \tvar repo = GitRepo.get(repopath);\n \trepo.set_auto_branch(!bval);\n \t\n \t\n \t\n \n}"
+ "toggled" : " (self, path) => {\n \n \tGtk.TreeIter iter;\n \t_this.reposStore.el.get_iter_from_string(out iter, path);\n \t\n \tGLib.Value val;\n \tGLib.Value rval;\n \t_this.reposStore.el.get_value(iter, 8, out val);\n \t_this.reposStore.el.get_value(iter, 6, out rval);\n \t\n \tvar repopath = (string)rval;\n \tvar bval = (bool)val;\n \t_this.reposStore.el.set_value(iter, 8, !bval);\n \tvar repo = GitRepo.get_sync(repopath);\n \trepo.set_auto_branch(!bval);\n \t\n \t\n \t\n \n}"
},
"id" : "cr_autobranch",
"xtype" : "CellRendererToggle",
_this.reposStore.el.get_value(iter, 6, out val);
var git_working_dir = (string)val;
- var repo = GitRepo.singleton().get(git_working_dir);
+ var repo = GitRepo.singleton().get_sync(git_working_dir);
Gdk.Rectangle rect;
_this.reposView.el.get_cell_area(path, col, out rect);
_this.reposStore.el.set_value(iter, 4, !bval);
GLib.debug("got repopath? %s", repopath);
- var repo = GitRepo.get(repopath);
+ var repo = GitRepo.get_sync(repopath);
repo.set_autocommit(!bval);
-
-
-
+
});
}
var repopath = (string)rval;
var bval = (bool)val;
_this.reposStore.el.set_value(iter, 5, !bval);
- var repo = GitRepo.get(repopath);
+ var repo = GitRepo.get_sync(repopath);
repo.set_autopush(!bval);
var repopath = (string)rval;
var bval = (bool)val;
_this.reposStore.el.set_value(iter, 8, !bval);
- var repo = GitRepo.get(repopath);
+ var repo = GitRepo.get_sync(repopath);
repo.set_auto_branch(!bval);
// valac -o /tmp/ggit Git.vala --pkg libgit2-glib-1.0 --pkg libsoup-2.4 --pkg gee-0.8 -g
-
-
+
void main()
{
}, GLib.Priority.HIGH);
var loop = new MainLoop();
-
- var a = new GitLive.Repo("/home/alan/gitlive/gitlive");
+
+ var a = new GitLive.Repo("/home/alan/gitlive/web.coba");
GLib.debug("Starting");
a.loadRemoteHeads.begin(true, (obj,res) => {
a.loadRemoteHeads.end(res);
var r = this.repo.enumerate_branches(Ggit.BranchType.LOCAL);
while (r.next()) {
var br = r.get() as Ggit.Branch;
+ if (br == null) {
+ continue;
+ }
+
//var head = this.repo.revparse("refs/heads/" + br.get_name() ).get_id();
//var rhead = this.repo.revparse(br.get_upstream().get_name() ).get_id();
- GLib.debug("got branch: H=%s name = %s upstream = %s oid = %s ",
- br.is_head() ? "Y" : "n",
- br.get_name(),
- br.get_upstream().get_name().substring(20),
- br.get_target().to_string());
- this.branches.add(br);
- if (br.is_head()) {
- GLib.debug("HEAD= %s", br.get_name());
- this.head = br;
+ try {
+ GLib.debug("got branch: N=%s", br.get_name() );
+ GLib.debug("is_head %s", br.is_head() ? "Y" : "n");
+
+ GLib.debug("upstream = %s", br.get_upstream() == null ? "??" : br.get_upstream().get_name().substring(20));
+ GLib.debug("oid = %s",br.get_target().to_string());
+ this.branches.add(br);
+ if (br.is_head()) {
+ GLib.debug("HEAD= %s", br.get_name());
+ this.head = br;
+ }
+ } catch (Error e) {
+ GLib.debug("Skip branch");
}
-
}
while (r.next()) {
var br = new GitBranch(repo);
var gbr = r.get() as Ggit.Branch;
- repo.branches.set(gbr.get_name(), br);
+
br.active = gbr.is_head();
br.name = gbr.get_name();
br.lastrev = gbr.get_target().to_string();
- var rname = gbr.get_upstream() != null ? gbr.get_upstream().get_name() : "";
+ string rname ;
+ try {
+ rname = gbr.get_upstream() != null ? gbr.get_upstream().get_name() : "";
+ } catch(Error e) {
+ GLib.debug("Skip branch = got error");
+ continue;
+ }
+ repo.branches.set(gbr.get_name(), br);
if (rname.has_prefix("refs/remotes/origin/")) {
rname = rname.substring(20);
if (remotes.has_key(rname)) {
// age?
// behind or infront..
}
+ if (br.active) {
+ GLib.debug("repo: %s currentBranch = %s", repo.name, br.name);
+ repo.currentBranch = br;
+ }
}
repo.branches.set(rn, br);
}
+ if (repo.currentBranch == null) {
+ GLib.error("could not find active Branch for %s", repo.name);
+ }
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..
});
}
+ 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();
}
+ // 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)) {
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()) {
base.monitor(path, depth);
+ if (depth == 0) {
+ this.scancomplete = 1;
+ }
+
+
}
var gitpath = cmd.gitpath;
- var repo = GitRepo.get( gitpath );
+ var repo = GitRepo.get_sync( gitpath );
if ( repo.is_master_branch() && repo.is_auto_branch()) {
leave_queued.add(cmd);
continue;
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);
this.vname = this.vdir + (this.vdir.length > 0 ? "/" : "") + this.name;
- this.repo = GitRepo.get(this.gitpath);
+ this.repo = GitRepo.get_sync(this.gitpath);
// trigger the suggestion to start a new branch
public string ahead_or_behind = "";
public Gee.HashMap<string,bool> ignore_files;
- public GitBranch currentBranch;
+
+ public GitBranch currentBranch;
+
public Gee.HashMap<string,GitBranch> branches; // accessed in GitBranch..
public RooTicket? activeTicket;
public Gee.HashMap<string,GitRepo> cache;
*/
public static int indexOf( Array<GitRepo> repos, string gitpath) {
// make a fake object to compare against..
- var test_repo = GitRepo.get(gitpath);
+ var test_repo = GitRepo.get_sync(gitpath);
for(var i =0; i < repos.length; i++) {
if (repos.index(i).gitdir == test_repo.gitdir) {
continue;
}
- var rep = GitRepo.get( sp );
+ var rep = GitRepo.get_sync( sp );
list_cache.append_val(rep);
}
}
- public static GitRepo get(string path)
+ public static GitRepo get_sync(string path)
{
+ GitRepo ret;
var cache = GitRepo.singleton().cache;
if (cache.has_key(path)) {
- return cache.get(path);
+ ret = cache.get(path);
+ } else {
+ ret = new GitRepo(path);
}
- return new GitRepo(path);
+ return ret;
+ }
+
+ public static async GitRepo? get(string path)
+ {
+
+ SourceFunc callback = GitRepo.get.callback;
+ GitRepo ret = null;
+ ThreadFunc<bool> run = () => {
+
+ var cache = GitRepo.singleton().cache;
+ if (cache.has_key(path)) {
+ ret = cache.get(path);
+ } else {
+ ret = new GitRepo(path);
+ }
+ Idle.add((owned) callback);
+ return true;
+
+ };
+ new Thread<bool>("thread-new-gitrepo", run);
+ yield;
+ return ret;
+
}
private GitRepo.single() {
}
-
+
+ public void doUpdate()
+ {
+ // update the branches..
+
+
+ }
+
+
+ public static void updateAllAsync(string after)
+ {
+ var done = 0;
+
+ var tr = GitRepo.singleton().cache;
+
+ var update_all_total = tr.size;
+ foreach(var repo in tr.values) {
+ repo.doUpdate.begin((obj, res) => {
+ GitRepo.updateRepo.end(res);
+ done++;
+ if (update_all_total != done) {
+ return;
+ }
+ switch (after) {
+ case "show_clones":
+ Clones.singleton().show();
+ break;
+ default:
+ GLib.debug("Unkown call after load = %s", update_all_after);
+ break;
+ }
+ }
+ }
+
+
+ }
+
}
GLib.debug("calls total = %d", (int) update_all_total);
}
+
+
+
public static void updateAllCallback(GitRepo repo, int err, string res)
{
repo.loadBranches();
}
);
-
+ Ggit.init();
Gtk.init (ref args);
GitMonitor.gitlive = Environment.get_home_dir() + "/gitlive";
this.activate.connect( () => {
this.pullAll();
- /*
- GitMonitor.gitmonitor.stop();
- var tr = GitRepo.list();
-
-
-
- for (var i= 0; i< tr.length;i++) {
- statusicon.set_from_stock(
- i%2 == 0 ? Gtk.Stock.FULLSCREEN : Gtk.Stock.LEAVE_FULLSCREEN );
-
- var repo = tr.index(i);
- //if (!repo.autocommit()) {
- //??? should we ignore ones not on autocommit..
- // continue;
- //}
- try {
- statusicon.set_tooltip_text("pull: " + repo.name);
- var str = repo.pull();
- // do not care if it's already in sycn..
- if (Regex.match_simple ("Already up-to-date", str) ) {
- continue;
- }
- var notification = new Notify.Notification(
- "Updated " + repo.name,
- str,
- "dialog-information"
-
- );
-
- notification.set_timeout(20);
- notification.show();
-
- } catch(Error e) {
- print("notification or push errror- probably to many in queue..");
- statusicon.set_from_stock( Gtk.Stock.MEDIA_RECORD );
- print(e.message);
-
- }
-
- }
- */
+
});