当前位置: 首页>>代码示例>>C#>>正文


C# GitIndex类代码示例

本文整理汇总了C#中GitIndex的典型用法代码示例。如果您正苦于以下问题:C# GitIndex类的具体用法?C# GitIndex怎么用?C# GitIndex使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


GitIndex类属于命名空间,在下文中一共展示了GitIndex类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: testModified

        public void testModified()
        {
            var index = new GitIndex(db);

            index.add(trash, writeTrashFile("file2", "file2"));
            index.add(trash, writeTrashFile("dir/file3", "dir/file3"));

            writeTrashFile("dir/file3", "changed");

            var t = new Tree(db);
            t.AddFile("file2").Id = ObjectId.FromString("0123456789012345678901234567890123456789");
            t.AddFile("dir/file3").Id = ObjectId.FromString("0123456789012345678901234567890123456789");
            Assert.AreEqual(2, t.MemberCount);

            var tree2 = (Tree) t.findTreeMember("dir");
            tree2.Id = new ObjectWriter(db).WriteTree(tree2);
            t.Id = new ObjectWriter(db).WriteTree(t);
            var diff = new IndexDiff(t, index);
            diff.Diff();
            Assert.AreEqual(2, diff.Changed.Count);
            Assert.IsTrue(diff.Changed.Contains("file2"));
            Assert.IsTrue(diff.Changed.Contains("dir/file3"));
            Assert.AreEqual(1, diff.Modified.Count);
            Assert.IsTrue(diff.Modified.Contains("dir/file3"));
            Assert.AreEqual(0, diff.Added.Count);
            Assert.AreEqual(0, diff.Removed.Count);
            Assert.AreEqual(0, diff.Missing.Count);
        }
开发者ID:georgeck,项目名称:GitSharp,代码行数:28,代码来源:IndexDiffTest.cs

示例2: handler

 void IndexTreeVisitor.VisitEntry(TreeEntry treeEntry, TreeEntry auxEntry, GitIndex.Entry indexEntry, FileInfo file)
 {
     VisitEntryAuxDelegate handler = VisitEntryAux;
     if (handler != null)
     {
         handler(treeEntry, auxEntry, indexEntry, file);
     }
 }
开发者ID:dev218,项目名称:GitSharp,代码行数:8,代码来源:AbstractIndexTreeVisitor.cs

示例3: WorkDirCheckout

 internal WorkDirCheckout(Repository repo, DirectoryInfo workDir, GitIndex oldIndex, GitIndex newIndex)
     : this()
 {
     _repo = repo;
     _root = workDir;
     _index = oldIndex;
     _merge = repo.MapTree(newIndex.writeTree());
 }
开发者ID:dev218,项目名称:GitSharp,代码行数:8,代码来源:WorkDirCheckout.cs

示例4: IndexTreeWalker

 public IndexTreeWalker(GitIndex index, Tree mainTree, Tree newTree, FileSystemInfo root,
                        IndexTreeVisitor visitor)
 {
     _mainTree = mainTree;
     _newTree = newTree;
     _root = root;
     _visitor = visitor;
     _threeTrees = newTree != null;
     _indexMembers = index.Members;
 }
开发者ID:stschake,项目名称:GitSharp,代码行数:10,代码来源:IndexTreeWalker.cs

示例5: IndexTreeWalker

		/// <summary>Construct a walker for the index and one tree.</summary>
		/// <remarks>Construct a walker for the index and one tree.</remarks>
		/// <param name="index"></param>
		/// <param name="tree"></param>
		/// <param name="root"></param>
		/// <param name="visitor"></param>
		public IndexTreeWalker(GitIndex index, Tree tree, FilePath root, IndexTreeVisitor
			 visitor)
		{
			//import org.eclipse.jgit.JGitText;
			this.mainTree = tree;
			this.root = root;
			this.visitor = visitor;
			this.newTree = null;
			threeTrees = false;
			indexMembers = index.GetMembers();
		}
开发者ID:famousthom,项目名称:monodevelop,代码行数:17,代码来源:IndexTreeWalker.cs

示例6: IndexDiff

        public IndexDiff(Tree tree, GitIndex index)
        {
            _anyChanges = false;
            _tree = tree;
            _index = index;

            Added = new HashSet<string>();
            Changed = new HashSet<string>();
            Removed = new HashSet<string>();
            Missing = new HashSet<string>();
            Modified = new HashSet<string>();
        }
开发者ID:georgeck,项目名称:GitSharp,代码行数:12,代码来源:IndexDiff.cs

示例7: TestBoth

 public virtual void TestBoth()
 {
     GitIndex index = new GitIndex(db);
     Tree tree = new Tree(db);
     index.Add(trash, WriteTrashFile("a", "a"));
     tree.AddFile("b/b");
     index.Add(trash, WriteTrashFile("c", "c"));
     tree.AddFile("c");
     new IndexTreeWalker(index, tree, trash, new IndexTreeWalkerTest.TestIndexTreeVisitor
         (this)).Walk();
     NUnit.Framework.Assert.IsTrue(indexOnlyEntriesVisited.Contains("a"));
     NUnit.Framework.Assert.IsTrue(treeOnlyEntriesVisited.Contains("b/b"));
     NUnit.Framework.Assert.IsTrue(bothVisited.Contains("c"));
 }
开发者ID:charles-cai,项目名称:ngit,代码行数:14,代码来源:IndexTreeWalkerTest.cs

示例8: ShouldSupportNotModifiedExtensionlessFilesWithoutContentChecking

		public void ShouldSupportNotModifiedExtensionlessFilesWithoutContentChecking()
		{
			var index = new GitIndex(db);

			writeTrashFile("extensionless-file", "contents");

			var file = new FileInfo(Path.Combine(trash.FullName, "extensionless-file"));

			index.add(trash, file);

			var entry = index.GetEntry("extensionless-file");

			Assert.IsFalse(entry.IsModified(trash));
		}
开发者ID:dev218,项目名称:GitSharp,代码行数:14,代码来源:IndexModifiedTests.cs

示例9: testAdded2

        public void testAdded2()
        {
            var index = new GitIndex(db);
            writeTrashFile("test/für henon.txt", "Weißebier");
            var tree = new Core.Tree(db);

            index.add(trash, new FileInfo(Path.Combine(trash.FullName, "test/für henon.txt")));
            var diff = new IndexDiff(tree, index);
            diff.Diff();

            Assert.AreEqual(1, diff.Added.Count);
            Assert.IsTrue(diff.Added.Contains("test/für henon.txt"));
            Assert.AreEqual(0, diff.Changed.Count);
            Assert.AreEqual(0, diff.Modified.Count);
            Assert.AreEqual(0, diff.Removed.Count);
        }
开发者ID:jagregory,项目名称:GitSharp,代码行数:16,代码来源:IndexDiffTest.cs

示例10: Compare

 private static int Compare(TreeEntry t, GitIndex.Entry i)
 {
     if ((t == null) && (i == null))
     {
         return 0;
     }
     if (t == null)
     {
         return 1;
     }
     if (i == null)
     {
         return -1;
     }
     return Tree.CompareNames(t.FullNameUTF8, i.NameUTF8, TreeEntry.LastChar(t), TreeEntry.LastChar(i));
 }
开发者ID:dev218,项目名称:GitSharp,代码行数:16,代码来源:IndexTreeWalker.cs

示例11: testAdded

        public void testAdded()
        {
            var index = new GitIndex(db);
            writeTrashFile("file1", "file1");
            writeTrashFile("dir/subfile", "dir/subfile");
            var tree = new Tree(db);

            index.add(trash, new FileInfo(Path.Combine(trash.FullName, "file1")));
            index.add(trash, new FileInfo(Path.Combine(trash.FullName, "dir/subfile")));
            var diff = new IndexDiff(tree, index);
            diff.Diff();

            Assert.AreEqual(2, diff.Added.Count);
            Assert.IsTrue(diff.Added.Contains("file1"));
            Assert.IsTrue(diff.Added.Contains("dir/subfile"));
            Assert.AreEqual(0, diff.Changed.Count);
            Assert.AreEqual(0, diff.Modified.Count);
            Assert.AreEqual(0, diff.Removed.Count);
        }
开发者ID:georgeck,项目名称:GitSharp,代码行数:19,代码来源:IndexDiffTest.cs

示例12: TestAdded

 public virtual void TestAdded()
 {
     GitIndex index = new GitIndex(db);
     WriteTrashFile("file1", "file1");
     WriteTrashFile("dir/subfile", "dir/subfile");
     Tree tree = new Tree(db);
     tree.SetId(InsertTree(tree));
     index.Add(trash, new FilePath(trash, "file1"));
     index.Add(trash, new FilePath(trash, "dir/subfile"));
     index.Write();
     FileTreeIterator iterator = new FileTreeIterator(db);
     IndexDiff diff = new IndexDiff(db, tree.GetId(), iterator);
     diff.Diff();
     NUnit.Framework.Assert.AreEqual(2, diff.GetAdded().Count);
     NUnit.Framework.Assert.IsTrue(diff.GetAdded().Contains("file1"));
     NUnit.Framework.Assert.IsTrue(diff.GetAdded().Contains("dir/subfile"));
     NUnit.Framework.Assert.AreEqual(0, diff.GetChanged().Count);
     NUnit.Framework.Assert.AreEqual(0, diff.GetModified().Count);
     NUnit.Framework.Assert.AreEqual(0, diff.GetRemoved().Count);
 }
开发者ID:ashmind,项目名称:ngit,代码行数:20,代码来源:IndexDiffTest.cs

示例13: ShouldAllowComparingOfAlreadyOpenedFile

		public void ShouldAllowComparingOfAlreadyOpenedFile()
		{
			var index = new GitIndex(db);
			var file = writeTrashFile("extensionless-file", "contents");

			index.add(trash, file);

			var entry = index.GetEntry("extensionless-file");

			// [henon] failed on my windows box (originally only observed on mono/unix) when executed in resharper or with nunit without waiting a second!
			// as the timing is not the point of the test here let's wait a sec anyway.
			Thread.Sleep(TimeSpan.FromSeconds(1));

			// replace contents of file (with same size so it passes the size check)
			using (var writer = file.CreateText())
				writer.Write("stnetnoc");

			// opening the file for reading shoudn't block us from checking the contents
			using (file.OpenRead())
				Assert.IsTrue(entry.IsModified(trash, true));
		}
开发者ID:dev218,项目名称:GitSharp,代码行数:21,代码来源:IndexModifiedTests.cs

示例14: TestCheckingOutWithConflicts

 public virtual void TestCheckingOutWithConflicts()
 {
     GitIndex index = new GitIndex(db);
     index.Add(trash, WriteTrashFile("bar", "bar"));
     index.Add(trash, WriteTrashFile("foo/bar/baz/qux", "foo/bar"));
     RecursiveDelete(new FilePath(trash, "bar"));
     RecursiveDelete(new FilePath(trash, "foo"));
     WriteTrashFile("bar/baz/qux/foo", "another nasty one");
     WriteTrashFile("foo", "troublesome little bugger");
     try
     {
         WorkDirCheckout workDirCheckout = new WorkDirCheckout(db, trash, index, index);
         workDirCheckout.Checkout();
         NUnit.Framework.Assert.Fail("Should have thrown exception");
     }
     catch (NGit.Errors.CheckoutConflictException)
     {
     }
     // all is well
     WorkDirCheckout workDirCheckout_1 = new WorkDirCheckout(db, trash, index, index);
     workDirCheckout_1.SetFailOnConflict(false);
     workDirCheckout_1.Checkout();
     NUnit.Framework.Assert.IsTrue(new FilePath(trash, "bar").IsFile());
     NUnit.Framework.Assert.IsTrue(new FilePath(trash, "foo/bar/baz/qux").IsFile());
     GitIndex index2 = new GitIndex(db);
     RecursiveDelete(new FilePath(trash, "bar"));
     RecursiveDelete(new FilePath(trash, "foo"));
     index2.Add(trash, WriteTrashFile("bar/baz/qux/foo", "bar"));
     WriteTrashFile("bar/baz/qux/bar", "evil? I thought it said WEEVIL!");
     index2.Add(trash, WriteTrashFile("foo", "lalala"));
     workDirCheckout_1 = new WorkDirCheckout(db, trash, index2, index);
     workDirCheckout_1.SetFailOnConflict(false);
     workDirCheckout_1.Checkout();
     NUnit.Framework.Assert.IsTrue(new FilePath(trash, "bar").IsFile());
     NUnit.Framework.Assert.IsTrue(new FilePath(trash, "foo/bar/baz/qux").IsFile());
     NUnit.Framework.Assert.IsNotNull(index2.GetEntry("bar"));
     NUnit.Framework.Assert.IsNotNull(index2.GetEntry("foo/bar/baz/qux"));
     NUnit.Framework.Assert.IsNull(index2.GetEntry("bar/baz/qux/foo"));
     NUnit.Framework.Assert.IsNull(index2.GetEntry("foo"));
 }
开发者ID:charles-cai,项目名称:ngit,代码行数:40,代码来源:WorkDirCheckoutTest.cs

示例15: testCheckingOutWithConflicts

        public void testCheckingOutWithConflicts()
        {
            var index = new GitIndex(db);
            index.add(trash, writeTrashFile("bar", "bar"));
            index.add(trash, writeTrashFile("foo/bar/baz/qux", "foo/bar"));
            recursiveDelete(new FileInfo(Path.Combine(trash.FullName, "bar")));
            recursiveDelete(new DirectoryInfo(Path.Combine(trash.FullName, "foo")));
            writeTrashFile("bar/baz/qux/foo", "another nasty one");
            writeTrashFile("foo", "troublesome little bugger");
            
            var workDirCheckout1 = new WorkDirCheckout(db, trash, index, index);

            AssertHelper.Throws<CheckoutConflictException>(workDirCheckout1.checkout);


            var workDirCheckout2 = new WorkDirCheckout(db, trash, index, index) { FailOnConflict = false };
            workDirCheckout2.checkout();

            Assert.IsTrue(new FileInfo(Path.Combine(trash.FullName, "bar")).IsFile());
            Assert.IsTrue(new FileInfo(Path.Combine(trash.FullName, "foo/bar/baz/qux")).IsFile());

            var index2 = new GitIndex(db);
            recursiveDelete(new FileInfo(Path.Combine(trash.FullName, "bar")));
            recursiveDelete(new DirectoryInfo(Path.Combine(trash.FullName, "foo")));
            index2.add(trash, writeTrashFile("bar/baz/qux/foo", "bar"));
            writeTrashFile("bar/baz/qux/bar", "evil? I thought it said WEEVIL!");
            index2.add(trash, writeTrashFile("foo", "lalala"));

            workDirCheckout2 = new WorkDirCheckout(db, trash, index2, index) { FailOnConflict = false };
            workDirCheckout2.checkout();

            Assert.IsTrue(new FileInfo(Path.Combine(trash.FullName, "bar")).IsFile());
            Assert.IsTrue(new FileInfo(Path.Combine(trash.FullName, "foo/bar/baz/qux")).IsFile());
            Assert.IsNotNull(index2.GetEntry("bar"));
            Assert.IsNotNull(index2.GetEntry("foo/bar/baz/qux"));
            Assert.IsNull(index2.GetEntry("bar/baz/qux/foo"));
            Assert.IsNull(index2.GetEntry("foo"));
        }
开发者ID:dev218,项目名称:GitSharp,代码行数:38,代码来源:WorkDirCheckoutTest.cs


注:本文中的GitIndex类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。