public virtual void TestCherryPick() { Git git = new Git(db); WriteTrashFile("a", "first line\nsec. line\nthird line\n"); git.Add().AddFilepattern("a").Call(); RevCommit firstCommit = git.Commit().SetMessage("create a").Call(); WriteTrashFile("b", "content\n"); git.Add().AddFilepattern("b").Call(); git.Commit().SetMessage("create b").Call(); WriteTrashFile("a", "first line\nsec. line\nthird line\nfourth line\n"); git.Add().AddFilepattern("a").Call(); git.Commit().SetMessage("enlarged a").Call(); WriteTrashFile("a", "first line\nsecond line\nthird line\nfourth line\n"); git.Add().AddFilepattern("a").Call(); RevCommit fixingA = git.Commit().SetMessage("fixed a").Call(); git.BranchCreate().SetName("side").SetStartPoint(firstCommit).Call(); CheckoutBranch("refs/heads/side"); WriteTrashFile("a", "first line\nsec. line\nthird line\nfeature++\n"); git.Add().AddFilepattern("a").Call(); git.Commit().SetMessage("enhanced a").Call(); git.CherryPick().Include(fixingA).Call(); NUnit.Framework.Assert.IsFalse(new FilePath(db.WorkTree, "b").Exists()); CheckFile(new FilePath(db.WorkTree, "a"), "first line\nsecond line\nthird line\nfeature++\n" ); Iterator<RevCommit> history = git.Log().Call().Iterator(); NUnit.Framework.Assert.AreEqual("fixed a", history.Next().GetFullMessage()); NUnit.Framework.Assert.AreEqual("enhanced a", history.Next().GetFullMessage()); NUnit.Framework.Assert.AreEqual("create a", history.Next().GetFullMessage()); NUnit.Framework.Assert.IsFalse(history.HasNext()); }
public virtual void TestRevert() { Git git = new Git(db); WriteTrashFile("a", "first line\nsec. line\nthird line\n"); git.Add().AddFilepattern("a").Call(); git.Commit().SetMessage("create a").Call(); WriteTrashFile("b", "content\n"); git.Add().AddFilepattern("b").Call(); git.Commit().SetMessage("create b").Call(); WriteTrashFile("a", "first line\nsec. line\nthird line\nfourth line\n"); git.Add().AddFilepattern("a").Call(); git.Commit().SetMessage("enlarged a").Call(); WriteTrashFile("a", "first line\nsecond line\nthird line\nfourth line\n"); git.Add().AddFilepattern("a").Call(); RevCommit fixingA = git.Commit().SetMessage("fixed a").Call(); WriteTrashFile("b", "first line\n"); git.Add().AddFilepattern("b").Call(); git.Commit().SetMessage("fixed b").Call(); git.Revert().Include(fixingA).Call(); NUnit.Framework.Assert.IsTrue(new FilePath(db.WorkTree, "b").Exists()); CheckFile(new FilePath(db.WorkTree, "a"), "first line\nsec. line\nthird line\nfourth line\n" ); Iterator<RevCommit> history = git.Log().Call().Iterator(); RevCommit revertCommit = history.Next(); string expectedMessage = "Revert \"fixed a\"\n\n" + "This reverts commit " + fixingA .Id.GetName() + ".\n"; NUnit.Framework.Assert.AreEqual(expectedMessage, revertCommit.GetFullMessage()); NUnit.Framework.Assert.AreEqual("fixed b", history.Next().GetFullMessage()); NUnit.Framework.Assert.AreEqual("fixed a", history.Next().GetFullMessage()); NUnit.Framework.Assert.AreEqual("enlarged a", history.Next().GetFullMessage()); NUnit.Framework.Assert.AreEqual("create b", history.Next().GetFullMessage()); NUnit.Framework.Assert.AreEqual("create a", history.Next().GetFullMessage()); NUnit.Framework.Assert.IsFalse(history.HasNext()); }
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); }
public virtual void TestSomeCommits() { // do 4 commits Git git = new Git(db); git.Commit().SetMessage("initial commit").Call(); git.Commit().SetMessage("second commit").SetCommitter(committer).Call(); git.Commit().SetMessage("third commit").SetAuthor(author).Call(); git.Commit().SetMessage("fourth commit").SetAuthor(author).SetCommitter(committer ).Call(); Iterable<RevCommit> commits = git.Log().Call(); // check that all commits came in correctly PersonIdent defaultCommitter = new PersonIdent(db); PersonIdent[] expectedAuthors = new PersonIdent[] { defaultCommitter, committer, author, author }; PersonIdent[] expectedCommitters = new PersonIdent[] { defaultCommitter, committer , defaultCommitter, committer }; string[] expectedMessages = new string[] { "initial commit", "second commit", "third commit" , "fourth commit" }; int l = expectedAuthors.Length - 1; foreach (RevCommit c in commits) { NUnit.Framework.Assert.AreEqual(expectedAuthors[l].GetName(), c.GetAuthorIdent(). GetName()); NUnit.Framework.Assert.AreEqual(expectedCommitters[l].GetName(), c.GetCommitterIdent ().GetName()); NUnit.Framework.Assert.AreEqual(c.GetFullMessage(), expectedMessages[l]); l--; } NUnit.Framework.Assert.AreEqual(l, -1); ReflogReader reader = db.GetReflogReader(Constants.HEAD); NUnit.Framework.Assert.IsTrue(reader.GetLastEntry().GetComment().StartsWith("commit:" )); }
public virtual void ResolveUnnamedCurrentBranchCommits() { Git git = new Git(db); WriteTrashFile("file.txt", "content"); git.Add().AddFilepattern("file.txt").Call(); RevCommit c1 = git.Commit().SetMessage("create file").Call(); WriteTrashFile("file.txt", "content2"); git.Add().AddFilepattern("file.txt").Call(); RevCommit c2 = git.Commit().SetMessage("edit file").Call(); NUnit.Framework.Assert.AreEqual(c2, db.Resolve("master@{0}")); NUnit.Framework.Assert.AreEqual(c1, db.Resolve("master@{1}")); git.Checkout().SetCreateBranch(true).SetName("newbranch").SetStartPoint(c1).Call( ); // same as current branch, e.g. master NUnit.Framework.Assert.AreEqual(c1, db.Resolve("@{0}")); try { NUnit.Framework.Assert.AreEqual(c1, db.Resolve("@{1}")); NUnit.Framework.Assert.Fail(); } catch (RevisionSyntaxException e) { // Looking at wrong ref, e.g HEAD NUnit.Framework.Assert.IsNotNull(e); } // detached head, read HEAD reflog git.Checkout().SetName(c2.GetName()).Call(); NUnit.Framework.Assert.AreEqual(c2, db.Resolve("@{0}")); NUnit.Framework.Assert.AreEqual(c1, db.Resolve("@{1}")); NUnit.Framework.Assert.AreEqual(c2, db.Resolve("@{2}")); }
public virtual void TestLastModifiedTimes() { Git git = new Git(db); string path = "file"; WriteTrashFile(path, "content"); string path2 = "file2"; WriteTrashFile(path2, "content2"); git.Add().AddFilepattern(path).Call(); git.Add().AddFilepattern(path2).Call(); git.Commit().SetMessage("commit").Call(); DirCache dc = db.ReadDirCache(); DirCacheEntry entry = dc.GetEntry(path); DirCacheEntry entry2 = dc.GetEntry(path); NUnit.Framework.Assert.IsTrue(entry.LastModified != 0, "last modified shall not be zero!" ); NUnit.Framework.Assert.IsTrue(entry2.LastModified != 0, "last modified shall not be zero!" ); WriteTrashFile(path, "new content"); git.Add().AddFilepattern(path).Call(); git.Commit().SetMessage("commit2").Call(); dc = db.ReadDirCache(); entry = dc.GetEntry(path); entry2 = dc.GetEntry(path); NUnit.Framework.Assert.IsTrue(entry.LastModified != 0, "last modified shall not be zero!" ); NUnit.Framework.Assert.IsTrue(entry2.LastModified != 0, "last modified shall not be zero!" ); }
public virtual void TestTagging() { Git git = new Git(db); git.Commit().SetMessage("initial commit").Call(); RevCommit commit = git.Commit().SetMessage("second commit").Call(); git.Commit().SetMessage("third commit").Call(); RevTag tag = git.Tag().SetObjectId(commit).SetName("tag").Call(); NUnit.Framework.Assert.AreEqual(commit.Id, tag.GetObject().Id); }
public override void SetUp() { base.SetUp(); Git git = new Git(db); git.Commit().SetMessage("initial commit").Call(); WriteTrashFile("Test.txt", "Hello world"); git.Add().AddFilepattern("Test.txt").Call(); git.Commit().SetMessage("Initial commit").Call(); bareRepo = Git.CloneRepository().SetBare(true).SetURI(db.Directory.ToURI().ToString ()).SetDirectory(CreateUniqueTestGitDir(true)).Call().GetRepository(); }
public virtual void TestAlreadyUpToDate() { Git git = new Git(db); RevCommit first = git.Commit().SetMessage("initial commit").Call(); CreateBranch(first, "refs/heads/branch1"); RevCommit second = git.Commit().SetMessage("second commit").Call(); MergeCommandResult result = git.Merge().Include(db.GetRef("refs/heads/branch1")). Call(); NUnit.Framework.Assert.AreEqual(MergeStatus.ALREADY_UP_TO_DATE, result.GetMergeStatus ()); NUnit.Framework.Assert.AreEqual(second, result.GetNewHead()); }
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(); }
public virtual void ResolveMasterCommits() { Git git = new Git(db); WriteTrashFile("file.txt", "content"); git.Add().AddFilepattern("file.txt").Call(); RevCommit c1 = git.Commit().SetMessage("create file").Call(); WriteTrashFile("file.txt", "content2"); git.Add().AddFilepattern("file.txt").Call(); RevCommit c2 = git.Commit().SetMessage("edit file").Call(); NUnit.Framework.Assert.AreEqual(c2, db.Resolve("master@{0}")); NUnit.Framework.Assert.AreEqual(c1, db.Resolve("master@{1}")); }
/// <exception cref="System.IO.IOException"></exception> /// <exception cref="NGit.Api.Errors.NoFilepatternException"></exception> /// <exception cref="NGit.Api.Errors.NoHeadException"></exception> /// <exception cref="NGit.Api.Errors.NoMessageException"></exception> /// <exception cref="NGit.Api.Errors.ConcurrentRefUpdateException"></exception> /// <exception cref="NGit.Api.Errors.JGitInternalException"></exception> /// <exception cref="NGit.Api.Errors.WrongRepositoryStateException"></exception> public virtual void SetupRepository() { // create initial commit git = new Git(db); initialCommit = git.Commit().SetMessage("initial commit").Call(); // create file indexFile = new FilePath(db.WorkTree, "a.txt"); FileUtils.CreateNewFile(indexFile); PrintWriter writer = new PrintWriter(indexFile); writer.Write("content"); writer.Flush(); // add file and commit it git.Add().AddFilepattern("a.txt").Call(); secondCommit = git.Commit().SetMessage("adding a.txt").Call(); prestage = DirCache.Read(db.GetIndexFile(), db.FileSystem).GetEntry(indexFile.GetName ()); // modify file and add to index writer.Write("new content"); writer.Close(); git.Add().AddFilepattern("a.txt").Call(); // create a file not added to the index untrackedFile = new FilePath(db.WorkTree, "notAddedToIndex.txt"); FileUtils.CreateNewFile(untrackedFile); PrintWriter writer2 = new PrintWriter(untrackedFile); writer2.Write("content"); writer2.Close(); }
public virtual void CommitAfterSquashMerge() { Git git = new Git(db); WriteTrashFile("file1", "file1"); git.Add().AddFilepattern("file1").Call(); RevCommit first = git.Commit().SetMessage("initial commit").Call(); NUnit.Framework.Assert.IsTrue(new FilePath(db.WorkTree, "file1").Exists()); CreateBranch(first, "refs/heads/branch1"); CheckoutBranch("refs/heads/branch1"); WriteTrashFile("file2", "file2"); git.Add().AddFilepattern("file2").Call(); git.Commit().SetMessage("second commit").Call(); NUnit.Framework.Assert.IsTrue(new FilePath(db.WorkTree, "file2").Exists()); CheckoutBranch("refs/heads/master"); MergeCommandResult result = git.Merge().Include(db.GetRef("branch1")).SetSquash(true ).Call(); NUnit.Framework.Assert.IsTrue(new FilePath(db.WorkTree, "file1").Exists()); NUnit.Framework.Assert.IsTrue(new FilePath(db.WorkTree, "file2").Exists()); NUnit.Framework.Assert.AreEqual(MergeStatus.FAST_FORWARD_SQUASHED, result.GetMergeStatus ()); // comment not set, should be inferred from SQUASH_MSG RevCommit squashedCommit = git.Commit().Call(); NUnit.Framework.Assert.AreEqual(1, squashedCommit.ParentCount); NUnit.Framework.Assert.IsNull(db.ReadSquashCommitMsg()); NUnit.Framework.Assert.AreEqual("commit: Squashed commit of the following:", db.GetReflogReader (Constants.HEAD).GetLastEntry().GetComment()); NUnit.Framework.Assert.AreEqual("commit: Squashed commit of the following:", db.GetReflogReader (db.GetBranch()).GetLastEntry().GetComment()); }
public virtual void TestAddUnstagedChanges() { FilePath file = new FilePath(db.WorkTree, "a.txt"); FileUtils.CreateNewFile(file); PrintWriter writer = new PrintWriter(file); writer.Write("content"); writer.Close(); Git git = new Git(db); git.Add().AddFilepattern("a.txt").Call(); RevCommit commit = git.Commit().SetMessage("initial commit").Call(); TreeWalk tw = TreeWalk.ForPath(db, "a.txt", commit.Tree); NUnit.Framework.Assert.AreEqual("6b584e8ece562ebffc15d38808cd6b98fc3d97ea", tw.GetObjectId (0).GetName()); writer = new PrintWriter(file); writer.Write("content2"); writer.Close(); commit = git.Commit().SetMessage("second commit").Call(); tw = TreeWalk.ForPath(db, "a.txt", commit.Tree); NUnit.Framework.Assert.AreEqual("6b584e8ece562ebffc15d38808cd6b98fc3d97ea", tw.GetObjectId (0).GetName()); commit = git.Commit().SetAll(true).SetMessage("third commit").SetAll(true).Call(); tw = TreeWalk.ForPath(db, "a.txt", commit.Tree); NUnit.Framework.Assert.AreEqual("db00fd65b218578127ea51f3dffac701f12f486a", tw.GetObjectId (0).GetName()); }
public virtual void TestPush() { // create other repository Repository db2 = CreateWorkRepository(); // setup the first repository StoredConfig config = ((FileBasedConfig)db.GetConfig()); RemoteConfig remoteConfig = new RemoteConfig(config, "test"); URIish uri = new URIish(db2.Directory.ToURI().ToURL()); remoteConfig.AddURI(uri); remoteConfig.Update(config); config.Save(); Git git1 = new Git(db); // create some refs via commits and tag RevCommit commit = git1.Commit().SetMessage("initial commit").Call(); Ref tagRef = git1.Tag().SetName("tag").Call(); try { db2.Resolve(commit.Id.GetName() + "^{commit}"); NUnit.Framework.Assert.Fail("id shouldn't exist yet"); } catch (MissingObjectException) { } // we should get here RefSpec spec = new RefSpec("refs/heads/master:refs/heads/x"); git1.Push().SetRemote("test").SetRefSpecs(spec).Call(); NUnit.Framework.Assert.AreEqual(commit.Id, db2.Resolve(commit.Id.GetName() + "^{commit}" )); NUnit.Framework.Assert.AreEqual(tagRef.GetObjectId(), db2.Resolve(tagRef.GetObjectId ().GetName())); }
private static void DoCommit(Git repository, string message) { var commit = repository.Commit(); commit.SetAuthor(GitHub.Username, "*****@*****.**"); commit.SetMessage(message); commit.SetAll(true); commit.Call(); }
public override void SetUp() { base.SetUp(); git = new Git(db); WriteTrashFile(FILE1, "1"); WriteTrashFile(FILE2, "a"); git.Add().AddFilepattern(FILE1).AddFilepattern(FILE2).Call(); initialCommit = git.Commit().SetMessage("Initial commit").Call(); WriteTrashFile(FILE1, "2"); WriteTrashFile(FILE2, "b"); git.Add().AddFilepattern(FILE1).AddFilepattern(FILE2).Call(); secondCommit = git.Commit().SetMessage("Second commit").Call(); WriteTrashFile(FILE1, "3"); WriteTrashFile(FILE2, "c"); git.Add().AddFilepattern(FILE1).AddFilepattern(FILE2).Call(); git.Commit().SetMessage("Third commit").Call(); }
public virtual void TestMergeInItself() { Git git = new Git(db); git.Commit().SetMessage("initial commit").Call(); MergeCommandResult result = git.Merge().Include(db.GetRef(Constants.HEAD)).Call(); NUnit.Framework.Assert.AreEqual(MergeStatus.ALREADY_UP_TO_DATE, result.GetMergeStatus ()); }
public override void SetUp() { base.SetUp(); git = new Git(db); // commit something WriteTrashFile("Test.txt", "Hello world"); git.Add().AddFilepattern("Test.txt").Call(); initialCommit = git.Commit().SetMessage("Initial commit").Call(); // create a master branch and switch to it git.BranchCreate().SetName("test").Call(); RefUpdate rup = db.UpdateRef(Constants.HEAD); rup.Link("refs/heads/test"); // commit something on the test branch WriteTrashFile("Test.txt", "Some change"); git.Add().AddFilepattern("Test.txt").Call(); secondCommit = git.Commit().SetMessage("Second commit").Call(); }
public override void SetUp() { base.SetUp(); git = Git.Wrap(db); committedFile = WriteTrashFile(PATH, "content"); git.Add().AddFilepattern(PATH).Call(); head = git.Commit().SetMessage("add file").Call(); NUnit.Framework.Assert.IsNotNull(head); }
public override void SetUp() { base.SetUp(); git = new Git(db); // commit something WriteTrashFile(FILE, "Hello world"); git.Add().AddFilepattern(FILE).Call(); git.Commit().SetMessage("Initial commit").Call(); }
public virtual void TestTaggingOnHead() { Git git = new Git(db); RevCommit commit = git.Commit().SetMessage("initial commit").Call(); Ref tagRef = git.Tag().SetName("tag").Call(); NUnit.Framework.Assert.AreEqual(commit.Id, db.Peel(tagRef).GetPeeledObjectId()); RevWalk walk = new RevWalk(db); NUnit.Framework.Assert.AreEqual("tag", walk.ParseTag(tagRef.GetObjectId()).GetTagName ()); }
public override void SetUp() { base.SetUp(); git = new Git(db); // checkout master git.Commit().SetMessage("initial commit").Call(); // commit something WriteTrashFile("Test.txt", "Hello world"); git.Add().AddFilepattern("Test.txt").Call(); initialCommit = git.Commit().SetMessage("Initial commit").Call(); WriteTrashFile("Test.txt", "Some change"); git.Add().AddFilepattern("Test.txt").Call(); secondCommit = git.Commit().SetMessage("Second commit").Call(); // create a master branch RefUpdate rup = db.UpdateRef("refs/heads/master"); rup.SetNewObjectId(initialCommit.Id); rup.SetForceUpdate(true); rup.Update(); }
/// <exception cref="System.Exception"></exception> public override void SetUp() { base.SetUp(); tr = new TestRepository<Repository>(db); git = new Git(db); // commit something WriteTrashFile("Test.txt", "Hello world"); git.Add().AddFilepattern("Test.txt").Call(); git.Commit().SetMessage("Initial commit").Call(); // create a master branch and switch to it git.BranchCreate().SetName("test").Call(); RefUpdate rup = db.UpdateRef(Constants.HEAD); rup.Link("refs/heads/test"); // commit something on the test branch WriteTrashFile("Test.txt", "Some change"); git.Add().AddFilepattern("Test.txt").Call(); git.Commit().SetMessage("Second commit").Call(); RevBlob blob = tr.Blob("blob-not-in-master-branch"); git.Tag().SetName("tag-for-blob").SetObjectId(blob).Call(); }
public virtual void TestCommit() { Git git = new Git(db); revCommit = git.Commit().SetMessage("squash_me").Call(); Ref master = db.GetRef("refs/heads/master"); string message = msgFormatter.Format(Arrays.AsList(revCommit), master); NUnit.Framework.Assert.AreEqual("Squashed commit of the following:\n\ncommit " + revCommit.GetName() + "\nAuthor: " + revCommit.GetAuthorIdent().GetName() + " <" + revCommit.GetAuthorIdent().GetEmailAddress() + ">\nDate: " + dateFormatter. FormatDate(author) + "\n\n\tsquash_me\n", message); }
public override void SetUp() { base.SetUp(); git = new Git(db); // create test files WriteTrashFile("File1.txt", "Hello world"); WriteTrashFile("File2.txt", "Delete Me"); WriteTrashFile("File3.txt", "Delete Me"); // add and commit first file git.Add().AddFilepattern("File1.txt").Call(); git.Commit().SetMessage("Initial commit").Call(); }
/// <exception cref="System.Exception"></exception> public virtual void Setup(int count) { Git git = new Git(db); for (int i = 0; i < count; i++) { git.Commit().SetCommitter(committer).SetAuthor(author).SetMessage("commit " + i). Call(); } list = new RevCommitList<RevCommit>(); RevWalk w = new RevWalk(db); w.MarkStart(w.LookupCommit(db.Resolve(Constants.HEAD))); list.Source(w); }
public virtual void TestMergeInItself() { Git git = new Git(db); git.Commit().SetMessage("initial commit").Call(); MergeCommandResult result = git.Merge().Include(db.GetRef(Constants.HEAD)).Call(); NUnit.Framework.Assert.AreEqual(MergeStatus.ALREADY_UP_TO_DATE, result.GetMergeStatus ()); // no reflog entry written by merge NUnit.Framework.Assert.AreEqual("commit: initial commit", db.GetReflogReader(Constants .HEAD).GetLastEntry().GetComment()); NUnit.Framework.Assert.AreEqual("commit: initial commit", db.GetReflogReader(db.GetBranch ()).GetLastEntry().GetComment()); }
public virtual void TestBoundLineDelete() { Git git = new Git(db); string[] content1 = new string[] { "first", "second" }; WriteTrashFile("file.txt", Join(content1)); git.Add().AddFilepattern("file.txt").Call(); RevCommit c1 = git.Commit().SetMessage("create file").Call(); string[] content2 = new string[] { "third", "first", "second" }; WriteTrashFile("file.txt", Join(content2)); git.Add().AddFilepattern("file.txt").Call(); RevCommit c2 = git.Commit().SetMessage("create file").Call(); BlameGenerator generator = new BlameGenerator(db, "file.txt"); 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("file.txt", 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("file.txt", generator.GetSourcePath()); NUnit.Framework.Assert.IsFalse(generator.Next()); } finally { generator.Release(); } }
public virtual void TestDifferentStates() { Git git = new Git(db); WriteTrashFile("a", "content of a"); WriteTrashFile("b", "content of b"); WriteTrashFile("c", "content of c"); git.Add().AddFilepattern("a").AddFilepattern("b").Call(); Status stat = git.Status().Call(); NUnit.Framework.Assert.AreEqual(Set("a", "b"), Set (stat.GetAdded())); NUnit.Framework.Assert.AreEqual(0, stat.GetChanged().Count); NUnit.Framework.Assert.AreEqual(0, stat.GetMissing().Count); NUnit.Framework.Assert.AreEqual(0, stat.GetModified().Count); NUnit.Framework.Assert.AreEqual(0, stat.GetRemoved().Count); NUnit.Framework.Assert.AreEqual(Set("c"), Set (stat.GetUntracked())); git.Commit().SetMessage("initial").Call(); WriteTrashFile("a", "modified content of a"); WriteTrashFile("b", "modified content of b"); WriteTrashFile("d", "content of d"); git.Add().AddFilepattern("a").AddFilepattern("d").Call(); WriteTrashFile("a", "again modified content of a"); stat = git.Status().Call(); NUnit.Framework.Assert.AreEqual(Set("d"), Set (stat.GetAdded())); NUnit.Framework.Assert.AreEqual(Set("a"), Set (stat.GetChanged())); NUnit.Framework.Assert.AreEqual(0, stat.GetMissing().Count); NUnit.Framework.Assert.AreEqual(Set("b", "a"), Set (stat.GetModified())); NUnit.Framework.Assert.AreEqual(0, stat.GetRemoved().Count); NUnit.Framework.Assert.AreEqual(Set("c"), Set (stat.GetUntracked())); git.Add().AddFilepattern(".").Call(); git.Commit().SetMessage("second").Call(); stat = git.Status().Call(); NUnit.Framework.Assert.AreEqual(0, stat.GetAdded().Count); NUnit.Framework.Assert.AreEqual(0, stat.GetChanged().Count); NUnit.Framework.Assert.AreEqual(0, stat.GetMissing().Count); NUnit.Framework.Assert.AreEqual(0, stat.GetModified().Count); NUnit.Framework.Assert.AreEqual(0, stat.GetRemoved().Count); NUnit.Framework.Assert.AreEqual(0, stat.GetUntracked().Count); DeleteTrashFile("a"); NUnit.Framework.Assert.IsFalse(new FilePath(git.GetRepository().WorkTree, "a").Exists ()); git.Add().AddFilepattern("a").SetUpdate(true).Call(); WriteTrashFile("a", "recreated content of a"); stat = git.Status().Call(); NUnit.Framework.Assert.AreEqual(0, stat.GetAdded().Count); NUnit.Framework.Assert.AreEqual(0, stat.GetChanged().Count); NUnit.Framework.Assert.AreEqual(0, stat.GetMissing().Count); NUnit.Framework.Assert.AreEqual(0, stat.GetModified().Count); NUnit.Framework.Assert.AreEqual(Set("a"), Set (stat.GetRemoved())); NUnit.Framework.Assert.AreEqual(Set("a"), Set (stat.GetUntracked())); git.Commit().SetMessage("t").Call(); }
public virtual void TestPathsResetWithUnmerged() { SetupRepository(); string file = "a.txt"; WriteTrashFile(file, "data"); git.Add().AddFilepattern(file).Call(); git.Commit().SetMessage("commit").Call(); DirCache index = db.LockDirCache(); DirCacheBuilder builder = index.Builder(); builder.Add(CreateEntry(file, FileMode.REGULAR_FILE, 1, string.Empty)); builder.Add(CreateEntry(file, FileMode.REGULAR_FILE, 2, string.Empty)); builder.Add(CreateEntry(file, FileMode.REGULAR_FILE, 3, string.Empty)); builder.Add(CreateEntry("b.txt", FileMode.REGULAR_FILE)); NUnit.Framework.Assert.IsTrue(builder.Commit()); NUnit.Framework.Assert.AreEqual("[a.txt, mode:100644, stage:1]" + "[a.txt, mode:100644, stage:2]" + "[a.txt, mode:100644, stage:3]" + "[b.txt, mode:100644]", IndexState(0)); git.Reset().AddPath(file).Call(); NUnit.Framework.Assert.AreEqual("[a.txt, mode:100644]" + "[b.txt, mode:100644]", IndexState(0)); }
public virtual void TestPushWithRefSpecFromConfig() { Git git = new Git(db); Git git2 = new Git(CreateBareRepository()); StoredConfig config = git.GetRepository().GetConfig(); RemoteConfig remoteConfig = new RemoteConfig(config, "test"); URIish uri = new URIish(git2.GetRepository().Directory.ToURI().ToURL()); remoteConfig.AddURI(uri); remoteConfig.AddPushRefSpec(new RefSpec("HEAD:refs/heads/newbranch")); remoteConfig.Update(config); config.Save(); WriteTrashFile("f", "content of f"); git.Add().AddFilepattern("f").Call(); RevCommit commit = git.Commit().SetMessage("adding f").Call(); NUnit.Framework.Assert.AreEqual(null, git2.GetRepository().Resolve("refs/heads/master" )); git.Push().SetRemote("test").Call(); NUnit.Framework.Assert.AreEqual(commit.Id, git2.GetRepository().Resolve("refs/heads/newbranch" )); }
public virtual void TestFetch() { // create other repository Repository db2 = CreateWorkRepository(); Git git2 = new Git(db2); // setup the first repository to fetch from the second repository StoredConfig config = ((FileBasedConfig)db.GetConfig()); RemoteConfig remoteConfig = new RemoteConfig(config, "test"); URIish uri = new URIish(db2.Directory.ToURI().ToURL()); remoteConfig.AddURI(uri); remoteConfig.Update(config); config.Save(); // create some refs via commits and tag RevCommit commit = git2.Commit().SetMessage("initial commit").Call(); RevTag tag = git2.Tag().SetName("tag").Call(); Git git1 = new Git(db); RefSpec spec = new RefSpec("refs/heads/master:refs/heads/x"); git1.Fetch().SetRemote("test").SetRefSpecs(spec).Call(); NUnit.Framework.Assert.AreEqual(commit.Id, db.Resolve(commit.Id.GetName() + "^{commit}" )); NUnit.Framework.Assert.AreEqual(tag.Id, db.Resolve(tag.Id.GetName())); }
public virtual void TestMixedResetWithUnmerged() { git = new Git(db); string file = "a.txt"; WriteTrashFile(file, "data"); string file2 = "b.txt"; WriteTrashFile(file2, "data"); git.Add().AddFilepattern(file).AddFilepattern(file2).Call(); git.Commit().SetMessage("commit").Call(); DirCache index = db.LockDirCache(); DirCacheBuilder builder = index.Builder(); builder.Add(CreateEntry(file, FileMode.REGULAR_FILE, 1, string.Empty)); builder.Add(CreateEntry(file, FileMode.REGULAR_FILE, 2, string.Empty)); builder.Add(CreateEntry(file, FileMode.REGULAR_FILE, 3, string.Empty)); NUnit.Framework.Assert.IsTrue(builder.Commit()); NUnit.Framework.Assert.AreEqual("[a.txt, mode:100644, stage:1]" + "[a.txt, mode:100644, stage:2]" + "[a.txt, mode:100644, stage:3]", IndexState(0)); git.Reset().SetMode(ResetCommand.ResetType.MIXED).Call(); NUnit.Framework.Assert.AreEqual("[a.txt, mode:100644]" + "[b.txt, mode:100644]", IndexState(0)); }
/// <exception cref="System.Exception"></exception> private RevCommit AddAllAndCommit(Git git) { git.Add().AddFilepattern(".").Call(); return(git.Commit().SetMessage("message").Call()); }
public virtual void TestFastForwardWithNewFile() { // create file1 on master WriteTrashFile(FILE1, FILE1); git.Add().AddFilepattern(FILE1).Call(); RevCommit first = git.Commit().SetMessage("Add file1").Call(); NUnit.Framework.Assert.IsTrue(new FilePath(db.WorkTree, FILE1).Exists()); // create a topic branch CreateBranch(first, "refs/heads/topic"); // create file2 on master FilePath file2 = WriteTrashFile("file2", "file2"); git.Add().AddFilepattern("file2").Call(); git.Commit().SetMessage("Add file2").Call(); NUnit.Framework.Assert.IsTrue(new FilePath(db.WorkTree, "file2").Exists()); CheckoutBranch("refs/heads/topic"); NUnit.Framework.Assert.IsFalse(new FilePath(db.WorkTree, "file2").Exists()); RebaseResult res = git.Rebase().SetUpstream("refs/heads/master").Call(); NUnit.Framework.Assert.IsTrue(new FilePath(db.WorkTree, "file2").Exists()); CheckFile(file2, "file2"); NUnit.Framework.Assert.AreEqual(RebaseResult.Status.FAST_FORWARD, res.GetStatus() ); }
public virtual void TestAddHugeFile() { Measure("Commencing test"); FilePath file = new FilePath(db.WorkTree, "a.txt"); RandomAccessFile rf = new RandomAccessFile(file, "rw"); rf.SetLength(4429185024L); rf.Close(); Measure("Created file"); Git git = new Git(db); git.Add().AddFilepattern("a.txt").Call(); Measure("Added file"); NUnit.Framework.Assert.AreEqual("[a.txt, mode:100644, length:134217728, sha1:b8cfba97c2b962a44f080b3ca4e03b3204b6a350]" , IndexState(LENGTH | CONTENT_ID)); Status status = git.Status().Call(); Measure("Status after add"); AssertCollectionEquals(Arrays.AsList("a.txt"), status.GetAdded()); NUnit.Framework.Assert.AreEqual(0, status.GetChanged().Count); NUnit.Framework.Assert.AreEqual(0, status.GetConflicting().Count); NUnit.Framework.Assert.AreEqual(0, status.GetMissing().Count); NUnit.Framework.Assert.AreEqual(0, status.GetModified().Count); NUnit.Framework.Assert.AreEqual(0, status.GetRemoved().Count); NUnit.Framework.Assert.AreEqual(0, status.GetUntracked().Count); // Does not change anything, but modified timestamp rf = new RandomAccessFile(file, "rw"); rf.Write(0); rf.Close(); status = git.Status().Call(); Measure("Status after non-modifying update"); AssertCollectionEquals(Arrays.AsList("a.txt"), status.GetAdded()); NUnit.Framework.Assert.AreEqual(0, status.GetChanged().Count); NUnit.Framework.Assert.AreEqual(0, status.GetConflicting().Count); NUnit.Framework.Assert.AreEqual(0, status.GetMissing().Count); NUnit.Framework.Assert.AreEqual(0, status.GetModified().Count); NUnit.Framework.Assert.AreEqual(0, status.GetRemoved().Count); NUnit.Framework.Assert.AreEqual(0, status.GetUntracked().Count); // Change something rf = new RandomAccessFile(file, "rw"); rf.Write('a'); rf.Close(); status = git.Status().Call(); Measure("Status after modifying update"); AssertCollectionEquals(Arrays.AsList("a.txt"), status.GetAdded()); NUnit.Framework.Assert.AreEqual(0, status.GetChanged().Count); NUnit.Framework.Assert.AreEqual(0, status.GetConflicting().Count); NUnit.Framework.Assert.AreEqual(0, status.GetMissing().Count); AssertCollectionEquals(Arrays.AsList("a.txt"), status.GetModified()); NUnit.Framework.Assert.AreEqual(0, status.GetRemoved().Count); NUnit.Framework.Assert.AreEqual(0, status.GetUntracked().Count); // Truncate mod 4G and re-establish equality rf = new RandomAccessFile(file, "rw"); rf.SetLength(134217728L); rf.Write(0); rf.Close(); status = git.Status().Call(); Measure("Status after truncating update"); AssertCollectionEquals(Arrays.AsList("a.txt"), status.GetAdded()); NUnit.Framework.Assert.AreEqual(0, status.GetChanged().Count); NUnit.Framework.Assert.AreEqual(0, status.GetConflicting().Count); NUnit.Framework.Assert.AreEqual(0, status.GetMissing().Count); AssertCollectionEquals(Arrays.AsList("a.txt"), status.GetModified()); NUnit.Framework.Assert.AreEqual(0, status.GetRemoved().Count); NUnit.Framework.Assert.AreEqual(0, status.GetUntracked().Count); // Change something rf = new RandomAccessFile(file, "rw"); rf.Write('a'); rf.Close(); status = git.Status().Call(); Measure("Status after modifying and truncating update"); AssertCollectionEquals(Arrays.AsList("a.txt"), status.GetAdded()); NUnit.Framework.Assert.AreEqual(0, status.GetChanged().Count); NUnit.Framework.Assert.AreEqual(0, status.GetConflicting().Count); NUnit.Framework.Assert.AreEqual(0, status.GetMissing().Count); AssertCollectionEquals(Arrays.AsList("a.txt"), status.GetModified()); NUnit.Framework.Assert.AreEqual(0, status.GetRemoved().Count); NUnit.Framework.Assert.AreEqual(0, status.GetUntracked().Count); // Truncate to entry length becomes negative int rf = new RandomAccessFile(file, "rw"); rf.SetLength(3429185024L); rf.Write(0); rf.Close(); git.Add().AddFilepattern("a.txt").Call(); Measure("Added truncated file"); NUnit.Framework.Assert.AreEqual("[a.txt, mode:100644, length:-865782272, sha1:59b3282f8f59f22d953df956ad3511bf2dc660fd]" , IndexState(LENGTH | CONTENT_ID)); status = git.Status().Call(); Measure("Status after status on truncated file"); AssertCollectionEquals(Arrays.AsList("a.txt"), status.GetAdded()); NUnit.Framework.Assert.AreEqual(0, status.GetChanged().Count); NUnit.Framework.Assert.AreEqual(0, status.GetConflicting().Count); NUnit.Framework.Assert.AreEqual(0, status.GetMissing().Count); NUnit.Framework.Assert.AreEqual(0, status.GetModified().Count); NUnit.Framework.Assert.AreEqual(0, status.GetRemoved().Count); NUnit.Framework.Assert.AreEqual(0, status.GetUntracked().Count); // Change something rf = new RandomAccessFile(file, "rw"); rf.Write('a'); rf.Close(); status = git.Status().Call(); Measure("Status after modifying and truncating update"); AssertCollectionEquals(Arrays.AsList("a.txt"), status.GetAdded()); NUnit.Framework.Assert.AreEqual(0, status.GetChanged().Count); NUnit.Framework.Assert.AreEqual(0, status.GetConflicting().Count); NUnit.Framework.Assert.AreEqual(0, status.GetMissing().Count); AssertCollectionEquals(Arrays.AsList("a.txt"), status.GetModified()); NUnit.Framework.Assert.AreEqual(0, status.GetRemoved().Count); NUnit.Framework.Assert.AreEqual(0, status.GetUntracked().Count); git.Commit().SetMessage("make a commit").Call(); Measure("After commit"); status = git.Status().Call(); Measure("After status after commit"); NUnit.Framework.Assert.AreEqual(0, status.GetAdded().Count); NUnit.Framework.Assert.AreEqual(0, status.GetChanged().Count); NUnit.Framework.Assert.AreEqual(0, status.GetConflicting().Count); NUnit.Framework.Assert.AreEqual(0, status.GetMissing().Count); AssertCollectionEquals(Arrays.AsList("a.txt"), status.GetModified()); NUnit.Framework.Assert.AreEqual(0, status.GetRemoved().Count); NUnit.Framework.Assert.AreEqual(0, status.GetUntracked().Count); git.Reset().SetMode(ResetCommand.ResetType.HARD).Call(); Measure("After reset --hard"); NUnit.Framework.Assert.AreEqual("[a.txt, mode:100644, length:-865782272, sha1:59b3282f8f59f22d953df956ad3511bf2dc660fd]" , IndexState(LENGTH | CONTENT_ID)); status = git.Status().Call(); Measure("Status after hard reset"); NUnit.Framework.Assert.AreEqual(0, status.GetAdded().Count); NUnit.Framework.Assert.AreEqual(0, status.GetChanged().Count); NUnit.Framework.Assert.AreEqual(0, status.GetConflicting().Count); NUnit.Framework.Assert.AreEqual(0, status.GetMissing().Count); NUnit.Framework.Assert.AreEqual(0, status.GetModified().Count); NUnit.Framework.Assert.AreEqual(0, status.GetRemoved().Count); NUnit.Framework.Assert.AreEqual(0, status.GetUntracked().Count); }
public virtual void TestCloneRepositoryWithNestedSubmodules() { git.Checkout().SetName(Constants.MASTER).Call(); // Create submodule 1 FilePath submodule1 = CreateTempDirectory("testCloneRepositoryWithNestedSubmodules1" ); Git sub1Git = Git.Init().SetDirectory(submodule1).Call(); NUnit.Framework.Assert.IsNotNull(sub1Git); Repository sub1 = sub1Git.GetRepository(); NUnit.Framework.Assert.IsNotNull(sub1); AddRepoToClose(sub1); string file = "file.txt"; string path = "sub"; Write(new FilePath(sub1.WorkTree, file), "content"); sub1Git.Add().AddFilepattern(file).Call(); RevCommit commit = sub1Git.Commit().SetMessage("create file").Call(); NUnit.Framework.Assert.IsNotNull(commit); // Create submodule 2 FilePath submodule2 = CreateTempDirectory("testCloneRepositoryWithNestedSubmodules2" ); Git sub2Git = Git.Init().SetDirectory(submodule2).Call(); NUnit.Framework.Assert.IsNotNull(sub2Git); Repository sub2 = sub2Git.GetRepository(); NUnit.Framework.Assert.IsNotNull(sub2); AddRepoToClose(sub2); Write(new FilePath(sub2.WorkTree, file), "content"); sub2Git.Add().AddFilepattern(file).Call(); RevCommit sub2Head = sub2Git.Commit().SetMessage("create file").Call(); NUnit.Framework.Assert.IsNotNull(sub2Head); // Add submodule 2 to submodule 1 Repository r = sub1Git.SubmoduleAdd().SetPath(path).SetURI(sub2.Directory.ToURI() .ToString()).Call(); NUnit.Framework.Assert.IsNotNull(r); AddRepoToClose(r); RevCommit sub1Head = sub1Git.Commit().SetAll(true).SetMessage("Adding submodule") .Call(); NUnit.Framework.Assert.IsNotNull(sub1Head); // Add submodule 1 to default repository r = git.SubmoduleAdd().SetPath(path).SetURI(sub1.Directory.ToURI().ToString()).Call (); NUnit.Framework.Assert.IsNotNull(r); AddRepoToClose(r); NUnit.Framework.Assert.IsNotNull(git.Commit().SetAll(true).SetMessage("Adding submodule" ).Call()); // Clone default repository and include submodules FilePath directory = CreateTempDirectory("testCloneRepositoryWithNestedSubmodules" ); CloneCommand clone = Git.CloneRepository(); clone.SetDirectory(directory); clone.SetCloneSubmodules(true); clone.SetURI(git.GetRepository().Directory.ToURI().ToString()); Git git2 = clone.Call(); AddRepoToClose(git2.GetRepository()); NUnit.Framework.Assert.IsNotNull(git2); NUnit.Framework.Assert.AreEqual(Constants.MASTER, git2.GetRepository().GetBranch( )); NUnit.Framework.Assert.IsTrue(new FilePath(git2.GetRepository().WorkTree, path + FilePath.separatorChar + file).Exists()); NUnit.Framework.Assert.IsTrue(new FilePath(git2.GetRepository().WorkTree, path + FilePath.separatorChar + path + FilePath.separatorChar + file).Exists()); SubmoduleStatusCommand status = new SubmoduleStatusCommand(git2.GetRepository()); IDictionary <string, SubmoduleStatus> statuses = status.Call(); SubmoduleStatus pathStatus = statuses.Get(path); NUnit.Framework.Assert.IsNotNull(pathStatus); NUnit.Framework.Assert.AreEqual(SubmoduleStatusType.INITIALIZED, pathStatus.GetType ()); NUnit.Framework.Assert.AreEqual(sub1Head, pathStatus.GetHeadId()); NUnit.Framework.Assert.AreEqual(sub1Head, pathStatus.GetIndexId()); SubmoduleWalk walk = SubmoduleWalk.ForIndex(git2.GetRepository()); NUnit.Framework.Assert.IsTrue(walk.Next()); Repository clonedSub1 = walk.GetRepository(); AddRepoToClose(clonedSub1); NUnit.Framework.Assert.IsNotNull(clonedSub1); status = new SubmoduleStatusCommand(clonedSub1); statuses = status.Call(); pathStatus = statuses.Get(path); NUnit.Framework.Assert.IsNotNull(pathStatus); NUnit.Framework.Assert.AreEqual(SubmoduleStatusType.INITIALIZED, pathStatus.GetType ()); NUnit.Framework.Assert.AreEqual(sub2Head, pathStatus.GetHeadId()); NUnit.Framework.Assert.AreEqual(sub2Head, pathStatus.GetIndexId()); NUnit.Framework.Assert.IsFalse(walk.Next()); }
public virtual void CommitSubmoduleUpdate() { Git git = new Git(db); WriteTrashFile("file.txt", "content"); git.Add().AddFilepattern("file.txt").Call(); RevCommit commit = git.Commit().SetMessage("create file").Call(); WriteTrashFile("file.txt", "content2"); git.Add().AddFilepattern("file.txt").Call(); RevCommit commit2 = git.Commit().SetMessage("edit file").Call(); SubmoduleAddCommand command = new SubmoduleAddCommand(db); string path = "sub"; command.SetPath(path); string uri = db.Directory.ToURI().ToString(); command.SetURI(uri); Repository repo = command.Call(); NUnit.Framework.Assert.IsNotNull(repo); AddRepoToClose(repo); SubmoduleWalk generator = SubmoduleWalk.ForIndex(db); NUnit.Framework.Assert.IsTrue(generator.Next()); NUnit.Framework.Assert.AreEqual(path, generator.GetPath()); NUnit.Framework.Assert.AreEqual(commit2, generator.GetObjectId()); NUnit.Framework.Assert.AreEqual(uri, generator.GetModulesUrl()); NUnit.Framework.Assert.AreEqual(path, generator.GetModulesPath()); NUnit.Framework.Assert.AreEqual(uri, generator.GetConfigUrl()); Repository subModRepo = generator.GetRepository(); AddRepoToClose(subModRepo); NUnit.Framework.Assert.IsNotNull(subModRepo); NUnit.Framework.Assert.AreEqual(commit2, repo.Resolve(Constants.HEAD)); RevCommit submoduleAddCommit = git.Commit().SetMessage("submodule add").SetOnly(path ).Call(); NUnit.Framework.Assert.IsNotNull(submoduleAddCommit); RefUpdate update = repo.UpdateRef(Constants.HEAD); update.SetNewObjectId(commit); NUnit.Framework.Assert.AreEqual(RefUpdate.Result.FORCED, update.ForceUpdate()); RevCommit submoduleEditCommit = git.Commit().SetMessage("submodule add").SetOnly( path).Call(); NUnit.Framework.Assert.IsNotNull(submoduleEditCommit); TreeWalk walk = new TreeWalk(db); walk.AddTree(submoduleAddCommit.Tree); walk.AddTree(submoduleEditCommit.Tree); walk.Filter = TreeFilter.ANY_DIFF; IList <DiffEntry> diffs = DiffEntry.Scan(walk); NUnit.Framework.Assert.AreEqual(1, diffs.Count); DiffEntry subDiff = diffs[0]; NUnit.Framework.Assert.AreEqual(FileMode.GITLINK, subDiff.GetOldMode()); NUnit.Framework.Assert.AreEqual(FileMode.GITLINK, subDiff.GetNewMode()); NUnit.Framework.Assert.AreEqual(commit2, subDiff.GetOldId().ToObjectId()); NUnit.Framework.Assert.AreEqual(commit, subDiff.GetNewId().ToObjectId()); NUnit.Framework.Assert.AreEqual(path, subDiff.GetNewPath()); NUnit.Framework.Assert.AreEqual(path, subDiff.GetOldPath()); }
/// <exception cref="System.Exception"></exception> public virtual void CommitAmendOnInitialShouldFail() { Git git = new Git(db); git.Commit().SetAmend(true).SetMessage("initial commit").Call(); }