Skip to content

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

@hammzj

Description

@hammzj

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 

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions