semver icon indicating copy to clipboard operation
semver copied to clipboard

Initial Version Creation Fails on Some Git Repositories

Open mortalapeman opened this issue 2 years ago • 6 comments

Summary

When first running npx nx run <project>:version on some repositories where the command git rev-list --max-parents=0 HEAD returns more than 1 commit, the target fails with a "bad revision" error.

Steps to Recreate

  1. Create a git repo with an initial commit
  2. Create a second git repo with a commit and some history
  3. Use some stack overflow post to merge the two repos together that maintains history for both. The exact post I have unfortunately forgotten. Probably something to do with filter-branch.

Solution

Fix the output of this function so that it will split the results on newlines and just pick the first valid commit SHA. The current code ends up concating all the commit SHAs together resulting in an invalid ref.

Work Arounds

Manually create the first tag with <project>-0.0.1 and not <project>-0.0.0 because using 0.0.0 will result in the plugin trying to find that first commit in the repo.

mortalapeman avatar Nov 19 '21 20:11 mortalapeman

I was also noticing that the initial creation was failing unless I manually created a CHANGELOG.md for each project.

wSedlacek avatar Nov 28 '21 20:11 wSedlacek

@edbzn @mortalapeman is the fix for this the same as what #444 is requesting? Creating a CHANGELOG.md didn't work for me. Had to manually tag a version for a new library. @edbzn What do you think about the suggestion I made in #444? Would you accept a PR with it?

ianldgs avatar Aug 01 '22 10:08 ianldgs

@edbzn friendly ping. Engineers on our repo are having to manually create a tag when adding new libraries. This is not a good experience 🙈

ianldgs avatar Sep 30 '22 08:09 ianldgs

@ianldgs did you try the latest version? we merged a fix related to this

edbzn avatar Sep 30 '22 09:09 edbzn

We did not. Will try and let you know. Thanks for the heads-up!

ianldgs avatar Sep 30 '22 09:09 ianldgs

The error described in #444 (bad revision 'd9c06c.....HEAD') is gone, ~~but now I get:~~

[test-lib-version] ❌ Error: fatal: pathspec '/Users/me/code/frontend/libs/test-lib-version/CHANGELOG.md' did not match any files

Can work around by creating a changelog manually, but is that expected?

Edit: I only got that error on a --dryRun. It works now 🙃 Thanks again!

ianldgs avatar Sep 30 '22 10:09 ianldgs