本文整理汇总了C#中GitCommands.GitRef类的典型用法代码示例。如果您正苦于以下问题:C# GitRef类的具体用法?C# GitRef怎么用?C# GitRef使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
GitRef类属于GitCommands命名空间,在下文中一共展示了GitRef类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetTreeRefs
private IList<GitRef> GetTreeRefs(string tree)
{
var itemsStrings = tree.Split('\n');
var gitRefs = new List<GitRef>();
var defaultHeads = new Dictionary<string, GitRef>(); // 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 = GitCommandHelpers.GetRemoteName(completeName, remotes);
var head = new GitRef(this, guid, completeName, remoteName);
if (DefaultHeadPattern.IsMatch(completeName))
defaultHeads[remoteName] = head;
else
gitRefs.Add(head);
}
// do not show default head if remote has a branch on the same commit
GitRef defaultHead;
foreach (var gitRef in gitRefs.Where(head => defaultHeads.TryGetValue(head.Remote, out defaultHead) && head.Guid == defaultHead.Guid))
{
defaultHeads.Remove(gitRef.Remote);
}
gitRefs.AddRange(defaultHeads.Values);
return gitRefs;
}
示例2: RemotesUpdated
private void RemotesUpdated(object sender, EventArgs e)
{
if (TabControlTagBranch.SelectedTab == MultipleBranchTab)
UpdateMultiBranchView();
EnableLoadSshButton();
// update the text box of the Remote Url combobox to show the URL of selected remote
{
string pushUrl = Module.GetPathSetting(string.Format(SettingKeyString.RemotePushUrl, _NO_TRANSLATE_Remotes.Text));
if (pushUrl.IsNullOrEmpty())
{
pushUrl = Module.GetPathSetting(string.Format(SettingKeyString.RemoteUrl, _NO_TRANSLATE_Remotes.Text));
}
PushDestination.Text = pushUrl;
}
var pushSettingValue = Module.GetSetting(string.Format("remote.{0}.push", _NO_TRANSLATE_Remotes.Text));
if (PushToRemote.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 GitRef(Module, 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 GitRef(Module, null, _currentBranch, _NO_TRANSLATE_Remotes.Text);
_NO_TRANSLATE_Branch.Items.Add(currentBranch);
_NO_TRANSLATE_Branch.SelectedItem = currentBranch;
return;
}
BranchSelectedValueChanged(null, null);
}
示例3: GetHeadColor
private static Color GetHeadColor(GitRef gitRef)
{
if (gitRef.IsTag)
return AppSettings.TagColor;
if (gitRef.IsHead)
return AppSettings.BranchColor;
if (gitRef.IsRemote)
return AppSettings.RemoteBranchColor;
return AppSettings.OtherTagColor;
}
示例4: ShowRemoteRef
public bool ShowRemoteRef(GitRef r)
{
if (r.IsTag)
return AppSettings.ShowSuperprojectTags;
if (r.IsHead)
return AppSettings.ShowSuperprojectBranches;
if (r.IsRemote)
return AppSettings.ShowSuperprojectRemoteBranches;
return false;
}
示例5: comboBoxBranches_TextChanged
private void comboBoxBranches_TextChanged(object sender, EventArgs e)
{
if (comboBoxBranches.DataSource == null)
{
return;
}
_selectedBranch = ((List<GitRef>)comboBoxBranches.DataSource).FirstOrDefault(a => a.LocalName == comboBoxBranches.Text);
SetSelectedRevisionByFocusedControl();
}
示例6: GetDefaultPushRemote
private string GetDefaultPushRemote(String remote, String branch)
{
Func<string, string, bool> IsSettingForBranch = (aSetting, aBranch) =>
{
var head = new GitRef(Module, string.Empty, aSetting);
return head.IsHead && head.Name.Equals(aBranch);
};
var pushSettings = Module.GetSettings(string.Format("remote.{0}.push", remote));
var remoteHead = pushSettings.
Select(s => s.Split(':')).
Where(t => t.Length == 2).
Where(t => IsSettingForBranch(t[0], branch)).
Select(t => new GitRef(Module, string.Empty, t[1])).
Where(h => h.IsHead).
FirstOrDefault();
return remoteHead == null ? null : remoteHead.Name;
}
示例7: comboBoxBranches_SelectionChangeCommitted
private void comboBoxBranches_SelectionChangeCommitted(object sender, EventArgs e)
{
if (comboBoxBranches.SelectedValue == null)
{
return;
}
_selectedBranch = (GitRef)comboBoxBranches.SelectedValue;
SetSelectedRevisionByFocusedControl();
Go();
}
示例8: GetDefaultPushRemote
/// <summary>
/// Returns the default remote for push operation.
/// </summary>
/// <param name="remote"></param>
/// <param name="branch"></param>
/// <returns>The <see cref="GitRef.Name"/> if found, otheriwse <see langword="null"/>.</returns>
// TODO: moved verbatim from FormPush.cs, perhaps needs refactoring
public string GetDefaultPushRemote(GitRemote remote, string branch)
{
if (remote == null)
{
throw new ArgumentNullException("remote");
}
Func<string, string, bool> isSettingForBranch = (setting, branchName) =>
{
var head = new GitRef(_module, string.Empty, setting);
return head.IsHead && head.Name.Equals(branchName, StringComparison.OrdinalIgnoreCase);
};
var remoteHead = remote.Push
.Select(s => s.Split(':'))
.Where(t => t.Length == 2)
.Where(t => isSettingForBranch(t[0], branch))
.Select(t => new GitRef(_module, string.Empty, t[1]))
.FirstOrDefault(h => h.IsHead);
return remoteHead == null ? null : remoteHead.Name;
}
示例9: GetTreeRefs
private IList<GitRef> GetTreeRefs(string tree)
{
var gitRefs = new List<GitRef>();
var defaultHeads = new Dictionary<string, GitRef>(); // remote -> HEAD
var remotes = GetRemotes(false);
using (TextReader tr = new StringReader(tree))
{
string line = tr.ReadLine();
while (line != null)
{
if (line == null || line.Length <= 42 || line.StartsWith("error: "))
continue;
var completeName = line.Substring(41).Trim();
var guid = line.Substring(0, 40);
var remoteName = GitCommandHelpers.GetRemoteName(completeName, remotes);
var head = new GitRef(this, guid, completeName, remoteName);
if (DefaultHeadPattern.IsMatch(completeName))
defaultHeads[remoteName] = head;
else
gitRefs.Add(head);
line = tr.ReadLine();
}
}
// do not show default head if remote has a branch on the same commit
GitRef defaultHead;
foreach (var gitRef in gitRefs.Where(head => defaultHeads.TryGetValue(head.Remote, out defaultHead) && head.Guid == defaultHead.Guid))
{
defaultHeads.Remove(gitRef.Remote);
}
gitRefs.AddRange(defaultHeads.Values);
return gitRefs;
}
示例10: RemotesUpdated
private void RemotesUpdated(object sender, EventArgs e)
{
_selectedRemote = _NO_TRANSLATE_Remotes.SelectedItem as GitRemote;
if (_selectedRemote == null)
{
return;
}
if (TabControlTagBranch.SelectedTab == MultipleBranchTab)
{
UpdateMultiBranchView();
}
EnableLoadSshButton();
// update the text box of the Remote Url combobox to show the URL of selected remote
string pushUrl = _selectedRemote.PushUrl;
if (pushUrl.IsNullOrEmpty())
{
pushUrl = _selectedRemote.Url;
}
PushDestination.Text = pushUrl;
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 GitRef(Module, null, _currentBranchName, _selectedRemote.Name);
_NO_TRANSLATE_Branch.Items.Add(currentBranch);
_NO_TRANSLATE_Branch.SelectedItem = currentBranch;
}
BranchSelectedValueChanged(null, null);
}
示例11: TagNode
public TagNode(Tree aTree, string aFullPath, GitRef tagInfo)
: base(aTree, aFullPath)
{
_tagInfo = tagInfo;
}