public EditBranchDialog (GitRepository repo, Branch branch, bool isNew) { this.Build (); this.repo = repo; comboStore = new ListStore (typeof(string), typeof(Gdk.Pixbuf), typeof (string)); comboSources.Model = comboStore; CellRendererPixbuf crp = new CellRendererPixbuf (); comboSources.PackStart (crp, false); comboSources.AddAttribute (crp, "pixbuf", 1); CellRendererText crt = new CellRendererText (); comboSources.PackStart (crt, true); comboSources.AddAttribute (crt, "text", 2); if (branch != null) { if (!isNew) oldName = branch.Name; currentTracking = branch.Tracking; entryName.Text = branch.Name; if (currentTracking != null) checkTrack.Active = true; } foreach (Branch b in repo.GetBranches ()) { AddValues (b.Name, ImageService.GetPixbuf ("vc-git-branch")); } foreach (string t in repo.GetTags ()) AddValues (t, ImageService.GetPixbuf ("vc-git-tag")); foreach (RemoteSource r in repo.GetRemotes ()) { foreach (string b in repo.GetRemoteBranches (r.Name)) AddValues (r.Name + "/" + b, ImageService.GetPixbuf ("md-web-search-icon")); } UpdateStatus (); }
public EditBranchDialog (GitRepository repo, Branch branch, bool isNew) { this.Build (); this.repo = repo; comboStore = new ListStore (typeof(string), typeof(Xwt.Drawing.Image), typeof (string)); comboSources.Model = comboStore; var crp = new CellRendererImage (); comboSources.PackStart (crp, false); comboSources.AddAttribute (crp, "image", 1); var crt = new CellRendererText (); comboSources.PackStart (crt, true); comboSources.AddAttribute (crt, "text", 2); if (branch != null) { if (!isNew) oldName = branch.Name; currentTracking = branch.Tracking; entryName.Text = branch.Name; checkTrack.Active = currentTracking != null; } foreach (Branch b in repo.GetBranches ()) { AddValues (b.Name, ImageService.GetIcon ("vc-branch", IconSize.Menu)); } foreach (string t in repo.GetTags ()) AddValues (t, ImageService.GetIcon ("vc-tag", IconSize.Menu)); foreach (RemoteSource r in repo.GetRemotes ()) { foreach (string b in repo.GetRemoteBranches (r.Name)) AddValues (r.Name + "/" + b, ImageService.GetIcon ("vc-repository", IconSize.Menu)); } UpdateStatus (); }
public IEnumerable<Branch> GetBranches () { IDictionary<string, NGit.Ref> refs = RootRepository.RefDatabase.GetRefs (Constants.R_HEADS); foreach (var pair in refs) { string name = NGit.Repository.ShortenRefName (pair.Key); Branch br = new Branch (); br.Name = name; br.Tracking = GitUtil.GetUpstreamSource (RootRepository, name); yield return br; } }
protected virtual void OnButtonTrackRemoteClicked (object sender, System.EventArgs e) { TreeIter it; if (!treeRemotes.Selection.GetSelected (out it)) return; string branchName = (string) storeRemotes.GetValue (it, 3); if (branchName == null) return; storeRemotes.IterParent (out it, it); RemoteSource remote = (RemoteSource) storeRemotes.GetValue (it, 0); Branch b = new Branch (); b.Name = branchName; b.Tracking = remote.Name + "/" + branchName; var dlg = new EditBranchDialog (repo, b, true); try { if (MessageService.RunCustomDialog (dlg) == (int) ResponseType.Ok) { repo.CreateBranch (dlg.BranchName, dlg.TrackSource); FillBranches (); } } finally { dlg.Destroy (); } }
public IEnumerable<Branch> GetBranches () { var list = new NGit.Api.Git (RootRepository).BranchList ().SetListMode (ListBranchCommand.ListMode.HEAD); foreach (var item in list.Call ()) { string name = NGit.Repository.ShortenRefName (item.GetName ()); Branch br = new Branch (); br.Name = name; br.Tracking = GitUtil.GetUpstreamSource (RootRepository, name); yield return br; } }
public IEnumerable<Branch> GetBranches () { StringReader sr = RunCommand ("branch -vv", true); List<Branch> list = new List<Branch> (); string line; while ((line = sr.ReadLine ()) != null) { if (line.Length < 2) continue; line = line.Substring (2); int i = line.IndexOf (' '); if (i == -1) continue; Branch b = new Branch (); b.Name = line.Substring (0, i); i = line.IndexOf ('[', i); if (i != -1) { int j = line.IndexOf (']', ++i); b.Tracking = line.Substring (i, j - i); } list.Add (b); } return list; }