From: Alan Knowles Date: Wed, 20 Mar 2019 06:37:20 +0000 (+0800) Subject: sync X-Git-Url: http://git.roojs.org/?a=commitdiff_plain;h=c02fc4d9e15adb3377948574522892233feab419;hp=a4ac2d6066f79b078520ea94db59c84ae9c48293;p=gitlive sync --- diff --git a/Git.vala b/Git.vala index b4cc84cd..62070086 100644 --- a/Git.vala +++ b/Git.vala @@ -186,9 +186,7 @@ namespace GitLive { this.repo.create_commit("HEAD", sig, sig, null, "Test Merge", new_tree, parents); - - - + } @@ -219,9 +217,12 @@ namespace GitLive { var commits = new Ggit.AnnotatedCommit[] { ac }; this.repo.merge(commits, mo, co); + + var cfg = this.repo.get_config().snapshot(); + var sig = new Ggit.Signature.now( - this.repo.get_config().get_string("user.name"), - this.repo.get_config().get_string("user.email") + cfg.get_string("user.name"), + cfg.get_string("user.email") ); var new_head = this.repo.get_head(); var oid = new_head.get_target(); @@ -236,9 +237,8 @@ namespace GitLive { var parent = new_head.lookup() as Ggit.Commit; Ggit.Commit[] parents = new Ggit.Commit[] { parent }; - this.repo.create_commit(this.head.get_name(), sig, sig, null, "Test Merge", new_tree, parents); + this.repo.create_commit("refs/heads/" + this.head.get_name(), sig, sig, null, "Test Merge", new_tree, parents); - } diff --git a/GitRepo.vala b/GitRepo.vala index d1ee6453..987f495f 100644 --- a/GitRepo.vala +++ b/GitRepo.vala @@ -28,10 +28,10 @@ public class GitRepo : Object public GitBranch currentBranch; public Gee.HashMap branches; // accessed in GitBranch.. public RooTicket? activeTicket; - public Gee.HashMap cache; - public Gee.HashMap config_cache; - + public Gee.HashMap cache; + public Gee.HashMap config_cache; + private Ggit.Repository repo; public static GitRepo singleton() { @@ -175,8 +175,13 @@ public class GitRepo : Object cache.set( path, this); } - var r = this.git({ "remote" , "get-url" , "--push" , "origin"}); - var uri = new Soup.URI(r); + this.repo = Ggit.Repository.open(GLib.File.new_for_path(path)); + + var r = this.repo.lookup_remote("origin"); + + + //var r = this.git({ "remote" , "get-url" , "--push" , "origin"}); + var uri = new Soup.URI(r.get_url()); this.host = uri.get_host(); this.init_config(); @@ -209,27 +214,30 @@ public class GitRepo : Object - public string get_config(string key) { + public string get_config(string key) + { if (this.config_cache.has_key(key)) { //GLib.debug("get_config %s = '%s'", key, this.config_cache.get(key)); return this.config_cache.get(key); } try { - var ret = this.git({ "config" , "gitlive." + key }).strip(); - this.config_cache.set(key, ret); - //GLib.debug("get_config %s = '%s'", key, ret); + var cfg = this.repo.get_config().snapshot(); + var ret = cfg.get_string("gitlive." + key).strip(); return ret; } catch (Error e) { - this.config_cache.set(key, ""); + this.repo.get_config().set_string("gitlive." + key, ""); + //this.config_cache.set(key, ""); //GLib.debug("get_config (fail) %s = '%s'", key, ""); return ""; // happens when there is nothing set... } } - public void set_config(string key, string value) { - this.git({ "config" , "gitlive." + key, value }); - this.config_cache.set(key,value); + public void set_config(string key, string value) + { + this.repo.get_config().set_string("gitlive." + key, value); + //this.git({ "config" , "gitlive." + key, value }); + //this.config_cache.set(key,value); } public bool is_managed() @@ -283,6 +291,7 @@ public class GitRepo : Object public void loadStatus() { + // status??/ var r = this.git({ "status" , "--porcelain" }); this.git_status = r; this.has_local_changes = r.length > 0;