/** * Wrap a repository with test building tools. * * @param db * the test repository to write into. * @param rw * the RevObject pool to use for object lookup. * @throws Exception */ public TestRepository(global::GitSharp.Core.Repository db, CoreRevWalk rw) { this.db = db; this.pool = rw; this.writer = new ObjectWriter(db); this.now = 1236977987000L; }
public void testWritePack3() { _writer.ReuseDeltas = false; var forcedOrder = new[] { ObjectId.FromString("82c6b885ff600be425b4ea96dee75dca255b69e7"), ObjectId.FromString("c59759f143fb1fe21c197981df75a7ee00290799"), ObjectId.FromString("aabf2ffaec9b497f0950352b3e582d73035c2035"), ObjectId.FromString("902d5476fa249b7abc9d84c611577a81381f0327"), ObjectId.FromString("5b6e7c66c276e7610d4a73c70ec1a1f7c1003259"), ObjectId.FromString("6ff87c4664981e4397625791c8ea3bbb5f2279a3") }; var parser = new GitSharp.Core.RevWalk.RevWalk(db); var forcedOrderRevs = new RevObject[forcedOrder.Length]; for (int i = 0; i < forcedOrder.Length; i++) { forcedOrderRevs[i] = parser.parseAny(forcedOrder[i]); } CreateVerifyOpenPack(forcedOrderRevs.AsEnumerable()); Assert.AreEqual(forcedOrder.Length, _writer.getObjectsNumber()); VerifyObjectsOrder(forcedOrder); Assert.AreEqual("ed3f96b8327c7c66b0f8f70056129f0769323d86", _writer.computeName().Name); }
public void testEqualsIsIdentity() { RevCommit a1 = Commit(); RevCommit b1 = Commit(); Assert.IsTrue(a1.Equals(a1)); Assert.IsTrue(a1.Equals((object)a1)); Assert.IsFalse(a1.Equals(b1)); Assert.IsFalse(a1.Equals(a1.Copy())); Assert.IsFalse(a1.Equals((object)a1.Copy())); Assert.IsFalse(a1.Equals(string.Empty)); var rw2 = new GitSharp.Core.RevWalk.RevWalk(db); RevCommit a2 = rw2.parseCommit(a1); RevCommit b2 = rw2.parseCommit(b1); Assert.AreNotSame(a1, a2); Assert.AreNotSame(b1, b2); Assert.IsFalse(a1.Equals(a2)); Assert.IsFalse(b1.Equals(b2)); Assert.AreEqual(a1.GetHashCode(), a2.GetHashCode()); Assert.AreEqual(b1.GetHashCode(), b2.GetHashCode()); Assert.IsTrue(AnyObjectId.equals(a1, a2)); Assert.IsTrue(AnyObjectId.equals(b1, b2)); }
public override void setUp() { base.setUp(); _ow = new ObjectWriter(db); rw = createRevWalk(); emptyTree = rw.parseTree(_ow.WriteTree(new Core.Tree(db))); nowTick = 1236977987000L; }
public override bool include(GitSharp.Core.RevWalk.RevWalk walker, RevCommit cmit) { bool remoteKnowsIsCommon = cmit.has(_common); if (cmit.has(_advertised)) { cmit.add(_common); } return(!remoteKnowsIsCommon); }
private RevCommit Parse(string msg) { var buf = new StringBuilder(); buf.Append("tree " + ObjectId.ZeroId.Name + "\n"); buf.Append("author A. U. Thor <*****@*****.**> 1 +0000\n"); buf.Append("committer A. U. Thor <*****@*****.**> 1 +0000\n"); buf.Append("\n"); buf.Append(msg); var walk = new GitSharp.Core.RevWalk.RevWalk(db); walk.setRetainBody(true); var c = new RevCommit(ObjectId.ZeroId); c.parseCanonical(walk, Constants.encode(buf.ToString())); return(c); }
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)); }
public void testParse_NoParents() { ObjectId treeId = id("9788669ad918b6fcce64af8882fc9a81cb6aba67"); const string authorName = "A U. Thor"; const string authorEmail = "*****@*****.**"; const int authorTime = 1218123387; const string committerName = "C O. Miter"; const string committerEmail = "*****@*****.**"; const int committerTime = 1218123390; var body = new StringBuilder(); body.Append("tree "); body.Append(treeId.Name); body.Append("\n"); body.Append("author "); body.Append(authorName); body.Append(" <"); body.Append(authorEmail); body.Append("> "); body.Append(authorTime); body.Append(" +0700\n"); body.Append("committer "); body.Append(committerName); body.Append(" <"); body.Append(committerEmail); body.Append("> "); body.Append(committerTime); body.Append(" -0500\n"); body.Append("\n"); var rw = new GitSharp.Core.RevWalk.RevWalk(db); var c = new RevCommit(id("9473095c4cb2f12aefe1db8a355fe3fafba42f67")); Assert.IsNull(c.Tree); Assert.IsNull(c.Parents); c.parseCanonical(rw, body.ToString().getBytes("UTF-8")); Assert.IsNotNull(c.Tree); Assert.AreEqual(treeId, c.Tree.getId()); Assert.AreSame(rw.lookupTree(treeId), c.Tree); Assert.IsNotNull(c.Parents); Assert.AreEqual(0, c.Parents.Length); Assert.AreEqual(string.Empty, c.getFullMessage()); PersonIdent cAuthor = c.getAuthorIdent(); Assert.IsNotNull(cAuthor); Assert.AreEqual(authorName, cAuthor.Name); Assert.AreEqual(authorEmail, cAuthor.EmailAddress); PersonIdent cCommitter = c.getCommitterIdent(); Assert.IsNotNull(cCommitter); Assert.AreEqual(committerName, cCommitter.Name); Assert.AreEqual(committerEmail, cCommitter.EmailAddress); }
public void testParseAllFields() { ObjectId treeId = Id("9788669ad918b6fcce64af8882fc9a81cb6aba67"); const string name = "v1.2.3.4.5"; const string taggerName = "A U. Thor"; const string taggerEmail = "*****@*****.**"; const int taggerTime = 1218123387; var body = new StringBuilder(); body.Append("object "); body.Append(treeId.Name); body.Append("\n"); body.Append("type tree\n"); body.Append("tag "); body.Append(name); body.Append("\n"); body.Append("tagger "); body.Append(taggerName); body.Append(" <"); body.Append(taggerEmail); body.Append("> "); body.Append(taggerTime); body.Append(" +0700\n"); body.Append("\n"); var rw = new GitSharp.Core.RevWalk.RevWalk(db); var c = new RevTag(Id("9473095c4cb2f12aefe1db8a355fe3fafba42f67")); Assert.IsNull(c.getObject()); Assert.IsNull(c.getTagName()); c.parseCanonical(rw, body.ToString().getBytes("UTF-8")); Assert.IsNotNull(c.getObject()); Assert.AreEqual(treeId, c.getObject().getId()); Assert.AreSame(rw.lookupTree(treeId), c.getObject()); Assert.IsNotNull(c.getTagName()); Assert.AreEqual(name, c.getTagName()); Assert.AreEqual(string.Empty, c.getFullMessage()); PersonIdent cTagger = c.getTaggerIdent(); Assert.IsNotNull(cTagger); Assert.AreEqual(taggerName, cTagger.Name); Assert.AreEqual(taggerEmail, cTagger.EmailAddress); }
private void testOneType(int typeCode) { ObjectId locId = Id("9788669ad918b6fcce64af8882fc9a81cb6aba67"); var b = new StringBuilder(); b.Append("object " + locId.Name + "\n"); b.Append("type " + Constants.typeString(typeCode) + "\n"); b.Append("tag v1.2.3.4.5\n"); b.Append("tagger A U. Thor <*****@*****.**> 1218123387 +0700\n"); b.Append("\n"); var rw = new GitSharp.Core.RevWalk.RevWalk(db); var c = new RevTag(Id("9473095c4cb2f12aefe1db8a355fe3fafba42f67")); Assert.IsNull(c.getObject()); Assert.IsNull(c.getTagName()); c.parseCanonical(rw, b.ToString().getBytes("UTF-8")); Assert.IsNotNull(c.getObject()); Assert.AreEqual(locId, c.getObject().getId()); Assert.AreSame(rw.lookupAny(locId, typeCode), c.getObject()); }
public override bool include(GitSharp.Core.RevWalk.RevWalk walker, RevCommit cmit) { return(true); }
private RevCommit Parse(string msg) { var buf = new StringBuilder(); buf.Append("tree " + ObjectId.ZeroId.Name + "\n"); buf.Append("author A. U. Thor <*****@*****.**> 1 +0000\n"); buf.Append("committer A. U. Thor <*****@*****.**> 1 +0000\n"); buf.Append("\n"); buf.Append(msg); var walk = new GitSharp.Core.RevWalk.RevWalk(db); walk.setRetainBody(true); var c = new RevCommit(ObjectId.ZeroId); c.parseCanonical(walk, Constants.encode(buf.ToString())); return c; }
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); }
public override void setUp() { base.setUp(); util = new TestRepository(db, createRevWalk()); rw = util.getRevWalk(); }