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


C# Repository.GetBranch方法代码示例

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


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

示例1: GitBasedFileSystemHistory

        public GitBasedFileSystemHistory(Repository repository, BranchName branchName)
        {
            if (branchName == null)
            {
                throw new ArgumentNullException(nameof(branchName));
            }
            if (repository == null)
            {
                throw new ArgumentNullException(nameof(repository));
            }

            m_Repository = repository;
            var branch = repository.GetBranch(branchName);
            m_BranchName = BranchName.Parse(branch.FriendlyName);

            m_Snapshots = new Lazy<IDictionary<string, GitBasedFileSystemSnapshot>>(LoadSnapshots);
        }
开发者ID:ap0llo,项目名称:SyncTool,代码行数:17,代码来源:GitBasedFileSystemHistory.cs

示例2: Create

        public static GitBasedMultiFileSystemSnapshot Create(Repository repository, BranchName branchName, IHistoryService historyService)
        {
            var directoryCreator = new LocalItemCreator();            

            var branch = repository.GetBranch(branchName);

            string commitId;
            using (var workingRepository = new TemporaryWorkingDirectory(repository.Info.Path, branch.FriendlyName))
            {

                var snapshotDirectory = new Directory(null, s_SnapshotDirectoryName);
                foreach (var fileSystemHistory in historyService.Items)
                {
                    var fileName = fileSystemHistory.Name + s_FileNameSuffix;
                    var content = fileSystemHistory.LatestFileSystemSnapshot?.Id ?? "";
                    snapshotDirectory.Add(d => new TextFile(d, fileName, content));
                }
                
                var snapshotDirectoryPath = Path.Combine(workingRepository.Location, s_SnapshotDirectoryName);
                directoryCreator.CreateDirectoryInPlace(snapshotDirectory, snapshotDirectoryPath, true);

                if (workingRepository.HasChanges)
                {
                    try
                    {
                        commitId = workingRepository.Commit("Created multi-filesystem snapshot");
                        workingRepository.Push();
                    }
                    catch (EmptyCommitException)
                    {
                        // no changes after all (HasChanges does not seem to be a 100% accurate)
                        commitId = repository.GetBranch(branchName).Tip.Sha;
                    }

                }
                else
                {
                    commitId = repository.GetBranch(branchName).Tip.Sha;
                }
            }

            var commit = repository.Lookup<Commit>(commitId);
            return IsSnapshot(commit) ? new GitBasedMultiFileSystemSnapshot(commit, historyService) : null;
        }
开发者ID:ap0llo,项目名称:SyncTool,代码行数:44,代码来源:GitBasedMultiFileSystemSnapshot.cs


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