Exemplo n.º 1
0
        public virtual void FailingPathsShouldNotResultInOKReturnValue(MergeStrategy strategy
                                                                       )
        {
            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.txt").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 = (ResolveMerger)strategy.NewMerger(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);
        }
Exemplo n.º 2
0
 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);
 }
Exemplo n.º 3
0
		/// <exception cref="System.Exception"></exception>
		private void DoCherryPickAndCheckResult(Git git, RevCommit sideCommit, ResolveMerger.MergeFailureReason
			 reason)
		{
			// get current index state
			string indexState = IndexState(CONTENT);
			// cherry-pick
			CherryPickResult result = git.CherryPick().Include(sideCommit.Id).Call();
			NUnit.Framework.Assert.AreEqual(CherryPickResult.CherryPickStatus.FAILED, result.
				GetStatus());
			// staged file a causes DIRTY_INDEX
			NUnit.Framework.Assert.AreEqual(1, result.GetFailingPaths().Count);
			NUnit.Framework.Assert.AreEqual(reason, result.GetFailingPaths().Get("a"));
			NUnit.Framework.Assert.AreEqual("a(modified)", Read(new FilePath(db.WorkTree, "a"
				)));
			// index shall be unchanged
			NUnit.Framework.Assert.AreEqual(indexState, IndexState(CONTENT));
			NUnit.Framework.Assert.AreEqual(RepositoryState.SAFE, db.GetRepositoryState());
		}
Exemplo n.º 4
0
        /// <exception cref="System.Exception"></exception>
        private void CheckMergeFailedResult(MergeCommandResult result, ResolveMerger.MergeFailureReason
			 reason, string indexState, FilePath fileA)
        {
            NUnit.Framework.Assert.AreEqual(MergeStatus.FAILED, result.GetMergeStatus());
            NUnit.Framework.Assert.AreEqual(reason, result.GetFailingPaths().Get("a"));
            NUnit.Framework.Assert.AreEqual("a(modified)", Read(fileA));
            NUnit.Framework.Assert.IsFalse(new FilePath(db.WorkTree, "b").Exists());
            NUnit.Framework.Assert.AreEqual("c", Read(new FilePath(db.WorkTree, "c")));
            NUnit.Framework.Assert.AreEqual(indexState, IndexState(CONTENT));
            NUnit.Framework.Assert.AreEqual(null, result.GetConflicts());
            NUnit.Framework.Assert.AreEqual(RepositoryState.SAFE, db.GetRepositoryState());
        }