getCommitShas method
Get a chronologically sorted list of all commits in the
git repository at gitDirpath
.
The first element in the list is the most recent commit.
Implementation
Future<List<String>> getCommitShas({
required String gitDirpath,
Map<String, String>? environment,
bool includeParentEnvironment = true,
}) async {
final dir = checkDirectoryExists(gitDirpath, "gitDirpath");
final res = await runAsync(
["log", "--format=%H"],
workingDirectory: dir.path,
environment: environment,
includeParentEnvironment: includeParentEnvironment,
);
if (0 != res.exitCode) {
throw CliResultException(
exitCode: res.exitCode,
stderr: res.stderr,
message: "Failed to get the commit shas from "
"the git directory at '$gitDirpath'",
);
}
return res.stdout
.toString()
.split("\n")
.where((e) => e.isNotEmpty)
.toList();
}