react-native-version icon indicating copy to clipboard operation
react-native-version copied to clipboard

fatal: no tag exactly matches 'id'

Open VinceBT opened this issue 7 years ago • 14 comments
trafficstars

Git version 2.17 on Windows My Git repo has many folders at the root and the app is in one of these folders image

VinceBT avatar Jun 01 '18 17:06 VinceBT

Looks like HEAD isn'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.

stovmascript avatar Jun 01 '18 22:06 stovmascript

Yes you are maybe correct. Such a behaviour would be great

VinceBT avatar Jun 02 '18 01:06 VinceBT

@VinceBT New version (2.6.1) is out now on npm.

stovmascript avatar Jun 02 '18 08:06 stovmascript

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 ? : https://github.com/stovmascript/react-native-version/blob/f5228b08e88beb97e3cf928a77ce75e7320b1cd4/index.js#L507

EDIT: Changing it to || did nothing

VinceBT avatar Jun 02 '18 09:06 VinceBT

Hm, weird. Here's what I just tried:

$ 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

LGTM

stovmascript avatar Jun 02 '18 21:06 stovmascript

Could you reopen this issue ? I still don't have the amend working even with latest version :(

VinceBT avatar Jun 04 '18 08:06 VinceBT

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.

stovmascript avatar Jun 04 '18 15:06 stovmascript

I think my issue is related to this https://github.com/npm/npm/issues/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: image

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

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

VinceBT avatar Jun 04 '18 19:06 VinceBT

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.

stovmascript avatar Jun 04 '18 22:06 stovmascript

@VinceBT Can you try out react-native-version@next (2.6.3-0) and see if that works ok?

stovmascript avatar Jun 06 '18 06:06 stovmascript

When using your new version I get this output and no git tag

[RNV] Versioning Android...
[RNV] Android updated
[RNV] Versioning iOS...
[RNV] iOS updated
[RNV] Amending...
[RNV] Done

But when creating a .git folder, I get this output and a git tag

[RNV] Versioning Android...
[RNV] Android updated
[RNV] Versioning iOS...
[RNV] iOS updated
[RNV] Amending...
[RNV] Adjusting Git tag...
[RNV] Done

The [RNV] Adjusting Git tag... step is triggered in the second case I dont have the double tag issue anymore

VinceBT avatar Jun 08 '18 17:06 VinceBT

Yeah, but isn't that what we want?

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.

stovmascript avatar Jun 08 '18 19:06 stovmascript

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.

christophliftoff avatar Aug 08 '23 13:08 christophliftoff

I fixed the problem by adding the missing .git folder to the apps/mobile folder.

Q. How can I check if my folder is missing? A. I checked on vs code for this.

  • Open Settings -> Search or type exclude -> find the pattern **/.git, remove it temporarily, and click ok.
  • Check for the .git folder in the main project directory and the apps/mobile folder.
  • If the .git folder is not in the apps/mobile folder, create it. [Leave it empty]
  • Now, execute your command, like yarn mobile:staging:release.

arafatalim avatar Jan 29 '24 15:01 arafatalim