You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
$ npm version patch
$ react-native-version -a
# commit amended, git tag adjusted
$ npm version patch
# another test commit
$ react-native-version -a
# commit amended, no git tag adjusted
I'm going to need a reproducible example in order to dig deeper.
From your description I gather that you have something like a monorepo with multiple projects or apps in it. This shouldn't be a problem. However, about Git tags... Do you utilize them somehow in the other apps? Do you skip tag creation (--no-git-tag-version or disabling in npm config) when using npm version ... or are you using default settings?
AFAIK Git tags are global inside a repo, so they can be overwritten by the other apps.
Since my app is inside a subfolder, it doesnt not create a tag, so there is nothing to amend.
I've adapted my package.json to look like that:
But when using npm version, it creates two tags now:
EDIT:
I think this ticket can be closed and a second known issue can be added to your readme haha
If you can help me on the double tag issue tell me if I need to create a second issue of if there is a simple fix
Hm, wasn't aware of this. Maybe a check that Git exists in that directory should also be added. npm version simply skips tag creation if there isn't a .git/ directory. I think we should mirror that behaviour.
With "preversion": "mkdir .git", when you run npm version and the Git tag for that version does not exist in your repo, it will create the tag and proceed with "postversion": "react-native-version --amend", which will find the tag and adjust it to point to the amended commit.
If the Git tag already exists in the repo, npm version will throw an error because it does not use the --force option like RNV does.
But I have found and issue in the case when there is no .git/ folder, npm version will skip creating a Git tag and will not even commit the changes in package.json. RNV will then do its work and amend the current commit in error. The same commit validation we do for determining when to search for Git tags should be added before amending.
For me this was happening when I would try and run the react-native-version script without committing my changes. It seems that you can only run this script once per commit? Otherwise I'd get the error you shared above.
Activity
stovmascript commentedon Jun 1, 2018
Looks like
HEADisn't pointing to any Git tag. Is that correct?Thought: Maybe RNV should just skip adjusting Git tags when it doesn't find any, instead of throwing.
VinceBT commentedon Jun 2, 2018
Yes you are maybe correct. Such a behaviour would be great
WIP #53 Find Git tag only if valid npm-version commit
Fix #53 Look for Git tag only if HEAD is a valid npm-version commit
Merge pull request #54 from stovmascript/issue-53
stovmascript commentedon Jun 2, 2018
@VinceBT New version (2.6.1) is out now on npm.
VinceBT commentedon Jun 2, 2018
I used --amend to try your modification and got the same error, I'm on 2.6.1
Could the
&&be the reason of the bug here ? :react-native-version/index.js
Line 507 in f5228b0
EDIT: Changing it to || did nothing
stovmascript commentedon Jun 2, 2018
Hm, weird. Here's what I just tried:
LGTM
VinceBT commentedon Jun 4, 2018
Could you reopen this issue ? I still don't have the amend working even with latest version :(
stovmascript commentedon Jun 4, 2018
I'm going to need a reproducible example in order to dig deeper.
From your description I gather that you have something like a monorepo with multiple projects or apps in it. This shouldn't be a problem. However, about Git tags... Do you utilize them somehow in the other apps? Do you skip tag creation (
--no-git-tag-versionor disabling in npm config) when usingnpm version ...or are you using default settings?AFAIK Git tags are global inside a repo, so they can be overwritten by the other apps.
VinceBT commentedon Jun 4, 2018
I think my issue is related to this npm/npm#9111
Since my app is inside a subfolder, it doesnt not create a tag, so there is nothing to amend.
I've adapted my package.json to look like that:

But when using npm version, it creates two tags now:

EDIT:
I think this ticket can be closed and a second known issue can be added to your readme haha
If you can help me on the double tag issue tell me if I need to create a second issue of if there is a simple fix
stovmascript commentedon Jun 4, 2018
Hm, wasn't aware of this. Maybe a check that Git exists in that directory should also be added.
npm versionsimply skips tag creation if there isn't a.git/directory. I think we should mirror that behaviour.WIP #53
Fix #53 Mirror npm-version's functionality for Git tag creation
stovmascript commentedon Jun 6, 2018
@VinceBT Can you try out
react-native-version@next(2.6.3-0) and see if that works ok?VinceBT commentedon Jun 8, 2018
When using your new version I get this output and no git tag
But when creating a .git folder, I get this output and a git tag
The
[RNV] Adjusting Git tag...step is triggered in the second caseI dont have the double tag issue anymore
stovmascript commentedon Jun 8, 2018
Yeah, but isn't that what we want?
With
"preversion": "mkdir .git", when you runnpm versionand the Git tag for that version does not exist in your repo, it will create the tag and proceed with"postversion": "react-native-version --amend", which will find the tag and adjust it to point to the amended commit.If the Git tag already exists in the repo,
npm versionwill throw an error because it does not use the--forceoption like RNV does.But I have found and issue in the case when there is no
.git/folder,npm versionwill skip creating a Git tag and will not even commit the changes inpackage.json. RNV will then do its work and amend the current commit in error. The same commit validation we do for determining when to search for Git tags should be added before amending.christophliftoff commentedon Aug 8, 2023
For me this was happening when I would try and run the
react-native-versionscript without committing my changes. It seems that you can only run this script once per commit? Otherwise I'd get the error you shared above.arafatalim commentedon Jan 29, 2024
I fixed the problem by adding the missing
.gitfolder to theapps/mobilefolder.Q. How can I check if my folder is missing?
A. I checked on
vs codefor this.Settings-> Search or typeexclude-> find the pattern**/.git, remove it temporarily, and clickok..gitfolder in the main project directory and theapps/mobilefolder..gitfolder is not in theapps/mobilefolder, create it. [Leave it empty]yarn mobile:staging:release.