getCurrentCommitSha method

Future<String?> getCurrentCommitSha(
  1. String projectPath, {
  2. bool short = true,
})

Gets full or short commit SHA of HEAD commit.

Implementation

Future<String?> getCurrentCommitSha(String projectPath,
    {bool short = true}) async {
  final args =
      short ? ['rev-parse', '--short', 'HEAD'] : ['rev-parse', 'HEAD'];
  final result = await _runner.run(
    'git',
    args,
    workingDirectory: projectPath,
  );
  if (result.exitCode != 0) return null;
  return result.stdout.toString().trim();
}