本文整理汇总了C#中NGit.Api.Git.Rm方法的典型用法代码示例。如果您正苦于以下问题:C# Git.Rm方法的具体用法?C# Git.Rm怎么用?C# Git.Rm使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NGit.Api.Git
的用法示例。
在下文中一共展示了Git.Rm方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: FailingPathsShouldNotResultInOKReturnValue
public virtual void FailingPathsShouldNotResultInOKReturnValue()
{
FilePath folder1 = new FilePath(db.WorkTree, "folder1");
FileUtils.Mkdir(folder1);
FilePath file = new FilePath(folder1, "file1.txt");
Write(file, "folder1--file1.txt");
file = new FilePath(folder1, "file2.txt");
Write(file, "folder1--file2.txt");
Git git = new Git(db);
git.Add().AddFilepattern(folder1.GetName()).Call();
RevCommit @base = git.Commit().SetMessage("adding folder").Call();
RecursiveDelete(folder1);
git.Rm().AddFilepattern("folder1/file1.txt").AddFilepattern("folder1/file2.txt").
Call();
RevCommit other = git.Commit().SetMessage("removing folders on 'other'").Call();
git.Checkout().SetName(@base.Name).Call();
file = new FilePath(db.WorkTree, "unrelated.txt");
Write(file, "unrelated");
git.Add().AddFilepattern("unrelated").Call();
RevCommit head = git.Commit().SetMessage("Adding another file").Call();
// Untracked file to cause failing path for delete() of folder1
file = new FilePath(folder1, "file3.txt");
Write(file, "folder1--file3.txt");
ResolveMerger merger = new ResolveMerger(db, false);
merger.SetCommitNames(new string[] { "BASE", "HEAD", "other" });
merger.SetWorkingTreeIterator(new FileTreeIterator(db));
bool ok = merger.Merge(head.Id, other.Id);
NUnit.Framework.Assert.IsFalse(merger.GetFailingPaths().IsEmpty());
NUnit.Framework.Assert.IsFalse(ok);
}
示例2: SetUp
public override void SetUp()
{
base.SetUp();
git = new Git(db);
// commit something
WriteTrashFile(FILE, "Hello world");
git.Add().AddFilepattern(FILE).Call();
commit1 = git.Commit().SetMessage("Initial commit").Call();
git.Rm().AddFilepattern(FILE).Call();
commit2 = git.Commit().SetMessage("Removed file").Call();
git.NotesAdd().SetObjectId(commit1).SetMessage("data").Call();
}
示例3: DeleteCore
void DeleteCore (FilePath[] localPaths, bool force, IProgressMonitor monitor)
{
foreach (var group in localPaths.GroupBy (p => GetRepository (p))) {
var repository = group.Key;
var files = group;
var git = new NGit.Api.Git (repository);
RmCommand rm = git.Rm ();
foreach (var f in files)
rm.AddFilepattern (repository.ToGitPath (f));
rm.Call ();
}
}
示例4: TestModifiedAndRenamed
public virtual void TestModifiedAndRenamed()
{
// this test is essentially the same as testDeletionOnSideConflict,
// however if once rename support is added this test should result in a
// successful merge instead of a conflict
Git git = new Git(db);
WriteTrashFile("x", "add x");
git.Add().AddFilepattern("x").Call();
RevCommit initial = git.Commit().SetMessage("add x").Call();
CreateBranch(initial, "refs/heads/d1");
CreateBranch(initial, "refs/heads/d2");
// rename x to y on d1
CheckoutBranch("refs/heads/d1");
new FilePath(db.WorkTree, "x").RenameTo(new FilePath(db.WorkTree, "y"));
git.Rm().AddFilepattern("x").Call();
git.Add().AddFilepattern("y").Call();
RevCommit d1Commit = git.Commit().SetMessage("d1 rename x -> y").Call();
CheckoutBranch("refs/heads/d2");
WriteTrashFile("x", "d2 change");
git.Add().AddFilepattern("x").Call();
RevCommit d2Commit = git.Commit().SetMessage("d2 change in x").Call();
CheckoutBranch("refs/heads/master");
MergeCommandResult d1Merge = git.Merge().Include(d1Commit).Call();
NUnit.Framework.Assert.AreEqual(MergeStatus.FAST_FORWARD, d1Merge.GetMergeStatus(
));
MergeCommandResult d2Merge = git.Merge().Include(d2Commit).Call();
NUnit.Framework.Assert.AreEqual(MergeStatus.CONFLICTING, d2Merge.GetMergeStatus()
);
NUnit.Framework.Assert.AreEqual(1, d2Merge.GetConflicts().Count);
NUnit.Framework.Assert.AreEqual(3, d2Merge.GetConflicts().Get("x")[0].Length);
}
示例5: TestMergeRemovingFoldersWithoutFastForward
public virtual void TestMergeRemovingFoldersWithoutFastForward()
{
FilePath folder1 = new FilePath(db.WorkTree, "folder1");
FilePath folder2 = new FilePath(db.WorkTree, "folder2");
FileUtils.Mkdir(folder1);
FileUtils.Mkdir(folder2);
FilePath file = new FilePath(folder1, "file1.txt");
Write(file, "folder1--file1.txt");
file = new FilePath(folder1, "file2.txt");
Write(file, "folder1--file2.txt");
file = new FilePath(folder2, "file1.txt");
Write(file, "folder--file1.txt");
file = new FilePath(folder2, "file2.txt");
Write(file, "folder2--file2.txt");
Git git = new Git(db);
git.Add().AddFilepattern(folder1.GetName()).AddFilepattern(folder2.GetName()).Call
();
RevCommit @base = git.Commit().SetMessage("adding folders").Call();
RecursiveDelete(folder1);
RecursiveDelete(folder2);
git.Rm().AddFilepattern("folder1/file1.txt").AddFilepattern("folder1/file2.txt").
AddFilepattern("folder2/file1.txt").AddFilepattern("folder2/file2.txt").Call();
RevCommit other = git.Commit().SetMessage("removing folders on 'branch'").Call();
git.Checkout().SetName(@base.Name).Call();
file = new FilePath(folder2, "file3.txt");
Write(file, "folder2--file3.txt");
git.Add().AddFilepattern(folder2.GetName()).Call();
git.Commit().SetMessage("adding another file").Call();
MergeCommandResult result = git.Merge().Include(other.Id).SetStrategy(MergeStrategy
.RESOLVE).Call();
NUnit.Framework.Assert.AreEqual(MergeStatus.MERGED, result.GetMergeStatus());
NUnit.Framework.Assert.IsFalse(folder1.Exists());
}
示例6: TestDeletionOnSideConflict
public virtual void TestDeletionOnSideConflict()
{
Git git = new Git(db);
WriteTrashFile("a", "1\na\n3\n");
WriteTrashFile("b", "1\nb\n3\n");
git.Add().AddFilepattern("a").AddFilepattern("b").Call();
RevCommit initialCommit = git.Commit().SetMessage("initial").Call();
// create side branch and delete "a"
CreateBranch(initialCommit, "refs/heads/side");
CheckoutBranch("refs/heads/side");
git.Rm().AddFilepattern("a").Call();
RevCommit secondCommit = git.Commit().SetMessage("side").Call();
// update a on master to generate conflict
CheckoutBranch("refs/heads/master");
WriteTrashFile("a", "1\na(main)\n3\n");
git.Add().AddFilepattern("a").Call();
git.Commit().SetMessage("main").Call();
// merge side with master
MergeCommandResult result = git.Merge().Include(secondCommit.Id).SetStrategy(MergeStrategy
.RESOLVE).Call();
NUnit.Framework.Assert.AreEqual(MergeStatus.CONFLICTING, result.GetMergeStatus());
NUnit.Framework.Assert.IsTrue(new FilePath(db.WorkTree, "a").Exists());
NUnit.Framework.Assert.AreEqual("1\na(main)\n3\n", Read(new FilePath(db.WorkTree,
"a")));
NUnit.Framework.Assert.AreEqual("1\nb\n3\n", Read(new FilePath(db.WorkTree, "b"))
);
NUnit.Framework.Assert.AreEqual(1, result.GetConflicts().Count);
NUnit.Framework.Assert.AreEqual(3, result.GetConflicts().Get("a")[0].Length);
}
示例7: DeleteCore
void DeleteCore (FilePath[] localPaths, bool force, IProgressMonitor monitor, bool keepLocal)
{
foreach (var group in GroupByRepository (localPaths)) {
List<FilePath> backupFiles = new List<FilePath> ();
var repository = group.Key;
var files = group;
var git = new NGit.Api.Git (repository);
RmCommand rm = git.Rm ();
foreach (var f in files) {
// Create backups.
if (keepLocal) {
string newPath = "";
if (f.IsDirectory) {
newPath = FileService.CreateTempDirectory ();
FileService.CopyDirectory (f, newPath);
} else {
newPath = Path.GetTempFileName ();
File.Copy (f, newPath, true);
}
backupFiles.Add (newPath);
}
rm.AddFilepattern (repository.ToGitPath (f));
}
try {
rm.Call ();
} finally {
// Restore backups.
if (keepLocal) {
foreach (var backup in backupFiles) {
if (backup.IsDirectory)
FileService.MoveDirectory (backup, files.ElementAt (backupFiles.IndexOf (backup)));
else
File.Move (backup, files.ElementAt (backupFiles.IndexOf (backup)));
}
}
}
}
}
示例8: TestResetHardFromIndexEntryWithoutFileToTreeWithoutFile
public virtual void TestResetHardFromIndexEntryWithoutFileToTreeWithoutFile()
{
Git git = new Git(db);
WriteTrashFile("x", "x");
git.Add().AddFilepattern("x").Call();
RevCommit id1 = git.Commit().SetMessage("c1").Call();
WriteTrashFile("f/g", "f/g");
git.Rm().AddFilepattern("x").Call();
git.Add().AddFilepattern("f/g").Call();
git.Commit().SetMessage("c2").Call();
DeleteTrashFile("f/g");
DeleteTrashFile("f");
// The actual test
git.Reset().SetMode(ResetCommand.ResetType.HARD).SetRef(id1.GetName()).Call();
AssertIndex(Mkmap("x", "x"));
}
示例9: TestRename
public virtual void TestRename()
{
Git git = new Git(db);
string[] content1 = new string[] { "a", "b", "c" };
WriteTrashFile("file.txt", Join(content1));
git.Add().AddFilepattern("file.txt").Call();
RevCommit commit1 = git.Commit().SetMessage("create file").Call();
WriteTrashFile("file1.txt", Join(content1));
git.Add().AddFilepattern("file1.txt").Call();
git.Rm().AddFilepattern("file.txt").Call();
git.Commit().SetMessage("moving file").Call();
string[] content2 = new string[] { "a", "b", "c2" };
WriteTrashFile("file1.txt", Join(content2));
git.Add().AddFilepattern("file1.txt").Call();
RevCommit commit3 = git.Commit().SetMessage("editing file").Call();
BlameCommand command = new BlameCommand(db);
command.SetFollowFileRenames(true);
command.SetFilePath("file1.txt");
BlameResult lines = command.Call();
NUnit.Framework.Assert.AreEqual(commit1, lines.GetSourceCommit(0));
NUnit.Framework.Assert.AreEqual(0, lines.GetSourceLine(0));
NUnit.Framework.Assert.AreEqual("file.txt", lines.GetSourcePath(0));
NUnit.Framework.Assert.AreEqual(commit1, lines.GetSourceCommit(1));
NUnit.Framework.Assert.AreEqual(1, lines.GetSourceLine(1));
NUnit.Framework.Assert.AreEqual("file.txt", lines.GetSourcePath(1));
NUnit.Framework.Assert.AreEqual(commit3, lines.GetSourceCommit(2));
NUnit.Framework.Assert.AreEqual(2, lines.GetSourceLine(2));
NUnit.Framework.Assert.AreEqual("file1.txt", lines.GetSourcePath(2));
}
示例10: DeleteDirectories
public override void DeleteDirectories (FilePath[] localPaths, bool force, IProgressMonitor monitor)
{
NGit.Api.Git git = new NGit.Api.Git (repo);
RmCommand rm = git.Rm ();
foreach (var f in localPaths)
rm.AddFilepattern (repo.ToGitPath (f));
rm.Call ();
// Untracked files are not deleted by the rm command, so delete them now
foreach (var f in localPaths) {
if (Directory.Exists (f))
Directory.Delete (f, true);
}
}
示例11: TestUntrackedFolders
public virtual void TestUntrackedFolders()
{
Git git = new Git(db);
IndexDiff diff = new IndexDiff(db, Constants.HEAD, new FileTreeIterator(db));
diff.Diff();
NUnit.Framework.CollectionAssert.AreEquivalent(Collections<string>.EMPTY_SET, diff.GetUntrackedFolders()
);
WriteTrashFile("readme", string.Empty);
WriteTrashFile("src/com/A.java", string.Empty);
WriteTrashFile("src/com/B.java", string.Empty);
WriteTrashFile("src/org/A.java", string.Empty);
WriteTrashFile("src/org/B.java", string.Empty);
WriteTrashFile("target/com/A.java", string.Empty);
WriteTrashFile("target/com/B.java", string.Empty);
WriteTrashFile("target/org/A.java", string.Empty);
WriteTrashFile("target/org/B.java", string.Empty);
git.Add().AddFilepattern("src").AddFilepattern("readme").Call();
git.Commit().SetMessage("initial").Call();
diff = new IndexDiff(db, Constants.HEAD, new FileTreeIterator(db));
diff.Diff();
NUnit.Framework.CollectionAssert.AreEquivalent(new HashSet<string>(Arrays.AsList("target")), diff
.GetUntrackedFolders());
WriteTrashFile("src/tst/A.java", string.Empty);
WriteTrashFile("src/tst/B.java", string.Empty);
diff = new IndexDiff(db, Constants.HEAD, new FileTreeIterator(db));
diff.Diff();
NUnit.Framework.CollectionAssert.AreEquivalent(new HashSet<string>(Arrays.AsList("target", "src/tst"
)), diff.GetUntrackedFolders());
git.Rm().AddFilepattern("src/com/B.java").AddFilepattern("src/org").Call();
git.Commit().SetMessage("second").Call();
WriteTrashFile("src/org/C.java", string.Empty);
diff = new IndexDiff(db, Constants.HEAD, new FileTreeIterator(db));
diff.Diff();
NUnit.Framework.CollectionAssert.AreEquivalent(new HashSet<string>(Arrays.AsList("src/org", "src/tst"
, "target")), diff.GetUntrackedFolders());
}
示例12: TestConflictingDeletedAndModified
public virtual void TestConflictingDeletedAndModified()
{
Git git = new Git(db);
WriteTrashFile("a", "1\na\n3\n");
WriteTrashFile("b", "1\nb\n3\n");
git.Add().AddFilepattern("a").AddFilepattern("b").Call();
RevCommit initialCommit = git.Commit().SetMessage("initial").Call();
// create side branch and delete "a"
CreateBranch(initialCommit, "refs/heads/side");
CheckoutBranch("refs/heads/side");
git.Rm().AddFilepattern("a").Call();
RevCommit secondCommit = git.Commit().SetMessage("side").Call();
// update a on master to generate conflict
CheckoutBranch("refs/heads/master");
WriteTrashFile("a", "1\na(main)\n3\n");
git.Add().AddFilepattern("a").Call();
git.Commit().SetMessage("main").Call();
// merge side with master
MergeCommandResult result = git.Merge().Include(secondCommit.Id).SetStrategy(MergeStrategy
.RESOLVE).Call();
NUnit.Framework.Assert.AreEqual(MergeStatus.CONFLICTING, result.GetMergeStatus());
FileTreeIterator iterator = new FileTreeIterator(db);
IndexDiff diff = new IndexDiff(db, Constants.HEAD, iterator);
diff.Diff();
NUnit.Framework.Assert.AreEqual("[]", new TreeSet<string>(diff.GetChanged()).ToString
());
NUnit.Framework.CollectionAssert.IsEmpty(diff.GetAdded());
NUnit.Framework.CollectionAssert.IsEmpty(diff.GetRemoved());
NUnit.Framework.CollectionAssert.IsEmpty(diff.GetMissing());
NUnit.Framework.CollectionAssert.IsEmpty(diff.GetModified());
NUnit.Framework.Assert.AreEqual("a", diff.GetConflicting().First ());
NUnit.Framework.Assert.AreEqual(1, diff.GetConflicting().Count ());
NUnit.Framework.CollectionAssert.IsEmpty(diff.GetUntrackedFolders()
);
}
示例13: TestRenamedBoundLineDelete
public virtual void TestRenamedBoundLineDelete()
{
Git git = new Git(db);
string FILENAME_1 = "subdir/file1.txt";
string FILENAME_2 = "subdir/file2.txt";
string[] content1 = new string[] { "first", "second" };
WriteTrashFile(FILENAME_1, Join(content1));
git.Add().AddFilepattern(FILENAME_1).Call();
RevCommit c1 = git.Commit().SetMessage("create file1").Call();
// rename it
WriteTrashFile(FILENAME_2, Join(content1));
git.Add().AddFilepattern(FILENAME_2).Call();
DeleteTrashFile(FILENAME_1);
git.Rm().AddFilepattern(FILENAME_1).Call();
git.Commit().SetMessage("rename file1.txt to file2.txt").Call();
// and change the new file
string[] content2 = new string[] { "third", "first", "second" };
WriteTrashFile(FILENAME_2, Join(content2));
git.Add().AddFilepattern(FILENAME_2).Call();
RevCommit c2 = git.Commit().SetMessage("change file2").Call();
BlameGenerator generator = new BlameGenerator(db, FILENAME_2);
try
{
generator.Push(null, db.Resolve(Constants.HEAD));
NUnit.Framework.Assert.AreEqual(3, generator.GetResultContents().Size());
NUnit.Framework.Assert.IsTrue(generator.Next());
NUnit.Framework.Assert.AreEqual(c2, generator.GetSourceCommit());
NUnit.Framework.Assert.AreEqual(1, generator.GetRegionLength());
NUnit.Framework.Assert.AreEqual(0, generator.GetResultStart());
NUnit.Framework.Assert.AreEqual(1, generator.GetResultEnd());
NUnit.Framework.Assert.AreEqual(0, generator.GetSourceStart());
NUnit.Framework.Assert.AreEqual(1, generator.GetSourceEnd());
NUnit.Framework.Assert.AreEqual(FILENAME_2, generator.GetSourcePath());
NUnit.Framework.Assert.IsTrue(generator.Next());
NUnit.Framework.Assert.AreEqual(c1, generator.GetSourceCommit());
NUnit.Framework.Assert.AreEqual(2, generator.GetRegionLength());
NUnit.Framework.Assert.AreEqual(1, generator.GetResultStart());
NUnit.Framework.Assert.AreEqual(3, generator.GetResultEnd());
NUnit.Framework.Assert.AreEqual(0, generator.GetSourceStart());
NUnit.Framework.Assert.AreEqual(2, generator.GetSourceEnd());
NUnit.Framework.Assert.AreEqual(FILENAME_1, generator.GetSourcePath());
NUnit.Framework.Assert.IsFalse(generator.Next());
}
finally
{
generator.Release();
}
// and test again with other BlameGenerator API:
generator = new BlameGenerator(db, FILENAME_2);
try
{
generator.Push(null, db.Resolve(Constants.HEAD));
BlameResult result = generator.ComputeBlameResult();
NUnit.Framework.Assert.AreEqual(3, result.GetResultContents().Size());
NUnit.Framework.Assert.AreEqual(c2, result.GetSourceCommit(0));
NUnit.Framework.Assert.AreEqual(FILENAME_2, result.GetSourcePath(0));
NUnit.Framework.Assert.AreEqual(c1, result.GetSourceCommit(1));
NUnit.Framework.Assert.AreEqual(FILENAME_1, result.GetSourcePath(1));
NUnit.Framework.Assert.AreEqual(c1, result.GetSourceCommit(2));
NUnit.Framework.Assert.AreEqual(FILENAME_1, result.GetSourcePath(2));
}
finally
{
generator.Release();
}
}
示例14: Prepare_f3_f2_14
/// <exception cref="System.Exception"></exception>
private void Prepare_f3_f2_14(Git git, int state, bool include_f2)
{
FilePath f2 = null;
if (include_f2)
{
f2 = WriteTrashFile(F2, "c2");
git.Add().AddFilepattern(F2).Call();
git.Commit().SetMessage(MSG).Call();
}
if (state >= 1)
{
WriteTrashFile(F3, "c3");
git.Add().AddFilepattern(F3).Call();
}
if (state >= 2)
{
git.Commit().SetMessage(MSG).Call();
}
if (state >= 3)
{
git.Rm().AddFilepattern(F3).Call();
}
if (state == 4)
{
WriteTrashFile(F3, "c3'");
git.Add().AddFilepattern(F3).Call();
}
if (include_f2)
{
Write(f2, "c2'");
git.Add().AddFilepattern(F2).Call();
Write(f2, "c2''");
}
}
示例15: Prepare_f1_3
/// <exception cref="System.Exception"></exception>
private FilePath Prepare_f1_3(Git git)
{
FilePath f1 = Prepare_f1_7(git);
git.Rm().AddFilepattern(F1).Call();
return f1;
}