getRepoRemoteHash function

Future<String?> getRepoRemoteHash({
  1. String? cwd,
})

Returns a SHA256 hash (first 16 chars) of the normalized git remote URL.

Implementation

Future<String?> getRepoRemoteHash({String? cwd}) async {
  final remoteUrl = await getRemoteUrl(cwd: cwd);
  if (remoteUrl == null) return null;

  final normalized = normalizeGitRemoteUrl(remoteUrl);
  if (normalized == null) return null;

  final hash = sha256.convert(utf8.encode(normalized)).toString();
  return hash.substring(0, 16);
}