本文整理汇总了C#中LibGit2Sharp.Repository.GetAllCommits方法的典型用法代码示例。如果您正苦于以下问题:C# Repository.GetAllCommits方法的具体用法?C# Repository.GetAllCommits怎么用?C# Repository.GetAllCommits使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LibGit2Sharp.Repository
的用法示例。
在下文中一共展示了Repository.GetAllCommits方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GitBasedFileSystemHistoryTest
public GitBasedFileSystemHistoryTest()
{
RepositoryInitHelper.InitializeRepository(m_TempDirectory.Location);
m_Repository = new Repository(m_TempDirectory.Location);
var branchName = new BranchName("", "branch1");
m_Repository.CreateBranch(branchName, m_Repository.GetAllCommits().Single());
m_Instance = new GitBasedFileSystemHistory(m_Repository, branchName);
}
示例2: InitializeRepository
/// <summary>
/// Initializes a new bare repository at the specified location, adds a repository info file to the root directory
/// and tags the initial commit with he value of <see cref="InitialCommitTagName"/>
/// </summary>
public static void InitializeRepository(string location)
{
// initialize a bare repository
Repository.Init(location, true);
var directoryCreator = new LocalItemCreator();
// clone the repository, add initial commit and push the changes back to the actual repository
using (var tempDirectory = directoryCreator.CreateTemporaryDirectory())
{
var clonedRepoPath = Repository.Clone(location, tempDirectory.Directory.Location);
var repositoryInfoFile = new RepositoryInfoFile(tempDirectory.Directory);
// add a empty file to the repository
directoryCreator.CreateFile(repositoryInfoFile, tempDirectory.Directory.Location);
// commit and push the file to the bare repository we created
using (var clonedRepo = new Repository(clonedRepoPath))
{
var signature = SignatureHelper.NewSignature();
clonedRepo.Stage(repositoryInfoFile.Name);
clonedRepo.Commit("Initial Commit", signature, signature, new CommitOptions());
clonedRepo.Network.Push(clonedRepo.Network.Remotes["origin"], @"refs/heads/master");
}
}
//create the configuration branch pointing to the initial commit
using (var repository = new Repository(location))
{
repository.CreateBranch(ConfigurationBranchName.ToString(), repository.GetAllCommits().Single());
repository.Tags.Add(InitialCommitTagName, repository.GetAllCommits().Single());
}
}
示例3: CanReuseLocalRepository_returns_false_if_the_repository_contains_unpublished_branches
public void CanReuseLocalRepository_returns_false_if_the_repository_contains_unpublished_branches()
{
var transaction1 = CreateTransaction();
transaction1.Begin();
using (var repository = new Repository(transaction1.LocalPath))
{
repository.CreateBranch("newBranch", repository.GetAllCommits().Single());
}
//do not commit the changes from the transaction (leaves the local directory intact (with a new commit))
var cachingTransaction = CreateCachingTransaction(transaction1.LocalPath);
Assert.False(cachingTransaction.CanReuseLocalRepository());
}
示例4: Commit_pushes_changes_from_all_branches_to_the_remote_repository
public void Commit_pushes_changes_from_all_branches_to_the_remote_repository()
{
var transaction = CreateTransaction();
transaction.Begin();
var expectedCommitCount = m_RemoteRepository.Commits.Count();
// make change on master branch
AddFile(transaction, "master", "file1");
expectedCommitCount += 1;
using (var localRepo = new Repository(transaction.LocalPath))
{
Assert.Equal(expectedCommitCount, localRepo.GetAllCommits().Count());
}
// make change on branch2
AddFile(transaction, s_Branch2, "file2");
expectedCommitCount += 1;
using (var localRepo = new Repository(transaction.LocalPath))
{
Assert.Equal(expectedCommitCount, localRepo.GetAllCommits().Count());
}
// push to remote repository
transaction.Commit();
// check that the commit where pushed to the remote directory
Assert.Equal(expectedCommitCount, m_RemoteRepository.GetAllCommits().Count());
}
示例5: Begin_gets_all_changes_from_the_remote_repository
public void Begin_gets_all_changes_from_the_remote_repository()
{
var transaction1 = CreateTransaction();
var transaction2 = CreateTransaction();
transaction1.Begin();
transaction2.Begin();
// add a file to the repository in transaction1
AddFile(transaction1, s_Branch2, "file1");
transaction1.Commit();
//in transaction2, add a file, too
AddFile(transaction2, s_Branch3, "file2");
transaction2.Commit();
//create a new transaction using the directory of transaction1
var transaction3 = CreateCachingTransaction(transaction1.LocalPath);
// Begin() needs to fetch the changes made by transaction2 into the local repository
transaction3.Begin();
// make sure there are really all commits in the local repository
using (var repository = new Repository(transaction3.LocalPath))
{
Assert.Equal(3, repository.GetAllCommits().Count());
}
}