invertase / melos

🌋 A tool for managing Dart projects with multiple packages. With IntelliJ and Vscode IDE support. Supports automated versioning, changelogs & publishing via Conventional Commits.
https://melos.invertase.dev/~melos-latest
Apache License 2.0
1.13k stars 201 forks source link

fix: applyDiff and gitCommitsForPackage does not resolve to use the correct revision range #673

Closed xsahil03x closed 6 months ago

xsahil03x commented 6 months ago

Is there an existing issue for this?

Version

5.2.1

Description

Currently the applyDiff and gitCommitsForPackage does not use the correct resolved diif in case it's a valid range. We are not handling the case when the provided diff is infact a valid revision range.

https://github.com/invertase/melos/blob/main/packages/melos/lib/src/common/git.dart#L419-L428

  if (revisionRange != null) {
    if (revisionRange.isEmpty) {
      revisionRange = null;
    } else if (!_gitVersionRangeShortHandRegExp.hasMatch(revisionRange)) {
      // If the revision range is not a valid revision range short hand then we
      // assume it's a commit or tag and default to the range from that
      // commit/tag to HEAD.
      return '$revisionRange...HEAD';
    } else {
+     return revisionRange;
    }
  }

Steps to reproduce

Run any command which includes the --diff filter.

eg: melos exec --fail-fast --diff=origin/main...HEAD -c 1 --include-dependents -- flutter test

Expected behavior

It should use the correct revision range.

Screenshots

No response

Additional context and comments

No response