Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: npm-version does not git-commit nor git-tag when package in subdirectory #4885

Closed
wants to merge 17 commits into from
Closed

fix: npm-version does not git-commit nor git-tag when package in subdirectory #4885

wants to merge 17 commits into from

Conversation

fernandopasik
Copy link

libnpmversion only checks one same dir if is git repo, instead use git.find to check parents as well

References

fixes #2010

@fernandopasik fernandopasik requested a review from a team as a code owner May 11, 2022 19:44
Copy link
Contributor

@fritzy fritzy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A test to verify the new behavior may be prudent.

Copy link
Contributor

@lukekarrys lukekarrys left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@fernandopasik Can you add a test case for this behavior?

@fernandopasik
Copy link
Author

@fernandopasik Can you add a test case for this behavior?

yes, I'll add the test case. I'm trying to understand why other tests have failed.

@timothybonci
Copy link

git is mocked in the tests - we don't use the package there.
'@npmcli/git': gitMock

@timothybonci
Copy link

@fernandopasik I opened a PR into yours with what I hope are the right changes for the tests. I'm a GitHub noob, so this may have been a dumb way of doing it, but you should be able to see the ideas. If this stays idle for a few days, I can open up my own MR into this repo with both our changes.

@fernandopasik
Copy link
Author

fernandopasik commented Jul 21, 2022

@timothybonci I've merged your changes, thanks!

@timothybonci
Copy link

How do we get the tests re-run? It looks like they only run once on PR open, but not on subsequent pushes, at least automatically. Are we waiting on a manual action by a maintainer?

@timothybonci
Copy link

I see failed tests from yesterday - it's not obvious to me why they're failing. I cloned the repo and can try and debug them, but I may not get to it until next week.

Fixing my silly mistake.  This fixes all but the last test.
Last test needs subdirectory evaluation
@timothybonci
Copy link

Just needed a good night's sleep. https://github.com/fernandopasik/cli/pull/2 fixes the tests.

use same directory in the setup and the tests
@timothybonci
Copy link

@lukekarrys Is this waiting on you now?

@darcyclarke darcyclarke added the semver:patch semver patch level for changes label Jul 26, 2022
@timothybonci
Copy link

I see the new failures, thanks.

@ruyadorno
Copy link
Contributor

I'm curious on how this will interact with workspaces, I believe it's important to make sure this change is not going to enable every npm version -w <ws-name> to commit/tag, at least not until npm/rfcs#570 is ready

@timothybonci
Copy link

According to this the design intent is to omit tagging when versioning workspaces. We can still create commits. I'll attempt to add a new condition before tagging that checks if we're in a workspace. This will require good tests, too.

@lukekarrys lukekarrys self-requested a review July 27, 2022 21:07
@timothybonci
Copy link

Having gotten more familiar with this, I'm leaning toward detecting workspaces, and then doing no tag and no commit. The convention we use in --git-tag-version false is "no tag, no commit". Inventing a new halfway commit with no tag for this use case doesn't seem wise.

* fix: look parent dirs to detect git repo on version

* Mock find and test with subdirectories

* refactor: use let instead of var

* style: use single quotes

* Revert "refactor: use let instead of var"

This reverts commit 2e40ec9.

* use same directory in the setup and the tests

Fixing my silly mistake.  This fixes all but the last test.

* Fix final test

Last test needs subdirectory evaluation

Co-authored-by: fernandopasik <fernando@pasik.com.ar>
@timothybonci
Copy link

I think I've got the workspace case covered now. https://github.com/fernandopasik/cli/pull/3
As I say in that PR, I'm not that skilled in Node, so I may have missed something silly/obvious to a seasoned dev.

@timothybonci
Copy link

Something I thought about, but didn't implement - should --f always result in a commit, even in the workspaces case? It seems like the universal "let you do otherwise unwise things" but I worry about how overloaded it could get, turning into a footgun. I'd love to get feedback on this if it's desirable.

@fernandopasik
Copy link
Author

fernandopasik commented Aug 10, 2022

@timothybonci almost all the work here is yours, please feel free to open a new PR with all the changes so I don't delay you.
If you do link it here and I will close my PR

@timothybonci
Copy link

timothybonci commented Aug 30, 2022

Thanks for starting this @fernandopasik. I've opened #5442 as a fresh start with my proposed changes.

@fernandopasik
Copy link
Author

No problem, thanks for your contributions too.

@fernandopasik fernandopasik deleted the version-subdirectory-fix branch August 30, 2022 20:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
semver:patch semver patch level for changes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[BUG] npm-version does not git-commit nor git-tag when package in subdirectory
7 participants