getCommitRange method

Future<GitCommitRange> getCommitRange(
  1. String projectPath, {
  2. String? fromTag,
  3. String? toCommit,
  4. int maxCount = 50,
})

Gets structured GitCommitRange between fromTag (or previous tag) and toCommit (default HEAD).

Implementation

Future<GitCommitRange> getCommitRange(
  String projectPath, {
  String? fromTag,
  String? toCommit,
  int maxCount = 50,
}) async {
  final targetTo =
      toCommit ?? await getCurrentCommitSha(projectPath) ?? 'HEAD';
  final targetFrom = fromTag ?? await getPreviousTag(projectPath);

  final commits = await getCommits(
    projectPath,
    fromRef: targetFrom,
    toRef: targetTo,
    maxCount: targetFrom == null ? maxCount : null,
  );

  String? fromCommitSha;
  if (targetFrom != null) {
    fromCommitSha = await _getRefCommitSha(projectPath, targetFrom);
  }

  return GitCommitRange(
    fromTag: targetFrom,
    fromCommit: fromCommitSha,
    toCommit: targetTo,
    commits: commits,
  );
}