/// <exception cref="System.IO.IOException"></exception> /// <exception cref="Sharpen.UnsupportedEncodingException"></exception> private ObjectId InsertTag(TagBuilder tag) { ObjectInserter oi = db.NewObjectInserter(); try { ObjectId id = oi.Insert(tag); oi.Flush(); return id; } finally { oi.Release(); } }
public virtual void Test022_createCommitTag() { ObjectId emptyId = InsertEmptyBlob(); Tree almostEmptyTree = new Tree(db); almostEmptyTree.AddEntry(new FileTreeEntry(almostEmptyTree, emptyId, Sharpen.Runtime.GetBytesForString ("empty"), false)); ObjectId almostEmptyTreeId = InsertTree(almostEmptyTree); NGit.CommitBuilder almostEmptyCommit = new NGit.CommitBuilder(); almostEmptyCommit.Author = new PersonIdent(author, 1154236443000L, -2 * 60); // not exactly the same almostEmptyCommit.Committer = new PersonIdent(author, 1154236443000L, -2 * 60); almostEmptyCommit.Message = "test022\n"; almostEmptyCommit.TreeId = almostEmptyTreeId; ObjectId almostEmptyCommitId = InsertCommit(almostEmptyCommit); TagBuilder t = new TagBuilder(); t.SetObjectId(almostEmptyCommitId, Constants.OBJ_COMMIT); t.SetTag("test022"); t.SetTagger(new PersonIdent(author, 1154236443000L, -4 * 60)); t.SetMessage("test022 tagged\n"); ObjectId actid = InsertTag(t); NUnit.Framework.Assert.AreEqual("0ce2ebdb36076ef0b38adbe077a07d43b43e3807", actid .Name); RevTag mapTag = ParseTag(actid); NUnit.Framework.Assert.AreEqual(Constants.OBJ_COMMIT, mapTag.GetObject().Type); NUnit.Framework.Assert.AreEqual("test022 tagged\n", mapTag.GetFullMessage()); NUnit.Framework.Assert.AreEqual(new PersonIdent(author, 1154236443000L, -4 * 60), mapTag.GetTaggerIdent()); NUnit.Framework.Assert.AreEqual("b5d3b45a96b340441f5abb9080411705c51cc86c", mapTag .GetObject().Id.Name); }
public virtual void Test021_createTreeTag() { ObjectId emptyId = InsertEmptyBlob(); Tree almostEmptyTree = new Tree(db); almostEmptyTree.AddEntry(new FileTreeEntry(almostEmptyTree, emptyId, Sharpen.Runtime.GetBytesForString ("empty"), false)); ObjectId almostEmptyTreeId = InsertTree(almostEmptyTree); TagBuilder t = new TagBuilder(); t.SetObjectId(almostEmptyTreeId, Constants.OBJ_TREE); t.SetTag("test021"); t.SetTagger(new PersonIdent(author, 1154236443000L, -4 * 60)); t.SetMessage("test021 tagged\n"); ObjectId actid = InsertTag(t); NUnit.Framework.Assert.AreEqual("b0517bc8dbe2096b419d42424cd7030733f4abe5", actid .Name); RevTag mapTag = ParseTag(actid); NUnit.Framework.Assert.AreEqual(Constants.OBJ_TREE, mapTag.GetObject().Type); NUnit.Framework.Assert.AreEqual("test021 tagged\n", mapTag.GetFullMessage()); NUnit.Framework.Assert.AreEqual(new PersonIdent(author, 1154236443000L, -4 * 60), mapTag.GetTaggerIdent()); NUnit.Framework.Assert.AreEqual("417c01c8795a35b8e835113a85a5c0c1c77f67fb", mapTag .GetObject().Id.Name); }
public virtual void Test020_createBlobTag() { ObjectId emptyId = InsertEmptyBlob(); TagBuilder t = new TagBuilder(); t.SetObjectId(emptyId, Constants.OBJ_BLOB); t.SetTag("test020"); t.SetTagger(new PersonIdent(author, 1154236443000L, -4 * 60)); t.SetMessage("test020 tagged\n"); ObjectId actid = InsertTag(t); NUnit.Framework.Assert.AreEqual("6759556b09fbb4fd8ae5e315134481cc25d46954", actid .Name); RevTag mapTag = ParseTag(actid); NUnit.Framework.Assert.AreEqual(Constants.OBJ_BLOB, mapTag.GetObject().Type); NUnit.Framework.Assert.AreEqual("test020 tagged\n", mapTag.GetFullMessage()); NUnit.Framework.Assert.AreEqual(new PersonIdent(author, 1154236443000L, -4 * 60), mapTag.GetTaggerIdent()); NUnit.Framework.Assert.AreEqual("e69de29bb2d1d6434b8b29ae775ad8c2e48c5391", mapTag .GetObject().Id.Name); }
/// <summary>Insert a single annotated tag into the store, returning its unique name. /// </summary> /// <remarks>Insert a single annotated tag into the store, returning its unique name. /// </remarks> /// <param name="builder">the builder containing the proposed tag's data.</param> /// <returns>the name of the tag object.</returns> /// <exception cref="System.IO.IOException">the object could not be stored.</exception> public ObjectId Insert(TagBuilder builder) { return Insert(Constants.OBJ_TAG, builder.Build()); }
public virtual void TestParse_PublicParseMethod() { ObjectInserter.Formatter fmt = new ObjectInserter.Formatter(); TagBuilder src = new TagBuilder(); src.SetObjectId(fmt.IdFor(Constants.OBJ_TREE, new byte[] { }), Constants.OBJ_TREE ); src.SetTagger(committer); src.SetTag("a.test"); src.SetMessage("Test tag\n\nThis is a test.\n"); RevTag p = RevTag.Parse(src.Build()); NUnit.Framework.Assert.AreEqual(src.GetObjectId(), p.GetObject()); NUnit.Framework.Assert.AreEqual(committer, p.GetTaggerIdent()); NUnit.Framework.Assert.AreEqual("a.test", p.GetTagName()); NUnit.Framework.Assert.AreEqual("Test tag", p.GetShortMessage()); NUnit.Framework.Assert.AreEqual(src.GetMessage(), p.GetFullMessage()); }