本文整理汇总了C#中Repository.RetrieveStatus方法的典型用法代码示例。如果您正苦于以下问题:C# Repository.RetrieveStatus方法的具体用法?C# Repository.RetrieveStatus怎么用?C# Repository.RetrieveStatus使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Repository
的用法示例。
在下文中一共展示了Repository.RetrieveStatus方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CanCheckoutAnExistingBranchByName
public void CanCheckoutAnExistingBranchByName(string branchName)
{
string path = SandboxStandardTestRepo();
using (var repo = new Repository(path))
{
Branch master = repo.Branches["master"];
Assert.True(master.IsCurrentRepositoryHead);
// Set the working directory to the current head
ResetAndCleanWorkingDirectory(repo);
Assert.False(repo.RetrieveStatus().IsDirty);
Branch test = repo.Checkout(branchName);
Assert.False(repo.Info.IsHeadDetached);
Assert.False(test.IsRemote);
Assert.True(test.IsCurrentRepositoryHead);
Assert.Equal(repo.Head, test);
Assert.False(master.IsCurrentRepositoryHead);
// Working directory should not be dirty
Assert.False(repo.RetrieveStatus().IsDirty);
// Assert reflog entry is created
var reflogEntry = repo.Refs.Log(repo.Refs.Head).First();
Assert.Equal(master.Tip.Id, reflogEntry.From);
Assert.Equal(repo.Branches[branchName].Tip.Id, reflogEntry.To);
Assert.NotNull(reflogEntry.Commiter.Email);
Assert.NotNull(reflogEntry.Commiter.Name);
Assert.Equal(string.Format("checkout: moving from master to {0}", branchName), reflogEntry.Message);
}
}
示例2: HonorDeeplyNestedGitIgnoreFile
public void HonorDeeplyNestedGitIgnoreFile()
{
string path = InitNewRepository();
using (var repo = new Repository(path))
{
char pd = Path.DirectorySeparatorChar;
var gitIgnoreFile = string.Format("deeply{0}nested{0}.gitignore", pd);
Touch(repo.Info.WorkingDirectory, gitIgnoreFile, "SmtCounters.h");
Commands.Stage(repo, gitIgnoreFile);
repo.Commit("Add .gitignore", Constants.Signature, Constants.Signature);
Assert.False(repo.RetrieveStatus().IsDirty);
var ignoredFile = string.Format("deeply{0}nested{0}SmtCounters.h", pd);
Touch(repo.Info.WorkingDirectory, ignoredFile, "Content");
Assert.False(repo.RetrieveStatus().IsDirty);
var file = string.Format("deeply{0}nested{0}file.txt", pd);
Touch(repo.Info.WorkingDirectory, file, "Yeah!");
var repositoryStatus = repo.RetrieveStatus();
Assert.True(repositoryStatus.IsDirty);
Assert.Equal(FileStatus.Ignored, repositoryStatus[ignoredFile].State);
Assert.Equal(FileStatus.NewInWorkdir, repositoryStatus[file].State);
Assert.True(repo.Ignore.IsPathIgnored(ignoredFile));
Assert.False(repo.Ignore.IsPathIgnored(file));
}
}
示例3: CanRemoveAnUnalteredFileFromTheIndexWithoutRemovingItFromTheWorkingDirectory
public void CanRemoveAnUnalteredFileFromTheIndexWithoutRemovingItFromTheWorkingDirectory(
bool removeFromWorkdir, string filename, bool throws, FileStatus initialStatus, bool existsBeforeRemove, bool existsAfterRemove, FileStatus lastStatus)
{
string path = SandboxStandardTestRepo();
using (var repo = new Repository(path))
{
int count = repo.Index.Count;
string fullpath = Path.Combine(repo.Info.WorkingDirectory, filename);
Assert.Equal(initialStatus, repo.RetrieveStatus(filename));
Assert.Equal(existsBeforeRemove, File.Exists(fullpath));
if (throws)
{
Assert.Throws<RemoveFromIndexException>(() => repo.Remove(filename, removeFromWorkdir));
Assert.Equal(count, repo.Index.Count);
}
else
{
repo.Remove(filename, removeFromWorkdir);
Assert.Equal(count - 1, repo.Index.Count);
Assert.Equal(existsAfterRemove, File.Exists(fullpath));
Assert.Equal(lastStatus, repo.RetrieveStatus(filename));
}
}
}
示例4: CanAddAndRemoveStash
public void CanAddAndRemoveStash()
{
string path = SandboxStandardTestRepo();
using (var repo = new Repository(path))
{
var stasher = Constants.Signature;
Assert.True(repo.RetrieveStatus().IsDirty);
Stash stash = repo.Stashes.Add(stasher, "My very first stash", StashModifiers.IncludeUntracked);
// Check that untracked files are deleted from working directory
string untrackedFilename = "new_untracked_file.txt";
Assert.False(File.Exists(Path.Combine(repo.Info.WorkingDirectory, untrackedFilename)));
Assert.NotNull(stash.Untracked[untrackedFilename]);
Assert.NotNull(stash);
Assert.Equal("[email protected]{0}", stash.CanonicalName);
Assert.Contains("My very first stash", stash.Message);
var stashRef = repo.Refs["refs/stash"];
Assert.Equal(stash.WorkTree.Sha, stashRef.TargetIdentifier);
Assert.False(repo.RetrieveStatus().IsDirty);
// Create extra file
untrackedFilename = "stash_candidate.txt";
Touch(repo.Info.WorkingDirectory, untrackedFilename, "Oh, I'm going to be stashed!\n");
Stash secondStash = repo.Stashes.Add(stasher, "My second stash", StashModifiers.IncludeUntracked);
Assert.NotNull(stash);
Assert.Equal("[email protected]{0}", stash.CanonicalName);
Assert.Contains("My second stash", secondStash.Message);
Assert.Equal(2, repo.Stashes.Count());
Assert.Equal("[email protected]{0}", repo.Stashes.First().CanonicalName);
Assert.Equal("[email protected]{1}", repo.Stashes.Last().CanonicalName);
Assert.NotNull(secondStash.Untracked[untrackedFilename]);
// Stash history has been shifted
Assert.Equal(repo.Lookup<Commit>("[email protected]{0}").Sha, secondStash.WorkTree.Sha);
Assert.Equal(repo.Lookup<Commit>("[email protected]{1}").Sha, stash.WorkTree.Sha);
//Remove one stash
repo.Stashes.Remove(0);
Assert.Equal(1, repo.Stashes.Count());
Stash newTopStash = repo.Stashes.First();
Assert.Equal("[email protected]{0}", newTopStash.CanonicalName);
Assert.Equal(stash.WorkTree.Sha, newTopStash.WorkTree.Sha);
// Stash history has been shifted
Assert.Equal(stash.WorkTree.Sha, repo.Lookup<Commit>("stash").Sha);
Assert.Equal(stash.WorkTree.Sha, repo.Lookup<Commit>("[email protected]{0}").Sha);
}
}
示例5: CanIgnoreIgnoredPaths
public void CanIgnoreIgnoredPaths(string path)
{
using (var repo = new Repository(SandboxStandardTestRepo()))
{
Touch(repo.Info.WorkingDirectory, ".gitignore", "ignored_file.txt\nignored_folder/\n");
Touch(repo.Info.WorkingDirectory, path, "This file is ignored.");
Assert.Equal(FileStatus.Ignored, repo.RetrieveStatus(path));
Commands.Stage(repo, "*");
Assert.Equal(FileStatus.Ignored, repo.RetrieveStatus(path));
}
}
示例6: CanAddAnEntryToTheIndexFromAFileInTheWorkdir
public void CanAddAnEntryToTheIndexFromAFileInTheWorkdir(string pathInTheWorkdir, FileStatus expectedBeforeStatus, FileStatus expectedAfterStatus)
{
var path = SandboxStandardTestRepoGitDir();
using (var repo = new Repository(path))
{
var before = repo.RetrieveStatus(pathInTheWorkdir);
Assert.Equal(expectedBeforeStatus, before);
repo.Index.Add(pathInTheWorkdir);
var after = repo.RetrieveStatus(pathInTheWorkdir);
Assert.Equal(expectedAfterStatus, after);
}
}
示例7: MixedResetRefreshesTheIndex
public void MixedResetRefreshesTheIndex()
{
string repoPath = InitNewRepository();
using (var repo = new Repository(repoPath))
{
FeedTheRepository(repo);
var oldHeadId = repo.Head.Tip.Id;
Tag tag = repo.Tags["mytag"];
repo.Reset(ResetMode.Mixed, tag.CanonicalName);
Assert.Equal(FileStatus.Modified, repo.RetrieveStatus("a.txt"));
AssertRefLogEntry(repo, "HEAD",
tag.Target.Id,
string.Format("reset: moving to {0}", tag.Target.Sha),
oldHeadId);
AssertRefLogEntry(repo, "refs/heads/mybranch",
tag.Target.Id,
string.Format("reset: moving to {0}", tag.Target.Sha),
oldHeadId);
}
}
示例8: CanStage
public void CanStage(string relativePath, FileStatus currentStatus, bool doesCurrentlyExistInTheIndex, FileStatus expectedStatusOnceStaged, bool doesExistInTheIndexOnceStaged, int expectedIndexCountVariation)
{
string path = SandboxStandardTestRepo();
using (var repo = new Repository(path))
{
int count = repo.Index.Count;
Assert.Equal(doesCurrentlyExistInTheIndex, (repo.Index[relativePath] != null));
Assert.Equal(currentStatus, repo.RetrieveStatus(relativePath));
repo.Stage(relativePath);
Assert.Equal(count + expectedIndexCountVariation, repo.Index.Count);
Assert.Equal(doesExistInTheIndexOnceStaged, (repo.Index[relativePath] != null));
Assert.Equal(expectedStatusOnceStaged, repo.RetrieveStatus(relativePath));
}
}
示例9: CanResolveConflictsByRemovingFromTheIndex
public void CanResolveConflictsByRemovingFromTheIndex(
bool removeFromWorkdir, string filename, bool existsBeforeRemove, bool existsAfterRemove, FileStatus lastStatus, int removedIndexEntries)
{
var path = SandboxMergedTestRepo();
using (var repo = new Repository(path))
{
int count = repo.Index.Count;
string fullpath = Path.Combine(repo.Info.WorkingDirectory, filename);
Assert.Equal(existsBeforeRemove, File.Exists(fullpath));
Assert.NotNull(repo.Index.Conflicts[filename]);
Assert.Equal(0, repo.Index.Conflicts.ResolvedConflicts.Count());
repo.Remove(filename, removeFromWorkdir);
Assert.Null(repo.Index.Conflicts[filename]);
Assert.Equal(count - removedIndexEntries, repo.Index.Count);
Assert.Equal(existsAfterRemove, File.Exists(fullpath));
Assert.Equal(lastStatus, repo.RetrieveStatus(filename));
Assert.Equal(1, repo.Index.Conflicts.ResolvedConflicts.Count());
Assert.NotNull(repo.Index.Conflicts.ResolvedConflicts[filename]);
}
}
示例10: CanCopeWithExternalChangesToTheIndex
public void CanCopeWithExternalChangesToTheIndex()
{
SelfCleaningDirectory scd = BuildSelfCleaningDirectory();
Touch(scd.DirectoryPath, "a.txt", "a\n");
Touch(scd.DirectoryPath, "b.txt", "b\n");
string path = Repository.Init(scd.DirectoryPath);
using (var repoWrite = new Repository(path))
using (var repoRead = new Repository(path))
{
var writeStatus = repoWrite.RetrieveStatus();
Assert.True(writeStatus.IsDirty);
Assert.Equal(0, repoWrite.Index.Count);
var readStatus = repoRead.RetrieveStatus();
Assert.True(readStatus.IsDirty);
Assert.Equal(0, repoRead.Index.Count);
repoWrite.Stage("*");
repoWrite.Commit("message", Constants.Signature, Constants.Signature);
writeStatus = repoWrite.RetrieveStatus();
Assert.False(writeStatus.IsDirty);
Assert.Equal(2, repoWrite.Index.Count);
readStatus = repoRead.RetrieveStatus();
Assert.False(readStatus.IsDirty);
Assert.Equal(2, repoRead.Index.Count);
}
}
示例11: CanCleanWorkingDirectory
public void CanCleanWorkingDirectory()
{
string path = CloneStandardTestRepo();
using (var repo = new Repository(path))
{
// Verify that there are the expected number of entries and untracked files
Assert.Equal(6, repo.RetrieveStatus().Count());
Assert.Equal(1, repo.RetrieveStatus().Untracked.Count());
repo.RemoveUntrackedFiles();
// Verify that there are the expected number of entries and 0 untracked files
Assert.Equal(5, repo.RetrieveStatus().Count());
Assert.Equal(0, repo.RetrieveStatus().Untracked.Count());
}
}
示例12: MixedResetRefreshesTheIndex
public void MixedResetRefreshesTheIndex()
{
string repoPath = InitNewRepository();
using (var repo = new Repository(repoPath, new RepositoryOptions { Identity = Constants.Identity }))
{
FeedTheRepository(repo);
var oldHeadId = repo.Head.Tip.Id;
Tag tag = repo.Tags["mytag"];
var before = DateTimeOffset.Now.TruncateMilliseconds();
repo.Reset(ResetMode.Mixed, tag.CanonicalName);
Assert.Equal(FileStatus.ModifiedInWorkdir, repo.RetrieveStatus("a.txt"));
AssertRefLogEntry(repo, "HEAD",
string.Format("reset: moving to {0}", tag.Target.Sha),
oldHeadId,
tag.Target.Id,
Constants.Identity, before);
AssertRefLogEntry(repo, "refs/heads/mybranch",
string.Format("reset: moving to {0}", tag.Target.Sha),
oldHeadId,
tag.Target.Id,
Constants.Identity, before);
}
}
示例13: CanAddAnEntryToTheIndexFromABlob
public void CanAddAnEntryToTheIndexFromABlob()
{
var path = SandboxStandardTestRepoGitDir();
using (var repo = new Repository(path))
{
const string targetIndexEntryPath = "1.txt";
var before = repo.RetrieveStatus(targetIndexEntryPath);
Assert.Equal(FileStatus.Unaltered, before);
var blob = repo.Lookup<Blob>("a8233120f6ad708f843d861ce2b7228ec4e3dec6");
repo.Index.Add(blob, targetIndexEntryPath, Mode.NonExecutableFile);
var after = repo.RetrieveStatus(targetIndexEntryPath);
Assert.Equal(FileStatus.ModifiedInIndex | FileStatus.ModifiedInWorkdir, after);
}
}
示例14: CanRetrieveTheStatusOfAFile
public void CanRetrieveTheStatusOfAFile()
{
var path = SandboxStandardTestRepoGitDir();
using (var repo = new Repository(path))
{
FileStatus status = repo.RetrieveStatus("new_tracked_file.txt");
Assert.Equal(FileStatus.Added, status);
}
}
示例15: TemporaryRulesShouldApplyUntilCleared
public void TemporaryRulesShouldApplyUntilCleared()
{
string path = SandboxStandardTestRepo();
using (var repo = new Repository(path))
{
Touch(repo.Info.WorkingDirectory, "Foo.cs", "Bar");
Assert.True(repo.RetrieveStatus().Untracked.Select(s => s.FilePath).Contains("Foo.cs"));
repo.Ignore.AddTemporaryRules(new[] { "*.cs" });
Assert.False(repo.RetrieveStatus().Untracked.Select(s => s.FilePath).Contains("Foo.cs"));
repo.Ignore.ResetAllTemporaryRules();
Assert.True(repo.RetrieveStatus().Untracked.Select(s => s.FilePath).Contains("Foo.cs"));
}
}