本文整理汇总了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);
}
示例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;
}