-
-
Notifications
You must be signed in to change notification settings - Fork 425
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: preserve merge states in submodules #769
Conversation
Codecov Report
@@ Coverage Diff @@
## master #769 +/- ##
=====================================
Coverage 100% 100%
=====================================
Files 13 13
Lines 429 439 +10
Branches 97 100 +3
=====================================
+ Hits 429 439 +10
Continue to review full report at Codecov.
|
lib/resolveGitRepo.js
Outdated
|
||
const buffer = await readBufferFromFile(defaultDir) | ||
const dotGit = buffer.toString() | ||
const gitConfigDir = path.resolve(dotGit.replace(/^gitdir: /, '')) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe it does not work properly because of this line. It takes path relative to node_modules or package.json (not sure), and from this going up a directory. I think it should be something like
const gitConfigDir = path.resolve(gitDir + '/' + dotGit.replace(/^gitdir: /, ''))
but probably better written
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for catching this. I tested it myself locally and the path in .git
seems to be relative to the gitDir
, so that would be better indeed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
one more thing, in my case
dotGit.replace(/^gitdir: /, '')
contains new line at the end, so it tries to read from
path/path/path
MERGE_MSG
when i add .trim() after replace it reads from proper path.
With this change and above change to path it works great in my case 🥇
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Those following newlines could use some trimming in other places as well, let me fix... thanks for testing!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done! Maybe a re-test just in case?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Works great now
🎉 This PR is included in version 10.0.1 🎉 The release is available on: Your semantic-release bot 📦🚀 |
This PR fixes the behaviour of lint-staged during merge conflicts in git submodules. The issue was that in a git submodule, the
.git
directory is actually a file containing a reference to the actual directory (that is located inside the parent repo's.git
directory).The fix includes detecting whether the current repo is a submodule by running
git rev-parse --show-superproject-working-tree
, which will only output a path when run inside a submodule. When this is true, the true.git
location is read from the submodule's file. This resolved path is then passed to the maingitWorkflow
instead of it assuming that the.git
directory is always at the root of the repo/submodule.Fixes #768
Thanks to @armata007 for the bug report.