• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# Core.ObjectWriter类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: testNonRecursiveFiltering

        public void testNonRecursiveFiltering()
        {
            var ow = new ObjectWriter(db);
            ObjectId aSth = ow.WriteBlob("a.sth".getBytes());
            ObjectId aTxt = ow.WriteBlob("a.txt".getBytes());
            DirCache dc = DirCache.read(db);
            DirCacheBuilder builder = dc.builder();
            var aSthEntry = new DirCacheEntry("a.sth");
            aSthEntry.setFileMode(FileMode.RegularFile);
            aSthEntry.setObjectId(aSth);
            var aTxtEntry = new DirCacheEntry("a.txt");
            aTxtEntry.setFileMode(FileMode.RegularFile);
            aTxtEntry.setObjectId(aTxt);
            builder.add(aSthEntry);
            builder.add(aTxtEntry);
            builder.finish();
            ObjectId treeId = dc.writeTree(ow);


            var tw = new GitSharp.Core.TreeWalk.TreeWalk(db);
            tw.setFilter(PathSuffixFilter.create(".txt"));
            tw.addTree(treeId);

            var paths = new LinkedList<string>();
            while (tw.next())
            {
                paths.AddLast(tw.getPathString());
            }

            var expected = new LinkedList<string>();
            expected.AddLast("a.txt");

            Assert.AreEqual(expected, paths);
        }
开发者ID:dev218,项目名称:GitSharp,代码行数:34,代码来源:PathSuffixFilterTestCase.cs


示例2: Save

		///	<summary>
		/// Persist this commit object
		/// </summary>
		/// <exception cref="IOException"></exception>
		public void Save() // [henon] was Commit() in java, but c# won't allow it
		{
			if (CommitId != null)
			{
				throw new InvalidOperationException("exists " + CommitId);
			}

			CommitId = new ObjectWriter(Repository).WriteCommit(this);
		}
开发者ID:dev218,项目名称:GitSharp,代码行数:13,代码来源:Commit.cs


示例3: HashAndInsertObject

 public string HashAndInsertObject(string filename)
 {
     var writer = new ObjectWriter(_repository);
     var objectId = writer.WriteBlob(new FileInfo(filename));
     return objectId.ToString();
 }
开发者ID:fschwiet,项目名称:git-tfs,代码行数:6,代码来源:GitRepository.cs


示例4: testMissingSubtree_DetectFileAdded_FileModified

        public void testMissingSubtree_DetectFileAdded_FileModified()
        {
            var ow = new ObjectWriter(db);
            ObjectId aFileId = ow.WriteBlob(Constants.CHARSET.GetBytes("a"));
            ObjectId bFileId = ow.WriteBlob(Constants.CHARSET.GetBytes("b"));
            ObjectId cFileId1 = ow.WriteBlob(Constants.CHARSET.GetBytes("c-1"));
            ObjectId cFileId2 = ow.WriteBlob(Constants.CHARSET.GetBytes("c-2"));

            // Create sub-a/empty, sub-c/empty = hello.
            Func<ObjectId> oldTree = () =>
                                     	{
                                            var root = new Core.Tree(db);

                                            Core.Tree subA = root.AddTree("sub-a");
                                     		subA.AddFile("empty").Id = aFileId;
                                     		subA.Id = ow.WriteTree(subA);

                                            Core.Tree subC = root.AddTree("sub-c");
                                     		subC.AddFile("empty").Id = cFileId1;
                                     		subC.Id = ow.WriteTree(subC);

                                     		return ow.WriteTree(root);
                                     	};

            // Create sub-a/empty, sub-b/empty, sub-c/empty.
            Func<ObjectId> newTree = () =>
                                     	{
                                            var root = new Core.Tree(db);

                                            Core.Tree subA = root.AddTree("sub-a");
                                     		subA.AddFile("empty").Id = aFileId;
                                     		subA.Id = ow.WriteTree(subA);

                                            Core.Tree subB = root.AddTree("sub-b");
                                     		subB.AddFile("empty").Id = bFileId;
                                     		subB.Id = ow.WriteTree(subB);

                                            Core.Tree subC = root.AddTree("sub-c");
                                     		subC.AddFile("empty").Id = cFileId2;
                                     		subC.Id = ow.WriteTree(subC);

                                     		return ow.WriteTree(root);
                                     	};

            var tw = new GitSharp.Core.TreeWalk.TreeWalk(db);
            tw.reset(new[] { oldTree.Invoke(), newTree.Invoke() });
            tw.Recursive = true;
            tw.setFilter(TreeFilter.ANY_DIFF);

            Assert.IsTrue(tw.next());
            Assert.AreEqual("sub-b/empty", tw.getPathString());
            Assert.AreEqual(FileMode.Missing, tw.getFileMode(0));
            Assert.AreEqual(FileMode.RegularFile, tw.getFileMode(1));
            Assert.AreEqual(ObjectId.ZeroId, tw.getObjectId(0));
            Assert.AreEqual(bFileId, tw.getObjectId(1));

            Assert.IsTrue(tw.next());
            Assert.AreEqual("sub-c/empty", tw.getPathString());
            Assert.AreEqual(FileMode.RegularFile, tw.getFileMode(0));
            Assert.AreEqual(FileMode.RegularFile, tw.getFileMode(1));
            Assert.AreEqual(cFileId1, tw.getObjectId(0));
            Assert.AreEqual(cFileId2, tw.getObjectId(1));

            Assert.IsFalse(tw.next());
        }
开发者ID:jagregory,项目名称:GitSharp,代码行数:65,代码来源:TreeWalkBasicDiffTest.cs


示例5: test025_computeSha1NoStore

 public void test025_computeSha1NoStore()
 {
     byte[] data = "test025 some data, more than 16 bytes to get good coverage".getBytes("ISO-8859-1");
     ObjectId id = new ObjectWriter(db).ComputeBlobSha1(data.Length, new MemoryStream(data));
     Assert.AreEqual("4f561df5ecf0dfbd53a0dc0f37262fef075d9dde", id.Name);
 }
开发者ID:mdekrey,项目名称:GitSharp,代码行数:6,代码来源:T0003_Basic_Write.cs


示例6: Write_Blob

        public void Write_Blob()
        {
            ObjectId id = new ObjectWriter(db).WriteBlob(new FileInfo("Resources/single_file_commit/i-am-a-file"));
            Assert.AreEqual("95ea6a6859af6791464bd8b6de76ad5a6f9fad81", id.ToString());
            Assert.AreEqual(Inspector.Inspect("Resources/single_file_commit", "95ea6a6859af6791464bd8b6de76ad5a6f9fad81"), new Inspector(db).Inspect(id));

            writeTrashFile("i-am-a-file", "and this is the data in me\r\n\r\n");
            id = new ObjectWriter(db).WriteBlob(new FileInfo(trash+"/i-am-a-file"));
            Assert.AreEqual("95ea6a6859af6791464bd8b6de76ad5a6f9fad81", id.ToString());
        }
开发者ID:mdekrey,项目名称:GitSharp,代码行数:10,代码来源:T0003_Basic_Write.cs


示例7: GenSha1

 private ObjectId GenSha1(string data)
 {
     var input = new MemoryStream(data.getBytes());
     var writer = new ObjectWriter(db);
     try
     {
         return writer.WriteObject(ObjectType.Blob, data.getBytes().Length, input, true);
     }
     catch (IOException exception)
     {
         Assert.Fail(exception.ToString());
     }
     return null;
 }
开发者ID:jagregory,项目名称:GitSharp,代码行数:14,代码来源:ReadTreeTest.cs


示例8: test023_createCommitNonAnullii

        public void test023_createCommitNonAnullii()
        {
            ObjectId emptyId = new ObjectWriter(db).WriteBlob(new byte[0]);
            var almostEmptyTree = new Tree(db);
            almostEmptyTree.AddEntry(new FileTreeEntry(almostEmptyTree, emptyId, "empty".getBytes(), false));
            ObjectId almostEmptyTreeId = new ObjectWriter(db).WriteTree(almostEmptyTree);

            var commit = new Commit(db)
                         	{
                         		TreeId = almostEmptyTreeId,
                         		Author = new PersonIdent("Joe H\u00e4cker", "[email protected]", 4294967295000L, 60),
                         		Committer = new PersonIdent("Joe Hacker", "[email protected]", 4294967295000L, 60),
                                Encoding = Constants.CHARSET,
                         		Message = "\u00dcbergeeks"
                         	};

            ObjectId cid = new ObjectWriter(db).WriteCommit(commit);
            Assert.AreEqual("4680908112778718f37e686cbebcc912730b3154", cid.Name);
        }
开发者ID:mdekrey,项目名称:GitSharp,代码行数:19,代码来源:T0003_Basic_Write.cs


示例9: WriteBlob

        private RevObject WriteBlob(Core.Repository repo, string data)
        {
            var revWalk = new GitSharp.Core.RevWalk.RevWalk(repo);
            byte[] bytes = Constants.encode(data);
            var ow = new ObjectWriter(repo);
            ObjectId id = ow.WriteBlob(bytes);
            try
            {
                Parse(id);
                Assert.Fail("Object " + id.Name + " should not exist in test repository");
            }
            catch (MissingObjectException)
            {
                // Ok
            }

            return revWalk.lookupBlob(id);
        }
开发者ID:dev218,项目名称:GitSharp,代码行数:18,代码来源:ConcurrentRepackTest.cs


示例10: Save

        // [henon] was Commit() in java, but c# won't allow it
        ///	<summary>
        /// Persist this commit object
        /// </summary>
        /// <exception cref="IOException"></exception>
        public void Save()
        {
            if (CommitId != null)
            {
                throw new InvalidOperationException("exists " + CommitId);
            }

            CommitId = new ObjectWriter(Repository).WriteCommit(this);
        }
开发者ID:linquize,项目名称:GitSharp,代码行数:14,代码来源:Commit.cs


示例11: TestPick

		public void TestPick()
		{
			// B---O
			// \----P---T
			//
			// Cherry-pick "T" onto "O". This shouldn't introduce "p-fail", which
			// was created by "P", nor should it modify "a", which was done by "P".
			//
			DirCache treeB = DirCache.read(db);
			DirCache treeO = DirCache.read(db);
			DirCache treeP = DirCache.read(db);
			DirCache treeT = DirCache.read(db);
			{
				DirCacheBuilder b = treeB.builder();
				DirCacheBuilder o = treeO.builder();
				DirCacheBuilder p = treeP.builder();
				DirCacheBuilder t = treeT.builder();

				b.add(MakeEntry("a", FileMode.RegularFile));

				o.add(MakeEntry("a", FileMode.RegularFile));
				o.add(MakeEntry("o", FileMode.RegularFile));

				p.add(MakeEntry("a", FileMode.RegularFile, "q"));
				p.add(MakeEntry("p-fail", FileMode.RegularFile));

				t.add(MakeEntry("a", FileMode.RegularFile));
				t.add(MakeEntry("t", FileMode.RegularFile));

				b.finish();
				o.finish();
				p.finish();
				t.finish();
			}

			var ow = new ObjectWriter(db);
			ObjectId B = Commit(ow, treeB, new ObjectId[] { });
			ObjectId O = Commit(ow, treeO, new[] { B });
			ObjectId P = Commit(ow, treeP, new[] { B });
			ObjectId T = Commit(ow, treeT, new[] { P });

			var twm = (ThreeWayMerger)MergeStrategy.SimpleTwoWayInCore.NewMerger(db);
			twm.SetBase(P);
			bool merge = twm.Merge(new[] { O, T });
			Assert.IsTrue(merge);

			var tw = new GitSharp.Core.TreeWalk.TreeWalk(db) { Recursive = true };
			tw.reset(twm.GetResultTreeId());

			Assert.IsTrue(tw.next());
			Assert.AreEqual("a", tw.getPathString());
			AssertCorrectId(treeO, tw);

			Assert.IsTrue(tw.next());
			Assert.AreEqual("o", tw.getPathString());
			AssertCorrectId(treeO, tw);

			Assert.IsTrue(tw.next());
			Assert.AreEqual("t", tw.getPathString());
			AssertCorrectId(treeT, tw);

			Assert.IsFalse(tw.next());
		}
开发者ID:dev218,项目名称:GitSharp,代码行数:63,代码来源:CherryPickTest.cs


示例12: WriteTree

 ///	<summary>
 /// Construct a WriteTree for a given directory
 ///	</summary>
 ///	<param name="sourceDirectory"> </param>
 ///	<param name="db"> </param>
 public WriteTree(DirectoryInfo sourceDirectory, Repository db)
     : base(sourceDirectory)
 {
     ow = new ObjectWriter(db);
 }
开发者ID:stschake,项目名称:GitSharp,代码行数:10,代码来源:WriteTree.cs


示例13: Save

        //renamed from Tag
        /**
         * Store a tag.
         * If author, message or type is set make the tag an annotated tag.
         *
         * @
         */
        public void Save()
        {
            if (TagId != null)
                throw new InvalidOperationException("exists " + TagId);
            ObjectId id;

            if (author != null || message != null || tagType != null)
            {
                ObjectId tagid = new ObjectWriter(Repository).WriteTag(this);
                TagId = tagid;
                id = tagid;
            }
            else
            {
                id = Id;
            }

            RefUpdate ru = Repository.UpdateRef(Constants.R_TAGS + TagName);
            ru.NewObjectId = id;
            ru.setRefLogMessage("tagged " + TagName, false);
            if (ru.forceUpdate() == RefUpdate.RefUpdateResult.LOCK_FAILURE)
                throw new ObjectWritingException("Unable to lock tag " + TagName);
        }
开发者ID:spraints,项目名称:GitSharp,代码行数:30,代码来源:Tag.cs


示例14: test021_createTreeTag

        public void test021_createTreeTag()
        {
            ObjectId emptyId = new ObjectWriter(db).WriteBlob(new byte[0]);
            var almostEmptyTree = new Tree(db);
            almostEmptyTree.AddEntry(new FileTreeEntry(almostEmptyTree, emptyId, "empty".getBytes(), false));
            ObjectId almostEmptyTreeId = new ObjectWriter(db).WriteTree(almostEmptyTree);

            var t = new Tag(db)
                        {
                            Id = almostEmptyTreeId,
                            TagType = "tree",
                            TagName = "test021",
                            Author = new PersonIdent(jauthor, 1154236443000L, -4*60),
                            Message = "test021 tagged\n"
                        };

            t.Save();
            Assert.AreEqual("b0517bc8dbe2096b419d42424cd7030733f4abe5", t.TagId.Name);

            Tag MapTag = db.MapTag("test021");
            Assert.AreEqual("tree", MapTag.TagType);
            Assert.AreEqual("test021 tagged\n", MapTag.Message);
            Assert.AreEqual(new PersonIdent(jauthor, 1154236443000L, -4 * 60), MapTag.Author);
            Assert.AreEqual("417c01c8795a35b8e835113a85a5c0c1c77f67fb", MapTag.Id.Name);
        }
开发者ID:mdekrey,项目名称:GitSharp,代码行数:25,代码来源:T0003_Basic_Write.cs


示例15: HashWithGitSharp

 private static string HashWithGitSharp(Stream file)
 {
     var repository = new Repository(new DirectoryInfo(Path.Combine(Environment.CurrentDirectory, ".git")));
     var writer = new ObjectWriter(repository);
     return writer.WriteBlob(file.Length, file).ToString();
 }
开发者ID:nnieslan,项目名称:git-tfs,代码行数:6,代码来源:HashAndInsertObject.cs


示例16: test022_createCommitTag

        public void test022_createCommitTag()
        {
            ObjectId emptyId = new ObjectWriter(db).WriteBlob(new byte[0]);
            var almostEmptyTree = new Tree(db);
            almostEmptyTree.AddEntry(new FileTreeEntry(almostEmptyTree, emptyId, "empty".getBytes(), false));
            ObjectId almostEmptyTreeId = new ObjectWriter(db).WriteTree(almostEmptyTree);

            var almostEmptyCommit = new Commit(db)
                                        {
                                            Author = new PersonIdent(jauthor, 1154236443000L, -2*60),
                                            Committer = new PersonIdent(jauthor, 1154236443000L, -2*60),
                                            Message = "test022\n",
                                            TreeId = almostEmptyTreeId
                                        };

            ObjectId almostEmptyCommitId = new ObjectWriter(db).WriteCommit(almostEmptyCommit);

            var t = new Tag(db)
                        {
                            Id = almostEmptyCommitId,
                            TagType = "commit",
                            TagName = "test022",
                            Author = new PersonIdent(jauthor, 1154236443000L, -4*60),
                            Message = "test022 tagged\n"
                        };

            t.Save();
            Assert.AreEqual("0ce2ebdb36076ef0b38adbe077a07d43b43e3807", t.TagId.Name);

            Tag mapTag = db.MapTag("test022");
            Assert.AreEqual("commit", mapTag.TagType);
            Assert.AreEqual("test022 tagged\n", mapTag.Message);
            Assert.AreEqual(new PersonIdent(jauthor, 1154236443000L, -4 * 60), mapTag.Author);
            Assert.AreEqual("b5d3b45a96b340441f5abb9080411705c51cc86c", mapTag.Id.Name);
        }
开发者ID:mdekrey,项目名称:GitSharp,代码行数:35,代码来源:T0003_Basic_Write.cs


示例17: testTrivialTwoWay_rightDFconflict2

        public void testTrivialTwoWay_rightDFconflict2()
        {
            DirCache treeB = DirCache.read(db);
            DirCache treeO = DirCache.read(db);
            DirCache treeT = DirCache.read(db);
            {
                DirCacheBuilder b = treeB.builder();
                DirCacheBuilder o = treeO.builder();
                DirCacheBuilder t = treeT.builder();

                b.add(MakeEntry("d", FileMode.RegularFile));

                o.add(MakeEntry("d/o", FileMode.RegularFile));

                t.add(MakeEntry("d", FileMode.RegularFile, "t !"));

                b.finish();
                o.finish();
                t.finish();
            }

            var ow = new ObjectWriter(db);
            ObjectId B = Commit(ow, treeB, new ObjectId[] { });
            ObjectId O = Commit(ow, treeO, new[] { B });
            ObjectId T = Commit(ow, treeT, new[] { B });

            Merger ourMerger = MergeStrategy.SimpleTwoWayInCore.NewMerger(db);
            bool merge = ourMerger.Merge(new[] { O, T });
            Assert.IsFalse(merge);
        }
开发者ID:georgeck,项目名称:GitSharp,代码行数:30,代码来源:SimpleMergeTest.cs


示例18: test024_createCommitNonAscii

 public void test024_createCommitNonAscii()
 {
     ObjectId emptyId = new ObjectWriter(db).WriteBlob(new byte[0]);
     var almostEmptyTree = new Tree(db);
     almostEmptyTree.AddEntry(new FileTreeEntry(almostEmptyTree, emptyId, "empty".getBytes(), false));
     ObjectId almostEmptyTreeId = new ObjectWriter(db).WriteTree(almostEmptyTree);
     var commit = new Commit(db)
                  	{
                  		TreeId = almostEmptyTreeId,
                  		Author = new PersonIdent("Joe H\u00e4cker", "[email protected]", 4294967295000L, 60),
                  		Committer = new PersonIdent("Joe Hacker", "[email protected]", 4294967295000L, 60),
                  		Encoding = Encoding.GetEncoding("ISO-8859-1"),
                  		Message = "\u00dcbergeeks"
                  	};
     ObjectId cid = new ObjectWriter(db).WriteCommit(commit);
     var s = new Inspector(db).Inspect(cid);
     Assert.AreEqual("2979b39d385014b33287054b87f77bcb3ecb5ebf", cid.ToString());
 }
开发者ID:mdekrey,项目名称:GitSharp,代码行数:18,代码来源:T0003_Basic_Write.cs


示例19: Commit

 private ObjectId Commit(ObjectWriter ow, DirCache treeB, ObjectId[] parentIds)
 {
     var c = new Commit(db) { TreeId = treeB.writeTree(ow), Author = new PersonIdent("A U Thor", "a.u.thor", 1L, 0) };
     c.Committer = c.Author;
     c.ParentIds = parentIds;
     c.Message = "Tree " + c.TreeId.Name;
     return ow.WriteCommit(c);
 }
开发者ID:georgeck,项目名称:GitSharp,代码行数:8,代码来源:SimpleMergeTest.cs


示例20: testTwoSuccessiveCommitsLinkedToHead

        public void testTwoSuccessiveCommitsLinkedToHead()
        {
            var repo = createNewEmptyRepo();
            var workingDirectory = repo.WorkingDirectory;
            repo.Create();

            var objectWriter = new ObjectWriter(repo);

            FileInfo project1_a_txt = writeTrashFile(Path.Combine(workingDirectory.FullName, "Project-1/A.txt"), "A.txt - first version\n");
            FileInfo project1_b_txt = writeTrashFile(Path.Combine(workingDirectory.FullName, "Project-1/B.txt"), "B.txt - first version\n");

            var tree = new Tree(repo);
            Tree projectTree = tree.AddTree("Project-1");
            addFile(projectTree, project1_a_txt, objectWriter);
            projectTree.Id = (objectWriter.WriteTree(projectTree));
            addFile(projectTree, project1_b_txt, objectWriter);
            projectTree.Id = (objectWriter.WriteTree(projectTree));
            tree.Id = (objectWriter.WriteTree(tree));

            var commit = new Commit(repo)
            {
                Author = new PersonIdent(jauthor, (0L), 60),
                Committer = new PersonIdent(jcommitter, (0L), 60),
                Message = "Foo\n\nMessage",
                TreeEntry = tree
            };
            commit.Save();
            var commitId = commit.CommitId;

            FileInfo project1_b_v2_txt = writeTrashFile(Path.Combine(workingDirectory.FullName, "Project-1/B.txt"), "B.txt - second version\n");

            tree = new Tree(repo);
            projectTree = tree.AddTree("Project-1");
            addFile(projectTree, project1_a_txt, objectWriter);
            projectTree.Id = (objectWriter.WriteTree(projectTree));
            addFile(projectTree, project1_b_v2_txt, objectWriter);
            projectTree.Id = (objectWriter.WriteTree(projectTree));
            tree.Id = (objectWriter.WriteTree(tree));

            commit = new Commit(repo)
            {
                Author = new PersonIdent(jauthor, (0L), 60),
                Committer = new PersonIdent(jcommitter, (0L), 60),
                Message = "Modified",
                ParentIds = new[] { commitId },
                TreeEntry = tree
            };
            commit.Save();
            commitId = commit.CommitId;

            RefUpdate lck = repo.UpdateRef("refs/heads/master");
            Assert.IsNotNull(lck, "obtained lock");
            lck.NewObjectId = commitId;
            Assert.AreEqual(RefUpdate.RefUpdateResult.New, lck.ForceUpdate());
        }
开发者ID:mdekrey,项目名称:GitSharp,代码行数:55,代码来源:T0003_Basic_Write.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Core.Repository类代码示例发布时间:2022-05-26
下一篇:
C# Core.ObjectId类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap