X-Git-Url: http://git.roojs.org/?a=blobdiff_plain;f=Git.vala;h=f8923461545cb315a98bd4158b2007548e595532;hb=fc81ce492666a9ddf264668c0a1e41a4564d1665;hp=b1e524a6caf7dc665a933a1ea6052d797afc9212;hpb=ea2b4d58f3f5111320103623b768081e76969f8d;p=gitlive diff --git a/Git.vala b/Git.vala index b1e524a6..f8923461 100644 --- a/Git.vala +++ b/Git.vala @@ -1,7 +1,6 @@ // valac -o /tmp/ggit Git.vala --pkg libgit2-glib-1.0 --pkg libsoup-2.4 --pkg gee-0.8 -g - - + void main() { @@ -18,16 +17,18 @@ void main() ); Ggit.init(); - - - GLib.Timeout.add (10, () => { + var a = new GitLive.Repo("/home/alan/gitlive/web.coba"); + a.fetchAll(); + return; + /* + GLib.Timeout.add (1, () => { GLib.debug("Meanwhile"); return true; - }, GLib.Priority.DEFAULT); + }, 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); @@ -104,19 +105,29 @@ namespace GitLive { var r = this.repo.enumerate_branches(Ggit.BranchType.LOCAL); while (r.next()) { var br = r.get() as Ggit.Branch; + if (br == null) { + continue; + } + if (br.is_tag()) { + 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"); } - } @@ -313,6 +324,7 @@ namespace GitLive { } var r = this.repo.lookup_remote("origin"); r.connect(Ggit.Direction.FETCH, this.callbacks, null, null); + yield; this.remote_heads = r.list(); foreach(var br in this.remote_heads) { @@ -321,7 +333,7 @@ namespace GitLive { } GLib.debug("Remote: name=%s oid=%s local_oid=%s is_local=%s", - br.get_name().substring(11), + br.get_name(), br.get_oid().to_string(), br.get_local_oid().to_string(), br.is_local() ? "Y" : "n" @@ -330,7 +342,7 @@ namespace GitLive { Idle.add((owned) callback); return true;; }; - new Thread("thread-example", run); + new Thread("loadRemoteHeads-" , run); yield;