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: preVersionCommit script is not executed #460

Closed
1 task done
fischerscode opened this issue Feb 4, 2023 · 2 comments · Fixed by #466
Closed
1 task done

fix: preVersionCommit script is not executed #460

fischerscode opened this issue Feb 4, 2023 · 2 comments · Fixed by #466
Assignees
Labels
bug Something isn't working

Comments

@fischerscode
Copy link
Contributor

Is there an existing issue for this?

  • I have searched the existing issues.

Version

2.9.0 (#456)

Description

The documentation says:

preVersionCommit: Runs before the version commit is created. Allows you to make your own changes as part of versioning. You need to stage changes that you make yourself.

But it seems like a script called version has to be created.

if (workspace.config.scripts.containsKey('version')) {
logger.log('Running "version" lifecycle script...\n');
await run(scriptName: 'version');
}

Steps to reproduce

  1. Create a script called preVersionCommit that changes files, like
    preVersionCommit: dart run scripts/generate_version.dart
  2. Run melos version

Expected behavior

The script preVersionCommit should be executed and the changed files should be commited (you might have to git add them in the script).

Screenshots

No response

Additional context and comments

I actually run the version from #456, but when reading the code, the behavior should be the same for 2.9.0.

Maybe I'm the problem, but when renaming the script preVersionCommit to version, everything works fine.

One might argue it's a documentation mistake instead of a bug.

Additional:
postversion is not documented.

if (workspace.config.scripts.containsKey('postversion')) {
logger.log('Running "postversion" lifecycle script...\n');
await run(scriptName: 'postversion');
}

@fischerscode fischerscode added bug Something isn't working Needs: Triage The issue needs triaging labels Feb 4, 2023
@blaugold
Copy link
Collaborator

blaugold commented Feb 4, 2023

@fischerscode Sorry you are running into this problem. A few days back, I refactored the command hooks a bit to make them more consistent. As part of that, the version hook became preVersionCommit. Unfortunately, the docs are a bit ahead of the last release because there currently is no mechanism to version the docs. I'm currently working towards 3.0.0 of Melos and hope to get there in the next few days.

@blaugold blaugold removed the Needs: Triage The issue needs triaging label Feb 4, 2023
@fischerscode
Copy link
Contributor Author

@blaugold No worries, melos is such a great tool, and a few minor bugs should always be expected when using open source software. I just feel like it's the responsibility of the users to report bugs / unexpected behavior.

Just an idea for the 3.0 release:

As an user, I feel like it would be better if there would be a dedicated section called hooks.
name: Example
packages:
 #....

scripts:
  # ....

hooks:
  version: echo "Do something"
  postversion: echo "Something else"
Or if the hooks would be a part of the commands section.
name: Example
packages:
 #....

commands:
  version:
    preCommitHook: echo "do something"
    preVersionHook: echo "..."
    postCommitHook: echo "..."
  bootstrap:
    preHook: ...
    postHook: ...

Feel free to close this issue whenever you feel like it.

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

Successfully merging a pull request may close this issue.

2 participants