1 // note: don't use an enum due to http://d.puremagic.com/issues/show_bug.cgi?id=10516
2 const srcHex = "49322bb17d3acc9146f98c97d078513228bbf3c0";
3 const oid = GitOid(srcHex);
4 const tgtHex = oid.toHex();
5
6 assert(tgtHex == srcHex);
1 // can convert from a partial string
2 const srcHex = "4932";
3 const oid = GitOid(srcHex);
4 const tgtHex = oid.toHex();
5
6 assert(tgtHex[0 .. 4] == srcHex);
7 assert(tgtHex[4 .. $].count('0') == tgtHex.length - 4);
1 /// cannot convert from a partial string smaller than MinHexSize
2 const smallHex = "493";
3 assertThrown!AssertError(GitOid(smallHex));
4
5 /// cannot convert from a string bigger than MinHexSize
6 const bigHex = std.array.replicate("1", MaxHexSize + 1);
7 assertThrown!AssertError(GitOid(bigHex));
Parse a full or partial hex-formatted object ID and create a GitOid object.
hex must be at least the size of MinHexSize, but not larger than MaxHexSize.