当前位置: 首页>>代码示例>>C#>>正文


C# IGitTfsRemote.Fetch方法代码示例

本文整理汇总了C#中IGitTfsRemote.Fetch方法的典型用法代码示例。如果您正苦于以下问题:C# IGitTfsRemote.Fetch方法的具体用法?C# IGitTfsRemote.Fetch怎么用?C# IGitTfsRemote.Fetch使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IGitTfsRemote的用法示例。


在下文中一共展示了IGitTfsRemote.Fetch方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: DoFetch

 protected virtual void DoFetch(IGitTfsRemote remote)
 {
     // It is possible that we have outdated refs/remotes/tfs/<id>.
     // E.g. someone already fetched changesets from TFS into another git repository and we've pulled it since
     // in that case tfs fetch will retrieve same changes again unnecessarily. To prevent it we will scan tree from HEAD and see if newer changesets from
     // TFS exists (by checking git-tfs-id mark in commit's comments).
     // The process is similar to bootstrapping.
     globals.Repository.MoveTfsRefForwardIfNeeded(remote);
     remote.Fetch();
 }
开发者ID:runt18,项目名称:git-tfs,代码行数:10,代码来源:Fetch.cs

示例2: DoFetch

        protected virtual void DoFetch(IGitTfsRemote remote, bool stopOnFailMergeCommit)
        {
            if (remote.Repository.IsBare)
            {
                if(string.IsNullOrEmpty(BareBranch))
                    throw new GitTfsException("error : specify a git branch to fetch on...");
                if (!remote.Repository.HasRef(GitRepository.ShortToLocalName(BareBranch)))
                    throw new GitTfsException("error : the specified git branch doesn't exist...");
                if (!ForceFetch && remote.MaxCommitHash != remote.Repository.GetCommit(BareBranch).Sha)
                    throw new GitTfsException("error : fetch is not allowed when there is ahead commits!",
                        new List<string>() {"Remove ahead commits and retry", "use the --force option (ahead commits will be lost!)"});
            }

            // It is possible that we have outdated refs/remotes/tfs/<id>.
            // E.g. someone already fetched changesets from TFS into another git repository and we've pulled it since
            // in that case tfs fetch will retrieve same changes again unnecessarily. To prevent it we will scan tree from HEAD and see if newer changesets from
            // TFS exists (by checking git-tfs-id mark in commit's comments).
            // The process is similar to bootstrapping.
            if (!ForceFetch)
                globals.Repository.MoveTfsRefForwardIfNeeded(remote);
            var exportMetadatasFilePath = Path.Combine(globals.GitDir, "git-tfs_workitem_mapping.txt");
            if (ExportMetadatas)
            {
                remote.ExportMetadatas = true;
                remote.Repository.SetConfig(GitTfsConstants.ExportMetadatasConfigKey, "true");
                if (!string.IsNullOrEmpty(ExportMetadatasFile))
                {
                    if (File.Exists(ExportMetadatasFile))
                    {
                        File.Copy(ExportMetadatasFile, exportMetadatasFilePath);
                    }
                    else
                        throw new GitTfsException("error: the work items mapping file doesn't exist!");
                }
            }
            else
            {
                if(remote.Repository.GetConfig(GitTfsConstants.ExportMetadatasConfigKey) == "true")
                    remote.ExportMetadatas = true;
            }
            remote.ExportWorkitemsMapping = new Dictionary<string, string>();
            if (remote.ExportMetadatas && File.Exists(exportMetadatasFilePath))
            {
                try
                {
                    foreach (var lineRead in File.ReadAllLines(exportMetadatasFilePath))
                    {
                        if (string.IsNullOrWhiteSpace(lineRead))
                            continue;
                        var values = lineRead.Split('|');
                        var oldWorkitem = values[0].Trim();
                        if(!remote.ExportWorkitemsMapping.ContainsKey(oldWorkitem))
                            remote.ExportWorkitemsMapping.Add(oldWorkitem, values[1].Trim());
                    }
                }
                catch (Exception)
                {
                    throw new GitTfsException("error: bad format of workitems mapping file! One line format should be: OldWorkItemId|NewWorkItemId");
                }
            }

            try
            {
                remote.Fetch(stopOnFailMergeCommit);

            }
            finally
            {
                Trace.WriteLine("Cleaning...");
                remote.CleanupWorkspaceDirectory();

                if (remote.Repository.IsBare)
                    remote.Repository.UpdateRef(GitRepository.ShortToLocalName(BareBranch), remote.MaxCommitHash);
            }
        }
开发者ID:JenasysDesign,项目名称:git-tfs,代码行数:75,代码来源:Fetch.cs

示例3: FetchRemote

        private IFetchResult FetchRemote(IGitTfsRemote tfsRemote, bool stopOnFailMergeCommit, bool createBranch = true)
        {
            Trace.WriteLine("Try fetching changesets...");
            var fetchResult = tfsRemote.Fetch(stopOnFailMergeCommit);
            Trace.WriteLine("Changesets fetched!");

            if (createBranch && fetchResult.IsSuccess && tfsRemote.Id != GitTfsConstants.DefaultRepositoryId)
            {
                Trace.WriteLine("Try creating the local branch...");
                if (!_globals.Repository.CreateBranch("refs/heads/" + tfsRemote.Id, tfsRemote.MaxCommitHash))
                    _stdout.WriteLine("warning: Fail to create local branch ref file!");
                else
                    Trace.WriteLine("Local branch created!");
            }

            Trace.WriteLine("Cleaning...");
            tfsRemote.CleanupWorkspaceDirectory();

            return fetchResult;
        }
开发者ID:Corniel,项目名称:git-tfs,代码行数:20,代码来源:InitBranch.cs

示例4: DoFetch

        protected virtual void DoFetch(IGitTfsRemote remote, bool stopOnFailMergeCommit)
        {
            var bareBranch = string.IsNullOrEmpty(BareBranch) ? remote.Id : BareBranch;

            // It is possible that we have outdated refs/remotes/tfs/<id>.
            // E.g. someone already fetched changesets from TFS into another git repository and we've pulled it since
            // in that case tfs fetch will retrieve same changes again unnecessarily. To prevent it we will scan tree from HEAD and see if newer changesets from
            // TFS exists (by checking git-tfs-id mark in commit's comments).
            // The process is similar to bootstrapping.
            if (!ForceFetch)
            {
                if (!remote.Repository.IsBare)
                    remote.Repository.MoveTfsRefForwardIfNeeded(remote);
                else
                    remote.Repository.MoveTfsRefForwardIfNeeded(remote, bareBranch);
            }

            if (!ForceFetch &&
                remote.Repository.IsBare &&
                remote.Repository.HasRef(GitRepository.ShortToLocalName(bareBranch)) &&
                remote.MaxCommitHash != remote.Repository.GetCommit(bareBranch).Sha)
            {
                throw new GitTfsException("error : fetch is not allowed when there is ahead commits!",
                    new[] {"Remove ahead commits and retry", "use the --force option (ahead commits will be lost!)"});
            }

            var metadataExportInitializer = new ExportMetadatasInitializer(globals);
            bool shouldExport = ExportMetadatas || remote.Repository.GetConfig(GitTfsConstants.ExportMetadatasConfigKey) == "true";

            if (ExportMetadatas)
            {
                metadataExportInitializer.InitializeConfig(remote.Repository, ExportMetadatasFile);
            }

            metadataExportInitializer.InitializeRemote(remote, shouldExport);

            try
            {
                if (InitialChangeset.HasValue)
                {
                    properties.InitialChangeset = InitialChangeset.Value;
                    properties.PersistAllOverrides();
                    remote.QuickFetch(InitialChangeset.Value);
                    remote.Fetch(stopOnFailMergeCommit);
                }
                else
                {
                    remote.Fetch(stopOnFailMergeCommit,upToChangeSet);
                }

            }
            finally
            {
                Trace.WriteLine("Cleaning...");
                remote.CleanupWorkspaceDirectory();

                if (remote.Repository.IsBare)
                    remote.Repository.UpdateRef(GitRepository.ShortToLocalName(bareBranch), remote.MaxCommitHash);
            }
        }
开发者ID:XinChenBug,项目名称:git-tfs,代码行数:60,代码来源:Fetch.cs

示例5: FetchRemote

        private IFetchResult FetchRemote(IGitTfsRemote tfsRemote, bool stopOnFailMergeCommit, bool createBranch = true, IRenameResult renameResult = null)
        {
            try
            {
                Trace.WriteLine("Try fetching changesets...");
                var fetchResult = tfsRemote.Fetch(stopOnFailMergeCommit, renameResult: renameResult);
                Trace.WriteLine("Changesets fetched!");

                if (fetchResult.IsSuccess && createBranch && tfsRemote.Id != GitTfsConstants.DefaultRepositoryId)
                {
                    Trace.WriteLine("Try creating the local branch...");
                    var branchRef = tfsRemote.Id.ToLocalGitRef();
                    if (!_globals.Repository.HasRef(branchRef))
                    {
                        if (!_globals.Repository.CreateBranch(branchRef, tfsRemote.MaxCommitHash))
                            _stdout.WriteLine("warning: Fail to create local branch ref file!");
                        else
                            Trace.WriteLine("Local branch created!");
                    }
                    else
                    {
                        _stdout.WriteLine("info: local branch ref already exists!");
                    }
                }
                return fetchResult;
            }
            finally
            {
                Trace.WriteLine("Cleaning...");
                tfsRemote.CleanupWorkspaceDirectory();
            }
        }
开发者ID:XinChenBug,项目名称:git-tfs,代码行数:32,代码来源:InitBranch.cs

示例6: DoFetch

        protected virtual void DoFetch(IGitTfsRemote remote)
        {
            if (remote.Repository.IsBare)
            {
                if(string.IsNullOrEmpty(BareBranch))
                    throw new GitTfsException("error : specify a git branch to fetch on...");
                if (!remote.Repository.HasRef(GitRepository.ShortToLocalName(BareBranch)))
                    throw new GitTfsException("error : the specified git branch doesn't exist...");
                if (!ForceFetchBare && remote.MaxCommitHash != remote.Repository.GetCommit(BareBranch).Sha)
                    throw new GitTfsException("error : fetch is not allowed when there is ahead commits!",
                        new List<string>() {"Remove ahead commits and retry", "use the --force option (ahead commits will be lost!)"});
            }

            // It is possible that we have outdated refs/remotes/tfs/<id>.
            // E.g. someone already fetched changesets from TFS into another git repository and we've pulled it since
            // in that case tfs fetch will retrieve same changes again unnecessarily. To prevent it we will scan tree from HEAD and see if newer changesets from
            // TFS exists (by checking git-tfs-id mark in commit's comments).
            // The process is similar to bootstrapping.
            globals.Repository.MoveTfsRefForwardIfNeeded(remote);

            remote.Fetch();

            Trace.WriteLine("Cleaning...");
            remote.CleanupWorkspaceDirectory();

            if(remote.Repository.IsBare)
                remote.Repository.UpdateRef(GitRepository.ShortToLocalName(BareBranch), remote.MaxCommitHash);
        }
开发者ID:RomanKruglyakov,项目名称:git-tfs,代码行数:28,代码来源:Fetch.cs

示例7: DoFetch

 protected virtual void DoFetch(IGitTfsRemote remote)
 {
     remote.Fetch();
 }
开发者ID:jsmale,项目名称:git-tfs,代码行数:4,代码来源:Fetch.cs


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