-
Notifications
You must be signed in to change notification settings - Fork 554
fix(cli): determine correct location of COMMIT_EDITMSG
#737
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
Conversation
src/git/commit.js
Outdated
@@ -50,7 +50,8 @@ function commit (repoPath, message, options, done) { | |||
} | |||
}); | |||
} else { | |||
const commitFilePath = path.join(repoPath, '/.git/COMMIT_EDITMSG'); | |||
const gitDirPath = execSync('git rev-parse --absolute-git-dir', { encoding: 'utf8' }).trim(); |
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.
This should be run in the repoPath
, right?
const gitDirPath = execSync('git rev-parse --absolute-git-dir', { encoding: 'utf8' }).trim(); | |
const gitDirPath = execSync('git rev-parse --absolute-git-dir', { encoding: 'utf8', cwd: repoPath }).trim(); |
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.
Yes, it should – Good catch. I will make the change (test needs to be changed, too) and report back. :)
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 applied the suggested change and it made any changes to the tests unnecessary. If I would have been aware that the tests create their own git environment I wouldn't have created the stub in the first place, sorry, my bad. 😄 I (force-)pushed the changes – Thanks again for catching this!
If using git working trees, then `.git` is a file and not a directory: This file references its own git directory within the main working tree. `$ git rev-parse --git-dir` will always return the directory where the `COMMIT_EDITMSG` file should be placed.
Codecov Report
|
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.
Neat 👍
Hello @LinusU, is there anything we can help to merge this PR? |
🎉 This PR is included in version 4.1.4 🎉 The release is available on: Your semantic-release bot 📦🚀 |
* fix: git-cz commit repoPath * chore(deps): bump minimist from 1.2.0 to 1.2.3 (#721) Bumps [minimist](https://github.com/substack/minimist) from 1.2.0 to 1.2.3. - [Release notes](https://github.com/substack/minimist/releases) - [Commits](https://github.com/substack/minimist/compare/1.2.0...1.2.3) Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * chore(deps): update dependency nyc to v15 (#704) Co-authored-by: Renovate Bot <[email protected]> * fix: add babel spread plugin * fix: move to babel.config.js * fix: update azure devops images * docs: add commitiquette (#727) * fix(deps): bump vulnerable packages * feature: remove dependency on ShellJS (#729) * feature: avoid dependning on shelljs * refactor: remove shelljs from tests * refactor: simplify configLoader call * fix: use shell flag when spawning npm init Co-authored-by: hdmr14 <[email protected]> * refactor: remove unused function isArray * refactor: remove unused function isString Co-authored-by: hdmr14 <[email protected]> * feat: remove dependency on ShellJS (#729) Empty commit to trigger release. * fix(deps): update dependency cz-conventional-changelog to v3.2.0 (#657) Co-authored-by: Renovate Bot <[email protected]> * fix: restore commitizen.congifLoader.load to public API (#733) * fix: restore commitizen.congifLoader.load to public API This reverts commit 468e924. * chore: temporarily skip failing test * fix: make cwd argument optional again (#735) * docs: add .czrc support to README (#739) * fix(deps): upgrade lodash to 4.17.20 and update package lock file * docs: add cz-format-extension (#758) * docs: Update `commitlint` adapter link (#751) * docs: Update `commitlint` adapter link * docs: Update link to commitlint adapter * docs: add adapter for jira (#748) We have created an adapter that is purposed for the JIRA workflow when you don't use _smart commits_. We have made sure that the adapter is well documented and easy to use. We think that it is unique and would love for it to be recognized. * chore(deps): update dependency nyc to v15.1.0 (#745) Co-authored-by: Renovate Bot <[email protected]> * fix(cli): determine correct location of `COMMIT_EDITMSG` (#737) If using git working trees, then `.git` is a file and not a directory: This file references its own git directory within the main working tree. `$ git rev-parse --git-dir` will always return the directory where the `COMMIT_EDITMSG` file should be placed. * chore(deps): update dependency babel-plugin-istanbul to v5.2.0 (#658) Co-authored-by: Renovate Bot <[email protected]> * chore(deps): update dependency semver to v6.3.0 (#659) Co-authored-by: Renovate Bot <[email protected]> * fix(deps): update dependency inquirer to v6.5.2 (#664) Co-authored-by: Renovate Bot <[email protected]> * feat: use cz as binary name (#767) While still support the old git-cz binary name. Also improve the documentation. Closes #761 * fix: git-cz commit repoPath Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: Renovate Bot <[email protected]> Co-authored-by: jimthedev <[email protected]> Co-authored-by: Martin McWhorter <[email protected]> Co-authored-by: Linus Unnebäck <[email protected]> Co-authored-by: hdmr14 <[email protected]> Co-authored-by: Fernando Maia <[email protected]> Co-authored-by: Jimmy Andrade <[email protected]> Co-authored-by: tyankatsu <[email protected]> Co-authored-by: Dura <[email protected]> Co-authored-by: Julius Recep Colliander Celik <[email protected]> Co-authored-by: nutlike <[email protected]> Co-authored-by: Felipe Santos <[email protected]>
I am using the commitizen hook and I am working with git working trees. When I tried to commit from a worktree it failed with following message:
If using git working trees, then
.git
is a file and not a directory. This pull request determines the correct location to put theCOMMIT_EDITMSG
file.I think the same problem was described in #683, #677 and #643 (the proposed solution should work for submodules as well).