Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: melos exec --diff=HEAD does not detect uncommitted changes #759

Open
1 task done
motucraft opened this issue Sep 21, 2024 · 0 comments
Open
1 task done

fix: melos exec --diff=HEAD does not detect uncommitted changes #759

motucraft opened this issue Sep 21, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@motucraft
Copy link

motucraft commented Sep 21, 2024

Is there an existing issue for this?

  • I have searched the existing issues.

Version

6.1.0

Description

When using the melos exec --diff=HEAD command, I expected it to detect uncommitted changes and run the command in the affected packages. However, even though there are uncommitted changes, Melos detects 0 packages and does not execute the command.

To demonstrate this issue, I have prepared a sample project that can be found here:
melos_git_diff_issue

Steps to reproduce

  1. Clone the project from melos_git_diff_issue.
  2. Make some changes to a file in one of the packages (without committing).
  3. Run git diff HEAD to confirm that there are uncommitted changes.
  4. Execute the following command (Mac):
    melos exec --diff=HEAD -- basename $(pwd)
  5. Observe that Melos detects 0 packages, even though changes exist.

Expected behavior

According to the official documentation, the --diff filter should "filter packages based on whether there were changes between a commit and the current HEAD or within a range of commits."

I expected Melos to detect uncommitted changes between the last commit (HEAD) and the working directory, and then execute the specified command in those affected packages. Specifically, any package with changes between the latest commit and the current working directory should be included, and the command should run in those packages.

packageFilters is expected to behave similarly, allowing packages to be filtered based on changes between commits or the working directory.

Screenshots

Here are the relevant logs from running melos analyze and melos exec --diff=HEAD:

melos analyze
% melos analyze                            
$ melos analyze
  └> /Users/motoki.osaki/github/motucraft/melos_git_diff_issue/.fvm/flutter_sdk/bin/dart analyze 
     └> RUNNING (in 4 packages)

-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
bar:
Analyzing bar...
No issues found!
bar: SUCCESS
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
baz:
Analyzing baz...
No issues found!
baz: SUCCESS
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
foo:
Analyzing foo...
No issues found!
foo: SUCCESS
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
sample_app:
Analyzing sample_app...
No issues found!
sample_app: SUCCESS
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

$ melos analyze
  └> /Users/motoki.osaki/github/motucraft/melos_git_diff_issue/.fvm/flutter_sdk/bin/dart analyze 
     └> SUCCESS
  • git diff
% git diff HEAD                            
diff --git a/packages/baz/lib/baz.dart b/packages/baz/lib/baz.dart
index ec73657..01bf9f8 100644
--- a/packages/baz/lib/baz.dart
+++ b/packages/baz/lib/baz.dart
@@ -7,6 +7,6 @@ class Baz extends StatelessWidget {
 
   @override
   Widget build(BuildContext context) {
-    return const Text('Baz', style: TextStyle(fontSize: 24));
+    return const Text('baz', style: TextStyle(fontSize: 24));
   }
 }
  • melos exec
% melos exec --diff=HEAD -- basename $(pwd)
$ melos exec> basename /Users/motoki.osaki/github/motucraft/melos_git_diff_issue
     └> RUNNING (in 0 packages)

-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

$ melos exec> basename /Users/motoki.osaki/github/motucraft/melos_git_diff_issue
     └> SUCCESS

Additional context and comments

No response

@motucraft motucraft added the bug Something isn't working label Sep 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant