This repository has been archived by the owner. It is now read-only.

(npm-version) Ability to run npm version without automatically git-committing and tagging #7186

Closed
redben opened this Issue Jan 21, 2015 · 6 comments

Comments

Projects
None yet
4 participants
@redben
Copy link

redben commented Jan 21, 2015

Is it possible to run npm version without tagging or committing. It is a great feature but it might be better not to assume everybody has the same workflow. Or may be there is a flag I am not aware of that disables git related tasks ?

@KenanY

This comment has been minimized.

Copy link
Collaborator

KenanY commented Jan 21, 2015

I'm not sure if there's a flag for disabling the commit part, but there is a flag for the tagging part:

  • npm version --no-git-tag-version will do this for you
  • npm config set git-tag-version=false will turn it off globally, allowing you to opt in with --git-tag-version if you want it

https://docs.npmjs.com/misc/config#git-tag-version

This flag should be documented in the npm version docs too but unfortunately it isn't. There's an issue open for that: #6711

@smikes

This comment has been minimized.

Copy link
Contributor

smikes commented Jan 21, 2015

I note this http://blog.izs.me/post/1675072029/10-cool-things-you-probably-didnt-realize-npm

(Of course, if you’re not using git, then it won’t do the git stuff. It’ll just change the json and write it back to package.json.)

So it should be possible to add a flag that disables all the git stuff ; /cc @othiym23 open to a pull request?

@KenanY

This comment has been minimized.

Copy link
Collaborator

KenanY commented Jan 21, 2015

So, based on the logic I'm seeing in lib/version.js, setting git-tag-version to false (ie through npm version --no-git-tag-version) should disable both the committing and tagging:

  • version() calls checkGit()
  • checkGit() calls cb(null, false) because git-tag-version = false
  • call to commit() is never reached because hasGit is false now

Committing and tagging are done in the same function so since this function is never called with this config being false then neither committing nor tagging takes place.

Don't feel like testing that out at the moment 😛

@redben

This comment has been minimized.

Copy link

redben commented Jan 22, 2015

@KenanY just tried it and that's exactly it, it work as you explained !

So maybe --no-git-tag-version should be called something else for clarity like --no-git ?

Thank you guys.

@redben redben closed this Jan 22, 2015

@smikes

This comment has been minimized.

Copy link
Contributor

smikes commented Jan 23, 2015

So maybe --no-git-tag-version should be called something else for clarity like --no-git ?

For a moment I thought that might even work due to the way nopt handles abbreviated options, but unfortunately there's a conflict. You can see it here:

$ npm config ls -l | grep ^git
git = "git"
git-tag-version = true

Again due to nopt support for negative options, npm version minor --no-git gets interpreted as npm version minor --git=false which then sets the git internal config option (which should point to the git executable) to be false, with unfortunate results.

@redben

This comment has been minimized.

Copy link

redben commented Jan 25, 2015

@smikes thanks for the explanation.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.