getCurrentCommitSha method
Get the commit the directory at gitDirpath
is at.
Implementation
Future<String> getCurrentCommitSha({
required String gitDirpath,
Map<String, String>? environment,
bool includeParentEnvironment = true,
}) async {
final dir = checkDirectoryExists(gitDirpath, "gitDirpath");
final res = await runAsync(
["rev-parse", "HEAD"],
workingDirectory: dir.path,
environment: environment,
includeParentEnvironment: includeParentEnvironment,
);
if (0 != res.exitCode)
throw CliResultException(
exitCode: res.exitCode,
stderr: res.stderr,
message: "Failed to get the current commit sha from "
"the git directory at '$gitDirpath'",
);
return res.stdout.toString().trim();
}