本文整理汇总了C#中GitCommands.GitHead类的典型用法代码示例。如果您正苦于以下问题:C# GitHead类的具体用法?C# GitHead怎么用?C# GitHead使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
GitHead类属于GitCommands命名空间,在下文中一共展示了GitHead类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetRemoteHeads
public static List<GitHead> GetRemoteHeads(string remote, bool tags, bool branches)
{
remote = FixPath(remote);
string tree = "";
if (tags && branches)
tree = RunCmd(Settings.GitCommand, "ls-remote --heads --tags \"" + remote + "\"");
else
if (tags)
tree = RunCmd(Settings.GitCommand, "ls-remote --tags \"" + remote + "\"");
else
if (branches)
tree = RunCmd(Settings.GitCommand, "ls-remote --heads \"" + remote + "\"");
string[] itemsStrings = tree.Split('\n');
List<GitHead> heads = new List<GitHead>();
foreach (string itemsString in itemsStrings)
{
if (itemsString.Length > 42)
{
GitHead head = new GitHead();
head.Guid = itemsString.Substring(0, 40);
head.Name = itemsString.Substring(41).Trim();
if (head.Name.Length > 0 && head.Name.LastIndexOf("/") > 1)
{
if (head.Name.Contains("refs/tags/"))
{
//we need the one containing ^{}, because it contains the reference
if (head.Name.Contains("^{}"))
{
head.Name = head.Name.Substring(0, head.Name.Length - 3);
}
head.Name = head.Name.Substring(head.Name.LastIndexOf("/") + 1);
head.IsHead = false;
head.IsTag = true;
}
else
{
head.IsHead = head.Name.Contains("refs/heads/");
head.IsRemote = head.Name.Contains("refs/remotes/");
head.IsTag = false;
head.IsOther = !head.IsHead && !head.IsRemote && !head.IsTag;
if (head.IsHead)
head.Name = head.Name.Substring(head.Name.LastIndexOf("heads/") + 6);
else
if (head.IsRemote)
head.Name = head.Name.Substring(head.Name.LastIndexOf("remotes/") + 8);
else
head.Name = head.Name.Substring(head.Name.LastIndexOf("/") + 1);
}
}
heads.Add(head);
}
}
return heads;
}
示例2: GetHeads
private List<GitHead> GetHeads(string tree)
{
var itemsStrings = tree.Split('\n');
var heads = new List<GitHead>();
var defaultHeads = new Dictionary<string, GitHead>(); // remote -> HEAD
var remotes = GetRemotes(false);
foreach (var itemsString in itemsStrings)
{
if (itemsString == null || itemsString.Length <= 42)
continue;
var completeName = itemsString.Substring(41).Trim();
var guid = itemsString.Substring(0, 40);
var remoteName = GetRemoteName(completeName, remotes);
var head = new GitHead(this, guid, completeName, remoteName);
if (DefaultHeadPattern.IsMatch(completeName))
defaultHeads[remoteName] = head;
else
heads.Add(head);
}
// do not show default head if remote has a branch on the same commit
GitHead defaultHead;
foreach (var head in heads.Where(head => defaultHeads.TryGetValue(head.Remote, out defaultHead) && head.Guid == defaultHead.Guid))
{
defaultHeads.Remove(head.Remote);
}
heads.AddRange(defaultHeads.Values);
return heads;
}
示例3: RemotesUpdated
private void RemotesUpdated(object sender, EventArgs e)
{
if (TabControlTagBranch.SelectedTab == MultipleBranchTab)
UpdateMultiBranchView();
EnableLoadSshButton();
var pushSettingValue = Settings.Module.GetSetting(string.Format("remote.{0}.push", _NO_TRANSLATE_Remotes.Text));
if (PullFromRemote.Checked && !string.IsNullOrEmpty(pushSettingValue))
{
string defaultLocal = GetDefaultPushLocal(_NO_TRANSLATE_Remotes.Text);
string defaultRemote = GetDefaultPushRemote(_NO_TRANSLATE_Remotes.Text);
RemoteBranch.Text = "";
if (!string.IsNullOrEmpty(defaultLocal))
{
var currentBranch = new GitHead(null, defaultLocal, _NO_TRANSLATE_Remotes.Text);
_NO_TRANSLATE_Branch.Items.Add(currentBranch);
_NO_TRANSLATE_Branch.SelectedItem = currentBranch;
}
if (!string.IsNullOrEmpty(defaultRemote))
RemoteBranch.Text = defaultRemote;
return;
}
if (string.IsNullOrEmpty(_NO_TRANSLATE_Branch.Text))
{
// Doing this makes it pretty easy to accidentally create a branch on the remote.
// But leaving it blank will do the 'default' thing, meaning all branches are pushed.
// Solution: when pushing a branch that doesn't exist on the remote, ask what to do
var currentBranch = new GitHead(null, _currentBranch, _NO_TRANSLATE_Remotes.Text);
_NO_TRANSLATE_Branch.Items.Add(currentBranch);
_NO_TRANSLATE_Branch.SelectedItem = currentBranch;
return;
}
BranchSelectedValueChanged(null, null);
}
示例4: GetHeadColor
private static Color GetHeadColor(GitHead head)
{
return head.IsTag
? Settings.TagColor
: head.IsHead
? Settings.BranchColor
: head.IsRemote
? Settings.RemoteBranchColor
: Settings.OtherTagColor;
}
示例5: GitHeaderGuiWrapper
public GitHeaderGuiWrapper(GitHead gitHead)
{
_gitHead = gitHead;
}
示例6: RemotesUpdated
private void RemotesUpdated(object sender, EventArgs e)
{
if (TabControlTagBranch.SelectedTab == MultipleBranchTab)
UpdateMultiBranchView();
EnableLoadSshButton();
var pushSettingValue = GitCommandHelpers.GetSetting("remote." + Remotes.Text + ".push");
if (PullFromRemote.Checked && !string.IsNullOrEmpty(pushSettingValue))
{
var values = pushSettingValue.Split(':');
RemoteBranch.Text = "";
if (values.Length > 0)
{
var currentBranch = new GitHead(null, values[0], Remotes.Text);
Branch.Items.Add(currentBranch);
Branch.SelectedItem = currentBranch;
}
if (values.Length > 1)
RemoteBranch.Text = values[1];
return;
}
if (string.IsNullOrEmpty(Branch.Text))
{
// Doing this makes it pretty easy to accidentally create a branch on the remote.
// But leaving it blank will do the 'default' thing, meaning all branches are pushed.
// Solution: when pushing a branch that doesn't exist on the remote, ask what to do
var currentBranch = new GitHead(null, _currentBranch, Remotes.Text);
Branch.Items.Add(currentBranch);
Branch.SelectedItem = currentBranch;
return;
}
BranchSelectedValueChanged(null, null);
}
示例7: Branches_DropDown
private void Branches_DropDown(object sender, EventArgs e)
{
Cursor.Current = Cursors.WaitCursor;
if ((PullFromUrl.Checked && string.IsNullOrEmpty(PullSource.Text)) &&
(PullFromRemote.Checked && string.IsNullOrEmpty(Remotes.Text)))
{
Branches.DataSource = null;
return;
}
//string realWorkingDir = GitCommands.Settings.WorkingDir;
try
{
LoadPuttyKey();
if (Heads == null)
{
if (PullFromUrl.Checked)
{
//Heads = GitCommands.GitCommands.GetRemoteHeads(PullSource.Text, false, true);
Heads = GitCommands.GitCommands.GetHeads(false, true);
}
else
{
//The line below is the most reliable way to get a list containing
//all remote branches but it is also the slowest.
//Heads = GitCommands.GitCommands.GetRemoteHeads(Remotes.Text, false, true);
//The code below is a quick way to get a lost containg all remote branches.
//It only returns the heads that are allready known to the repository. This
//doesn't return heads that are new on the server. This can be updated using
//update branch info in the manage remotes dialog.
Heads = new List<GitHead>();
foreach (GitHead head in GitCommands.GitCommands.GetHeads(true, true))
{
if (head.IsRemote && head.Name.StartsWith(Remotes.Text, StringComparison.CurrentCultureIgnoreCase))
{
GitCommands.GitHead remoteHead = new GitCommands.GitHead();
remoteHead.Name = head.Name.Substring(head.Name.LastIndexOf("/") + 1);
Heads.Insert(0, remoteHead);
}
}
}
}
Branches.DisplayMember = "Name";
GitCommands.GitHead allHead = new GitCommands.GitHead();
allHead.Name = "*";
Heads.Insert(0, allHead);
GitCommands.GitHead noHead = new GitCommands.GitHead();
noHead.Name = "";
Heads.Insert(0, noHead);
Branches.DataSource = Heads;
}
finally
{
//GitCommands.Settings.WorkingDir = realWorkingDir;
}
Cursor.Current = Cursors.Default;
}
示例8: BranchesDropDown
private void BranchesDropDown(object sender, EventArgs e)
{
Cursor.Current = Cursors.WaitCursor;
if ((PullFromUrl.Checked && string.IsNullOrEmpty(PullSource.Text)) &&
(PullFromRemote.Checked && string.IsNullOrEmpty(Remotes.Text)))
{
Branches.DataSource = null;
return;
}
LoadPuttyKey();
if (_heads == null)
{
if (PullFromUrl.Checked)
{
_heads = GitCommands.GitCommands.GetHeads(false, true);
}
else
{
// The line below is the most reliable way to get a list containing
// all remote branches but it is also the slowest.
// Heads = GitCommands.GitCommands.GetRemoteHeads(Remotes.Text, false, true);
// The code below is a quick way to get a list containg all remote branches.
// It only returns the heads that are allready known to the repository. This
// doesn't return heads that are new on the server. This can be updated using
// update branch info in the manage remotes dialog.
_heads = new List<GitHead>();
foreach (var head in GitCommands.GitCommands.GetHeads(true, true))
{
if (!head.IsRemote ||
!head.Name.StartsWith(Remotes.Text, StringComparison.CurrentCultureIgnoreCase))
continue;
var localHead = new GitHead(null, head.LocalName);
_heads.Insert(0, localHead);
}
}
}
Branches.DisplayMember = "Name";
_heads.Insert(0, GitHead.AllHeads);
_heads.Insert(0, GitHead.NoHead);
Branches.DataSource = _heads;
Cursor.Current = Cursors.Default;
}
示例9: MergesWithRemote
public bool MergesWithRemote(GitHead head)
{
return head.IsRemote && head.Remote == TrackingRemote && head.LocalName == MergeWith;
}
示例10: ForceRefreshRevisions
public void ForceRefreshRevisions()
{
try
{
ApplyFilterFromRevisionFilterDialog();
_initialLoad = true;
LastScrollPos = Revisions.FirstDisplayedScrollingRowIndex;
DisposeRevisionGraphCommand();
var newCurrentCheckout = Settings.Module.GetCurrentCheckout();
// If the current checkout changed, don't get the currently selected rows, select the
// new current checkout instead.
if (newCurrentCheckout == CurrentCheckout)
{
LastSelectedRows = Revisions.SelectedIds;
}
else
{
// This is a new checkout, so ensure the variable is cleared out.
LastSelectedRows = null;
}
Revisions.ClearSelection();
CurrentCheckout = newCurrentCheckout;
Revisions.Clear();
Error.Visible = false;
if (!Settings.Module.ValidWorkingDir())
{
Revisions.Visible = false;
NoCommits.Visible = true;
Loading.Visible = false;
NoGit.Visible = true;
string dir = Settings.Module.WorkingDir;
if (String.IsNullOrEmpty(dir) || !Directory.Exists(dir) ||
Directory.GetDirectories(dir).Length == 0 &&
Directory.GetFiles(dir).Length == 0)
CloneRepository.Show();
else
CloneRepository.Hide();
NoGit.BringToFront();
return;
}
NoCommits.Visible = false;
NoGit.Visible = false;
Revisions.Visible = true;
Revisions.BringToFront();
Revisions.Enabled = false;
Loading.Visible = true;
Loading.BringToFront();
_isLoading = true;
currentBranch = null;
base.Refresh();
IndexWatcher.Reset();
if (!Settings.ShowGitNotes && !LogParam.Contains(" --not --glob=notes --not"))
LogParam = LogParam + " --not --glob=notes --not";
if (Settings.ShowGitNotes && LogParam.Contains(" --not --glob=notes --not"))
LogParam = LogParam.Replace(" --not --glob=notes --not", string.Empty);
RevisionGridInMemFilter revisionFilterIMF = RevisionGridInMemFilter.CreateIfNeeded(_revisionFilter.GetInMemAuthorFilter(),
_revisionFilter.GetInMemCommitterFilter(),
_revisionFilter.GetInMemMessageFilter(),
_revisionFilter.GetIgnoreCase());
RevisionGridInMemFilter filterBarIMF = RevisionGridInMemFilter.CreateIfNeeded(InMemAuthorFilter,
InMemCommitterFilter,
InMemMessageFilter,
InMemFilterIgnoreCase);
RevisionGraphInMemFilter revGraphIMF;
if (revisionFilterIMF != null && filterBarIMF != null)
revGraphIMF = new RevisionGraphInMemFilterOr(revisionFilterIMF, filterBarIMF);
else if (revisionFilterIMF != null)
revGraphIMF = revisionFilterIMF;
else
revGraphIMF = filterBarIMF;
_revisionGraphCommand = new RevisionGraph { BranchFilter = BranchFilter, LogParam = LogParam + Filter + _revisionFilter.GetFilter() };
_revisionGraphCommand.Updated += GitGetCommitsCommandUpdated;
_revisionGraphCommand.Exited += GitGetCommitsCommandExited;
_revisionGraphCommand.Error += _revisionGraphCommand_Error;
_revisionGraphCommand.InMemFilter = revGraphIMF;
//_revisionGraphCommand.BeginUpdate += ((s, e) => Revisions.Invoke((Action) (() => Revisions.Clear())));
_revisionGraphCommand.Execute();
LoadRevisions();
SetRevisionsLayout();
}
catch (Exception exception)
{
Error.Visible = true;
Error.BringToFront();
MessageBox.Show(this, exception.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
示例11: GitGetCommitsCommandUpdated
private void GitGetCommitsCommandUpdated(object sender, EventArgs e)
{
var updatedEvent = (RevisionGraph.RevisionGraphUpdatedEventArgs)e;
GitRevision revision = updatedEvent.Revision;
// remember current branch for further using
if (revision != null && revision.Heads != null && currentBranch == null)
{
currentBranch = revision.Heads.FirstOrDefault(head => !head.IsRemote && head.Selected);
}
UpdateGraph(revision);
}