GitOid.this

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.

  1. this(char[] hex)
    struct GitOid
    this
    (
    in char[] hex
    )
  2. this(inout(git_oid) oid)

Examples

// note: don't use an enum due to http://d.puremagic.com/issues/show_bug.cgi?id=10516
const srcHex = "49322bb17d3acc9146f98c97d078513228bbf3c0";
const oid = GitOid(srcHex);
const tgtHex = oid.toHex();

assert(tgtHex == srcHex);
// can convert from a partial string
const srcHex = "4932";
const oid = GitOid(srcHex);
const tgtHex = oid.toHex();

assert(tgtHex[0 .. 4] == srcHex);
assert(tgtHex[4 .. $].count('0') == tgtHex.length - 4);
/// cannot convert from a partial string smaller than MinHexSize
const smallHex = "493";
assertThrown!AssertError(GitOid(smallHex));

/// cannot convert from a string bigger than MinHexSize
const bigHex = std.array.replicate("1", MaxHexSize + 1);
assertThrown!AssertError(GitOid(bigHex));

Meta