public virtual void TestConstructor_PeeledStatusNotKnown() { ObjectIdRef r; r = new ObjectIdRef.Unpeeled(RefStorage.LOOSE, name, ID_A); NUnit.Framework.Assert.AreEqual(RefStorage.LOOSE, r.GetStorage()); NUnit.Framework.Assert.AreSame(name, r.GetName()); NUnit.Framework.Assert.AreSame(ID_A, r.GetObjectId()); NUnit.Framework.Assert.IsFalse(r.IsPeeled(), "not peeled"); NUnit.Framework.Assert.IsNull(r.GetPeeledObjectId(), "no peel id"); NUnit.Framework.Assert.AreSame(r, r.GetLeaf(), "leaf is this"); NUnit.Framework.Assert.AreSame(r, r.GetTarget(), "target is this"); NUnit.Framework.Assert.IsFalse(r.IsSymbolic(), "not symbolic"); r = new ObjectIdRef.Unpeeled(RefStorage.PACKED, name, ID_A); NUnit.Framework.Assert.AreEqual(RefStorage.PACKED, r.GetStorage()); r = new ObjectIdRef.Unpeeled(RefStorage.LOOSE_PACKED, name, ID_A); NUnit.Framework.Assert.AreEqual(RefStorage.LOOSE_PACKED, r.GetStorage()); r = new ObjectIdRef.Unpeeled(RefStorage.NEW, name, null); NUnit.Framework.Assert.AreEqual(RefStorage.NEW, r.GetStorage()); NUnit.Framework.Assert.AreSame(name, r.GetName()); NUnit.Framework.Assert.IsNull(r.GetObjectId(), "no id on new ref"); NUnit.Framework.Assert.IsFalse(r.IsPeeled(), "not peeled"); NUnit.Framework.Assert.IsNull(r.GetPeeledObjectId(), "no peel id"); NUnit.Framework.Assert.AreSame(r, r.GetLeaf(), "leaf is this"); NUnit.Framework.Assert.AreSame(r, r.GetTarget(), "target is this"); NUnit.Framework.Assert.IsFalse(r.IsSymbolic(), "not symbolic"); }
public virtual void TestConstructor_PeeledStatusNotKnown() { ObjectIdRef r; r = new ObjectIdRef.Unpeeled(RefStorage.LOOSE, name, ID_A); NUnit.Framework.Assert.AreEqual(RefStorage.LOOSE, r.GetStorage()); NUnit.Framework.Assert.AreSame(name, r.GetName()); NUnit.Framework.Assert.AreSame(ID_A, r.GetObjectId()); NUnit.Framework.Assert.IsFalse(r.IsPeeled(), "not peeled"); NUnit.Framework.Assert.IsNull(r.GetPeeledObjectId(), "no peel id"); NUnit.Framework.Assert.AreSame(r, r.GetLeaf(), "leaf is this"); NUnit.Framework.Assert.AreSame(r, r.GetTarget(), "target is this"); NUnit.Framework.Assert.IsFalse(r.IsSymbolic(), "not symbolic"); r = new ObjectIdRef.Unpeeled(RefStorage.PACKED, name, ID_A); NUnit.Framework.Assert.AreEqual(RefStorage.PACKED, r.GetStorage()); r = new ObjectIdRef.Unpeeled(RefStorage.LOOSE_PACKED, name, ID_A); NUnit.Framework.Assert.AreEqual(RefStorage.LOOSE_PACKED, r.GetStorage()); r = new ObjectIdRef.Unpeeled(RefStorage.NEW, name, null); NUnit.Framework.Assert.AreEqual(RefStorage.NEW, r.GetStorage()); NUnit.Framework.Assert.AreSame(name, r.GetName()); NUnit.Framework.Assert.IsNull(r.GetObjectId(), "no id on new ref"); NUnit.Framework.Assert.IsFalse(r.IsPeeled(), "not peeled"); NUnit.Framework.Assert.IsNull(r.GetPeeledObjectId(), "no peel id"); NUnit.Framework.Assert.AreSame(r, r.GetLeaf(), "leaf is this"); NUnit.Framework.Assert.AreSame(r, r.GetTarget(), "target is this"); NUnit.Framework.Assert.IsFalse(r.IsSymbolic(), "not symbolic"); }
public virtual void TestConstructor_Peeled() { ObjectIdRef r; r = new ObjectIdRef.Unpeeled(RefStorage.LOOSE, name, ID_A); NUnit.Framework.Assert.AreEqual(RefStorage.LOOSE, r.GetStorage()); NUnit.Framework.Assert.AreSame(name, r.GetName()); NUnit.Framework.Assert.AreSame(ID_A, r.GetObjectId()); NUnit.Framework.Assert.IsFalse(r.IsPeeled(), "not peeled"); NUnit.Framework.Assert.IsNull(r.GetPeeledObjectId(), "no peel id"); NUnit.Framework.Assert.AreSame(r, r.GetLeaf(), "leaf is this"); NUnit.Framework.Assert.AreSame(r, r.GetTarget(), "target is this"); NUnit.Framework.Assert.IsFalse(r.IsSymbolic(), "not symbolic"); r = new ObjectIdRef.PeeledNonTag(RefStorage.LOOSE, name, ID_A); NUnit.Framework.Assert.IsTrue(r.IsPeeled(), "is peeled"); NUnit.Framework.Assert.IsNull(r.GetPeeledObjectId(), "no peel id"); r = new ObjectIdRef.PeeledTag(RefStorage.LOOSE, name, ID_A, ID_B); NUnit.Framework.Assert.IsTrue(r.IsPeeled(), "is peeled"); NUnit.Framework.Assert.AreSame(ID_B, r.GetPeeledObjectId()); }
public virtual void TestForceRemotesOrigin() { string srcn = "refs/heads/*"; string dstn = "refs/remotes/origin/*"; RefSpec rs = new RefSpec("+" + srcn + ":" + dstn); NUnit.Framework.Assert.IsTrue(rs.IsForceUpdate()); NUnit.Framework.Assert.IsTrue(rs.IsWildcard()); NUnit.Framework.Assert.AreEqual(srcn, rs.GetSource()); NUnit.Framework.Assert.AreEqual(dstn, rs.GetDestination()); NUnit.Framework.Assert.AreEqual("+" + srcn + ":" + dstn, rs.ToString()); NUnit.Framework.Assert.AreEqual(rs, new RefSpec(rs.ToString())); Ref r; RefSpec expanded; r = new ObjectIdRef.Unpeeled(RefStorage.LOOSE, "refs/heads/master", null); NUnit.Framework.Assert.IsTrue(rs.MatchSource(r)); NUnit.Framework.Assert.IsFalse(rs.MatchDestination(r)); expanded = rs.ExpandFromSource(r); NUnit.Framework.Assert.AreNotSame(rs, expanded); NUnit.Framework.Assert.IsTrue(expanded.IsForceUpdate()); NUnit.Framework.Assert.IsFalse(expanded.IsWildcard()); NUnit.Framework.Assert.AreEqual(r.GetName(), expanded.GetSource()); NUnit.Framework.Assert.AreEqual("refs/remotes/origin/master", expanded.GetDestination ()); r = new ObjectIdRef.Unpeeled(RefStorage.LOOSE, "refs/remotes/origin/next", null); NUnit.Framework.Assert.IsFalse(rs.MatchSource(r)); NUnit.Framework.Assert.IsTrue(rs.MatchDestination(r)); r = new ObjectIdRef.Unpeeled(RefStorage.LOOSE, "refs/tags/v1.0", null); NUnit.Framework.Assert.IsFalse(rs.MatchSource(r)); NUnit.Framework.Assert.IsFalse(rs.MatchDestination(r)); }
/// <exception cref="NGit.Errors.TransportException"></exception> private Ref ReadRef(SortedDictionary<string, Ref> avail, string rn) { string s; string @ref = WalkRemoteObjectDatabase.ROOT_DIR + rn; try { BufferedReader br = this.OpenReader(@ref); try { s = br.ReadLine(); } finally { br.Close(); } } catch (FileNotFoundException) { return null; } catch (IOException err) { throw new TransportException(this.GetURI(), MessageFormat.Format(JGitText.Get().transportExceptionReadRef , @ref), err); } if (s == null) { throw new TransportException(this.GetURI(), MessageFormat.Format(JGitText.Get().transportExceptionEmptyRef , rn)); } if (s.StartsWith("ref: ")) { string target = Sharpen.Runtime.Substring(s, "ref: ".Length); Ref r = avail.Get(target); if (r == null) { r = this.ReadRef(avail, target); } if (r == null) { r = new ObjectIdRef.Unpeeled(RefStorage.NEW, target, null); } r = new SymbolicRef(rn, r); avail.Put(r.GetName(), r); return r; } if (ObjectId.IsId(s)) { Ref r = new ObjectIdRef.Unpeeled(this.Loose(avail.Get(rn)), rn, ObjectId.FromString (s)); avail.Put(r.GetName(), r); return r; } throw new TransportException(this.GetURI(), MessageFormat.Format(JGitText.Get().transportExceptionBadRef , rn, s)); }
public virtual void TestConstructor_Peeled() { ObjectIdRef r; r = new ObjectIdRef.Unpeeled(RefStorage.LOOSE, name, ID_A); NUnit.Framework.Assert.AreEqual(RefStorage.LOOSE, r.GetStorage()); NUnit.Framework.Assert.AreSame(name, r.GetName()); NUnit.Framework.Assert.AreSame(ID_A, r.GetObjectId()); NUnit.Framework.Assert.IsFalse(r.IsPeeled(), "not peeled"); NUnit.Framework.Assert.IsNull(r.GetPeeledObjectId(), "no peel id"); NUnit.Framework.Assert.AreSame(r, r.GetLeaf(), "leaf is this"); NUnit.Framework.Assert.AreSame(r, r.GetTarget(), "target is this"); NUnit.Framework.Assert.IsFalse(r.IsSymbolic(), "not symbolic"); r = new ObjectIdRef.PeeledNonTag(RefStorage.LOOSE, name, ID_A); NUnit.Framework.Assert.IsTrue(r.IsPeeled(), "is peeled"); NUnit.Framework.Assert.IsNull(r.GetPeeledObjectId(), "no peel id"); r = new ObjectIdRef.PeeledTag(RefStorage.LOOSE, name, ID_A, ID_B); NUnit.Framework.Assert.IsTrue(r.IsPeeled(), "is peeled"); NUnit.Framework.Assert.AreSame(ID_B, r.GetPeeledObjectId()); }