• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# GitCommands.GitHead类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了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;
        }
开发者ID:Gitulf,项目名称:gitextensions,代码行数:60,代码来源:GitCommands.cs


示例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;
        }
开发者ID:dopry,项目名称:gitextensions,代码行数:34,代码来源:GitModule.cs


示例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);
        }
开发者ID:nickmayer,项目名称:gitextensions,代码行数:39,代码来源:FormPush.cs


示例4: GetHeadColor

 private static Color GetHeadColor(GitHead head)
 {
     return head.IsTag
                ? Settings.TagColor
                : head.IsHead
                      ? Settings.BranchColor
                      : head.IsRemote
                            ? Settings.RemoteBranchColor
                            : Settings.OtherTagColor;
 }
开发者ID:eranws,项目名称:gitextensions,代码行数:10,代码来源:RevisionGrid.cs


示例5: GitHeaderGuiWrapper

 public GitHeaderGuiWrapper(GitHead gitHead)
 {
     _gitHead = gitHead;
 }
开发者ID:dmay,项目名称:gitextensions,代码行数:4,代码来源:FormGoToCommit.cs


示例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);
        }
开发者ID:adrianoc,项目名称:gitextensions,代码行数:38,代码来源:FormPush.cs


示例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;
        }
开发者ID:gdennie,项目名称:gitextensions,代码行数:64,代码来源:FormPull.cs


示例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;
        }
开发者ID:TwistedHope,项目名称:gitextensions,代码行数:49,代码来源:FormPull.cs


示例9: MergesWithRemote

 public bool MergesWithRemote(GitHead head)
 {
     return head.IsRemote && head.Remote == TrackingRemote && head.LocalName == MergeWith;
 }
开发者ID:vasily-kirichenko,项目名称:gitextensions,代码行数:4,代码来源:GitHead.cs


示例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);
            }
        }
开发者ID:vasily-kirichenko,项目名称:gitextensions,代码行数:100,代码来源:RevisionGrid.cs


示例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);
        }
开发者ID:vasily-kirichenko,项目名称:gitextensions,代码行数:13,代码来源:RevisionGrid.cs



注:本文中的GitCommands.GitHead类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# GitCommands.GitItem类代码示例发布时间:2022-05-26
下一篇:
C# GitCommands.GitCommandsInstance类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap