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

Unable to read the file ".git/COMMIT_EDITMSG" #360

Open
adamtay opened this issue Jun 24, 2021 · 2 comments
Open

Unable to read the file ".git/COMMIT_EDITMSG" #360

adamtay opened this issue Jun 24, 2021 · 2 comments

Comments

@adamtay
Copy link

adamtay commented Jun 24, 2021

Same as issue #11 which has been closed.

If working in a subdirectory where package.json is not at the root directory, the following error message is outputted:

JIRA prepare commit msg > Error: Unable to read the file ".git/COMMIT_EDITMSG".

@adamtay
Copy link
Author

adamtay commented Jun 24, 2021

The root cause of this issue is that git.getMsgFilePath() returns .git/COMMIT_EDITMSG. If husky cannot resolve the directory based on the cwd, the script errors out here message = fs.readFileSync(messageFilePath, { encoding: 'utf-8' });

As a suggestion, change git.writeJiraTicket() to do the following.

  const { gitCommonDir } = gitRevParse();
  const messageFilePath = getMsgFilePath().replace(".git", gitCommonDir);

@rishitank
Copy link

rishitank commented May 5, 2022

I have a subfolder called client where my package.json and .jirapreparecommitmsgrc file live. I managed to fix this issue with subfolders by adding the following to my .husky/prepare-commit-msg file:

cd client/ || exit
npx jira-prepare-commit-msg "./../$1"

This way it will pick up my .jirapreparecommitmsgrc config while also being able to find .git/COMMIT_EDITMSG by using a relative path.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants