GitHash constructor

GitHash(
  1. String sha
)

Implementation

GitHash(String sha) {
  if (sha.length != 40) {
    throw Exception('Hash size is not 40');
  }

  _bytes = Uint8List(20);
  var j = 0;
  for (var i = 0; i < sha.length; i += 2) {
    var hexChar = sha.substring(i, i + 2);
    var num = int.tryParse(hexChar, radix: 16);
    if (num == null) {
      throw GitHashStringNotHexadecimal();
    }
    _bytes[j] = num;
    j++;
  }
}