Skip to content

[BUG] npm-version does not git-commit nor git-tag when package in subdirectory #2010

@jasonkarns

Description

@jasonkarns

Current Behavior:

npm version <version> is not committing the modified package.json or package-lock.json; nor git-tagging.

We were using npm version {major|minor|patch} extensively (and successfully). It stopped working once the package was moved out of the root of the repo and into a subdirectory.

Expected Behavior:

npm version <version> should continue to create a git-commit and git-tag as indicated in the docs:

If run in a git repo, it will also create a version commit and tag. This behavior is controlled by git-tag-version (see below), and can be disabled on the command line by running npm --no-git-tag-version version. It will fail if the working directory is not clean, unless the -f or --force flag is set.

Steps To Reproduce:

  1. initialize an npm package in the root of an initialized git repo
  2. npm version minor successfully bumps the version, commits and tags
  3. move the npm package into a subdirectory of the repo
  4. npm version minor still bumps the version in package.json and package-lock.json, but git is not committed nor tagged.

Environment:

  • macOS 10.15.7
  • node: v14.13.1
  • npm: 6.14.8
  • git: git version 2.28.0

This is apparently an existing bug going as far back as npm v3: npm/npm#18795

Metadata

Metadata

Assignees

No one assigned

    Labels

    Bugthing that needs fixingPriority 2secondary priority issueRelease 7.xwork is associated with a specific npm 7 releaseRelease 8.xwork is associated with a specific npm 8 releasecmd:versionrelated to `npm version`

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions