cli icon indicating copy to clipboard operation
cli copied to clipboard

fix: version does not git-commit nor git-tag when package in subdir

Open timothybonci opened this issue 3 years ago • 15 comments

Change the git detection to use git.find in order to walk up through directories to find the git repo.

Add use case for detecting if you're in a subdirectory that is a workspace, and make that case the exception for creating the commit and tag.

References

Fixes #2010

timothybonci avatar Aug 30 '22 19:08 timothybonci

Thanks for the new PR for this @timothybonci! It looks good so far, but CI is showing a few more tests in test/lib/commands/version.js that are failing now. Would you be able to look at those too?

lukekarrys avatar Sep 21 '22 22:09 lukekarrys

Yep, I missed that test locally. Thanks for kicking off the workflows, and thanks for fixing the git config in the .github ci. I'll fire up the debugger.

timothybonci avatar Sep 22 '22 00:09 timothybonci

Aha, there was a bug in the internal caller in lib/commands/version.js where we were passing the flag instead of the option property, so we were never properly overriding gitTagVersion with false. These tests were passing before because we'd short circuit the doGit check on git.is returning false. Now that we use git.find and find the repo, we pass to the next check for doGit, which properly fails. Now that it's fixed, we short circuit on the very first check for gitTagVersion, and correctly don't attempt any git operations.

Long story short, I think I fixed it. I'd appreciate another run of the workflows.

timothybonci avatar Sep 23 '22 13:09 timothybonci

@lukekarrys would you please approve the test workflows to test the latest changes?

timothybonci avatar Oct 10 '22 13:10 timothybonci

Rebased to latest and fixed the two outstanding lint issues.

timothybonci avatar Oct 20 '22 21:10 timothybonci

Rebased to latest again. @lukekarrys could you review?

timothybonci avatar Oct 28 '22 15:10 timothybonci

Sorry for the delay in reviewing this @timothybonci. I am out for a few weeks and will review it when I get back. Thanks for your continued work on this!

lukekarrys avatar Nov 13 '22 01:11 lukekarrys

@lukekarrys are there any updates on this? It has been quite a few weeks. As a newcomer to NPM, I wasted a lot of time trying to figure out why this feature is not working according to docs :(.

1oglop1 avatar Mar 04 '23 08:03 1oglop1

bumping because I need this feature.

martinmiglio avatar May 19 '23 23:05 martinmiglio

This would be extremely helpful to get merged. I've wasted a few days trying to understand why this behavior is different from the official docs. Workarounds are nice, but it's better to get it fixed properly.

markhougaard avatar May 25 '23 14:05 markhougaard

~~Typically we try to avoid unit tests like those written in test/is-workspace-safe.js~~

~~Our testing approach is that we need to be able to reach it all from the surface area of the module itself. Unit testing in npm has historically led to a lot of dead code and unneeded complexity handling cases that were impossible in whole.~~

~~It's fine to test those things in a separate file for organization but they need to reach those lines of code through libnpmversion itself, not by requiring the module directly.~~

ETA: it looks like this repo is still all unit tests. We're not asking you to implement this so the unit test will have to do for now

wraithgar avatar May 25 '23 14:05 wraithgar

We're also urgently waiting for this bugfix.

@lukekarrys @wraithgar - If I understand the latest comment correctly, the PR is now ready to be merged? If not, what still needs to be done?

Thank you all for your engagement in this product!

Stehsegler avatar Aug 22 '23 09:08 Stehsegler

@lukekarrys @wraithgar @timothybonci Wondering if there will be an progress made on this PR for this bug fix?

dmcweeney avatar Nov 10 '23 14:11 dmcweeney

I think what's left is to fix the merge conflicts and to make sure we're ok with the tag it will make. Workspaces need to be tagged differently than the root project because without any changes they will collide with each other and the root project (since the tag is only the version, it's not namespaced in any way)

wraithgar avatar Nov 13 '23 14:11 wraithgar

After a year of silence, I'm not going to contribute further. I'm relinquishing any possible claims I may have on anything I've written in these commits/MR. I wish you all the best of luck.

timothybonci avatar Dec 29 '23 17:12 timothybonci