X-Git-Url: http://git.roojs.org/?a=blobdiff_plain;f=GitRepo.vala;h=987f495f1d1d5b03f214601a06c8326b46260494;hb=c02fc4d9e15adb3377948574522892233feab419;hp=d1ee64539b2eb9d7c225a1f32ee43ad34e18fa3e;hpb=1b65514c93e260c86b738acbb13cf8ec2a39d596;p=gitlive 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;