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

Using "--amend" and "--message" options will not overwrite the original commit message #3936

Open
hammzj opened this issue Jan 11, 2024 · 2 comments · May be fixed by #3954
Open

Using "--amend" and "--message" options will not overwrite the original commit message #3936

hammzj opened this issue Jan 11, 2024 · 2 comments · May be fixed by #3954

Comments

@hammzj
Copy link

hammzj commented Jan 11, 2024

Current Behavior

When using --amend and --message, the commit will be amended but the message will remain unchanged. The --message option is not respected and will be implicitly ignored.

Examples:
lerna version minor --amend --message "My commit message"

lerna version publish minor --amend --message "My commit message"

Expected Behavior

  • The version/publish commands work as usual
  • The original commit is amended
  • The original commit is updated with the specified message from the flag: --message

The code below will accomplish everything above, but is not recommended due to pushing remote references twice:

#!/bin/bash
# 1. Let lerna tag versions, publish npm packages with new versions, then amend commit (using original commit message)
# 2. Push the commit to github. Creates new git tag as well
# 3. Redo the commit message to use a chore commit using some magic
# 4. Push the changes using the new commit message
lerna publish minor --amend --exact --yes
git push --follow-tags --force
version=$(node -p "require('./lerna.json').version")
description=$(cat ./.git/COMMIT_EDITMSG)
git commit --amend --message "[chore] publish packages $version" --message "$description"
git push --force

Steps to Reproduce

  • Change a source file in a repository and commit it with message "I changed a file"
  • Run lerna publish minor --amend --exact --message "This is a new commit message" --yes
  • Check repository
    • Git tags should be published correctly ✅
    • NPM packages should be published correctly ✅
    • Original commit amended with versioning changes/only 1 commit exists ✅
    • Commit message should be changed to "This is a new commit message"

This issue may not be prioritized if details are not provided to help us reproduce the issue.

Failure Logs / Configuration

lerna.json

{
  "npmClient": "yarn",
  "version": "2.934.0",
  "graphType": "all",
  "command": {
    "publish": {
      "registry": "https://npm.pkg.github.com/",
      "graphType": "all",
      "ignoreChanges": [
        "*.md"
      ]
    }
  }
}

Environment

npx lerna info:

lerna notice cli v4.0.0

 Environment info:
  System:
    OS: macOS 13.6.3
    CPU: (8) x64 Intel(R) Core(TM) i5-1038NG7 CPU @ 2.00GHz
  Binaries:
    Node: 18.16.0 - ~/.nvm/versions/node/v18.16.0/bin/node
    Yarn: 1.22.19 - ~/node_modules/.bin/yarn
    npm: 9.5.1 - ~/.nvm/versions/node/v18.16.0/bin/npm
  Utilities:
    Git: 2.39.0 - /usr/local/bin/git
  npmPackages:
    lerna: ^4.0.0 => 4.0.0 
@hammzj hammzj changed the title Using "--amend" and --message" options does not overwrite the original commit message Using "--amend" and "--message" options does not overwrite the original commit message Jan 11, 2024
@hammzj hammzj changed the title Using "--amend" and "--message" options does not overwrite the original commit message Using "--amend" and "--message" options will not overwrite the original commit message Jan 11, 2024
@amorscher amorscher linked a pull request Feb 6, 2024 that will close this issue
10 tasks
@amorscher
Copy link
Contributor

Why do you have to push two times? I think one push in the end with the correct message will be sufficient. This push you have to do anyway as amend will not push.

@hammzj
Copy link
Author

hammzj commented Feb 7, 2024

First push is to use lerna to increment packages + publish them; it also amends a squashed commit so that all changes are kept in a single commit instead of two.

The second push is to change the original commit message to a custom chore message using the version change made in the first push.

We've tried it many other ways, and while it's not pretty, it functions how it is expected. lerna --amend should allow a custom message when specified to override the message of the commit it amends.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants