本文整理汇总了C#中LibGit2Sharp.Repository.LocalBranchExists方法的典型用法代码示例。如果您正苦于以下问题:C# Repository.LocalBranchExists方法的具体用法?C# Repository.LocalBranchExists怎么用?C# Repository.LocalBranchExists使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LibGit2Sharp.Repository
的用法示例。
在下文中一共展示了Repository.LocalBranchExists方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: IsValid
/// <summary>
/// Verifies that the specified path points to a valid repository usable by SyncTool
/// (a repository with the expected tags and default branches as created by RepositoryInitHelper)
/// </summary>
public static bool IsValid(string path)
{
// check if the directory exists and is a valid git repository
if (!Directory.Exists(path) || !Repository.IsValid(path))
{
return false;
}
using (var repository = new Repository(path))
{
// the repository needs to be a bare repository
if (!repository.Info.IsBare)
{
return false;
}
// ensure there is a configuration branch
if (!repository.LocalBranchExists(RepositoryInitHelper.ConfigurationBranchName))
{
return false;
}
// ensure there is a tag for the initial commit
if (repository.Tags[RepositoryInitHelper.InitialCommitTagName] == null)
{
return false;
}
// check if there is a repository info file in the root (on all branches)
foreach (var localBranch in repository.GetLocalBranches())
{
var gitDirectory = new GitDirectory(null, "Irrelevant", localBranch.Tip);
if (!gitDirectory.FileExists(RepositoryInfoFile.RepositoryInfoFileName))
{
return false;
}
//TODO: verify content of repository info file
}
}
return true;
}
示例2: CreateGroup_Creates_a_repository_and_pushes_it_to_the_remote_repository
public void CreateGroup_Creates_a_repository_and_pushes_it_to_the_remote_repository()
{
// create a mock for the settings provider
var settingsProvider = GetGroupSettingsProviderMock().WithEmptyGroupSettings();
// set up local working directory
var localDir = Path.Combine(m_TempDirectory.Location, "Local");
Directory.CreateDirectory(localDir);
// set up the "remote" repository
var remoteDir = Path.Combine(m_TempDirectory.Location, "Remote");
Directory.CreateDirectory(remoteDir);
Repository.Init(remoteDir, true);
var groupManager = new GitBasedGroupManager(new SingleDirectoryRepositoryPathProvider(localDir), settingsProvider.Object);
// create a new group
groupManager.CreateGroup("Group1", remoteDir);
// creation of groups should not leave behind anything
Assert.Empty(Directory.GetFileSystemEntries(localDir));
// assert that the group was actually created in the remote repository
using (var repository = new Repository(remoteDir))
{
Assert.Equal(2, repository.Branches.Count());
Assert.True(repository.LocalBranchExists(RepositoryInitHelper.ConfigurationBranchName));
Assert.NotNull(repository.Tags[RepositoryInitHelper.InitialCommitTagName]);
}
settingsProvider.Verify(m => m.SaveGroupSettings(It.IsAny<IEnumerable<GroupSettings>>()), Times.AtLeastOnce);
}
示例3: Begin_deletes_local_branches_if_the_tracked_brach_was_deleted_in_the_remote_repository
public void Begin_deletes_local_branches_if_the_tracked_brach_was_deleted_in_the_remote_repository()
{
var transaction1 = CreateTransaction();
transaction1.Begin();
m_RemoteRepository.Branches.Remove(s_Branch3);
var transaction2 = CreateCachingTransaction(transaction1.LocalPath);
transaction2.Begin();
// assert that the branch has been removed in the local repository and that other branches are still there
using (var repository = new Repository(transaction2.LocalPath))
{
Assert.False(repository.LocalBranchExists(s_Branch3));
Assert.True(repository.LocalBranchExists(s_Branch2));
Assert.True(repository.LocalBranchExists("master"));
}
}