本文整理汇总了C#中IRepository.RetrieveStatus方法的典型用法代码示例。如果您正苦于以下问题:C# IRepository.RetrieveStatus方法的具体用法?C# IRepository.RetrieveStatus怎么用?C# IRepository.RetrieveStatus使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IRepository
的用法示例。
在下文中一共展示了IRepository.RetrieveStatus方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: IndexViewModel
public IndexViewModel(IRepository repo)
{
this.repo = repo;
this.refreshCommand = ReactiveCommand.Create();
this.repositoryStatus = this.refreshCommand.Select(u =>
{
return repo.RetrieveStatus(new StatusOptions() { Show = StatusShowOption.IndexAndWorkDir });
}).ToProperty(this, vm => vm.RepositoryStatus);
this.statusEntries = this
.WhenAny(vm => vm.RepositoryStatus, change =>
{
var status = change.GetValue();
return status.CreateDerivedCollection(s => s, null, null, null, this.refreshCommand);
}).ToProperty(this, vm => vm.StatusEntries);
var resetSignal = this.WhenAny(vm => vm.StatusEntries, change =>
{
return 0;
});
var allEntries = this.WhenAny(vm => vm.StatusEntries, change => change.GetValue());
this.unstagedEntries = allEntries.Select(s =>
{
return s.CreateDerivedCollection(i => i, i => Unstaged(i.State), null, resetSignal);
}).ToProperty(this, vm => vm.UnstagedEntries);
this.stagedEntries = allEntries.Select(s =>
{
return s.CreateDerivedCollection(i => i, i => Staged(i.State), null, resetSignal);
}).ToProperty(this, vm => vm.StagedEntries);
}
示例2: Model
public Model(IRepository repository)
{
mRepository = repository;
mRevision = new Lazy<string>(() => mRepository.Commits.Count().ToString(CultureInfo.InvariantCulture));
mShortHash = new Lazy<string>(() => mRepository.Commits.Last().Sha.Substring(0, 7));
mBranch = new Lazy<string>(() => mRepository.Head.CanonicalName);
mHasLocalChange = new Lazy<string>(() => mRepository.RetrieveStatus().IsDirty.ToString(CultureInfo.InvariantCulture));
#if DEBUG
mBuildConfig = "DEBUG";
#else
mBuildConfig = "RELEASE";
#endif
}
示例3: AssertStatus
private static void AssertStatus(bool shouldIgnoreCase, FileStatus expectedFileStatus, IRepository repo, string path)
{
try
{
Assert.Equal(expectedFileStatus, repo.RetrieveStatus(path));
}
catch (ArgumentException)
{
Assert.False(shouldIgnoreCase);
}
}
示例4: RemoveStagedItems
private static IEnumerable<string> RemoveStagedItems(IRepository repository, IEnumerable<string> paths, bool removeFromWorkingDirectory = true, ExplicitPathsOptions explicitPathsOptions = null)
{
var removed = new List<string>();
using (var changes = repository.Diff.Compare<TreeChanges>(DiffModifiers.IncludeUnmodified | DiffModifiers.IncludeUntracked, paths, explicitPathsOptions))
{
var index = repository.Index;
foreach (var treeEntryChanges in changes)
{
var status = repository.RetrieveStatus(treeEntryChanges.Path);
switch (treeEntryChanges.Status)
{
case ChangeKind.Added:
case ChangeKind.Deleted:
removed.Add(treeEntryChanges.Path);
index.Remove(treeEntryChanges.Path);
break;
case ChangeKind.Unmodified:
if (removeFromWorkingDirectory && (
status.HasFlag(FileStatus.ModifiedInIndex) ||
status.HasFlag(FileStatus.NewInIndex)))
{
throw new RemoveFromIndexException("Unable to remove file '{0}', as it has changes staged in the index. You can call the Remove() method with removeFromWorkingDirectory=false if you want to remove it from the index only.",
treeEntryChanges.Path);
}
removed.Add(treeEntryChanges.Path);
index.Remove(treeEntryChanges.Path);
continue;
case ChangeKind.Modified:
if (status.HasFlag(FileStatus.ModifiedInWorkdir) && status.HasFlag(FileStatus.ModifiedInIndex))
{
throw new RemoveFromIndexException("Unable to remove file '{0}', as it has staged content different from both the working directory and the HEAD.",
treeEntryChanges.Path);
}
if (removeFromWorkingDirectory)
{
throw new RemoveFromIndexException("Unable to remove file '{0}', as it has local modifications. You can call the Remove() method with removeFromWorkingDirectory=false if you want to remove it from the index only.",
treeEntryChanges.Path);
}
removed.Add(treeEntryChanges.Path);
index.Remove(treeEntryChanges.Path);
continue;
default:
throw new RemoveFromIndexException("Unable to remove file '{0}'. Its current status is '{1}'.",
treeEntryChanges.Path,
treeEntryChanges.Status);
}
}
index.Write();
return removed;
}
}
示例5: GitModifications
/// <summary>
/// Get a value indicating if there are modifications in the current working directory.
/// </summary>
private void GitModifications(IRepository repo)
{
var status = repo.RetrieveStatus(new StatusOptions());
this.gitInfo.Added = status.Added.Count();
this.gitInfo.Missing = status.Missing.Count();
this.gitInfo.Modified = status.Modified.Count();
this.gitInfo.Removed = status.Removed.Count();
this.gitInfo.Staged = status.Staged.Count();
this.gitInfo.Changes = this.gitInfo.Added + this.gitInfo.Missing + this.gitInfo.Modified
+ this.gitInfo.Removed + this.gitInfo.Staged;
this.gitInfo.HasModifications = Convert.ToBoolean(this.gitInfo.Changes);
}
示例6: FeedTheRepository
private static void FeedTheRepository(IRepository repo)
{
string fullPath = Touch(repo.Info.WorkingDirectory, "a.txt", "Hello\n");
repo.Stage(fullPath);
repo.Commit("Initial commit", Constants.Signature, Constants.Signature);
repo.ApplyTag("mytag");
File.AppendAllText(fullPath, "World\n");
repo.Stage(fullPath);
Signature shiftedSignature = Constants.Signature.TimeShift(TimeSpan.FromMinutes(1));
repo.Commit("Update file", shiftedSignature, shiftedSignature);
repo.CreateBranch("mybranch");
repo.Checkout("mybranch");
Assert.False(repo.RetrieveStatus().IsDirty);
}
示例7: AssertStage
private static void AssertStage(bool? ignorecase, IRepository repo, string path)
{
try
{
repo.Stage(path);
Assert.Equal(FileStatus.Added, repo.RetrieveStatus(path));
repo.Reset();
Assert.Equal(FileStatus.Untracked, repo.RetrieveStatus(path));
}
catch (ArgumentException)
{
Assert.False(ignorecase ?? true);
}
}
示例8: AssertStage
private static void AssertStage(bool? ignorecase, IRepository repo, string path)
{
try
{
Commands.Stage(repo, path);
Assert.Equal(FileStatus.NewInIndex, repo.RetrieveStatus(path));
repo.Index.Replace(repo.Head.Tip);
Assert.Equal(FileStatus.NewInWorkdir, repo.RetrieveStatus(path));
}
catch (ArgumentException)
{
Assert.False(ignorecase ?? true);
}
}
示例9: BuildFrom
private static Tuple<string, FileStatus> BuildFrom(IRepository repository, string path)
{
string relativePath = repository.BuildRelativePathFrom(path);
return new Tuple<string, FileStatus>(relativePath, repository.RetrieveStatus(relativePath));
}