René's URL Explorer Experiment


Title: Fails in hook mode when package is a subdirectory of git repo · Issue #683 · commitizen/cz-cli · GitHub

Open Graph Title: Fails in hook mode when package is a subdirectory of git repo · Issue #683 · commitizen/cz-cli

X Title: Fails in hook mode when package is a subdirectory of git repo · Issue #683 · commitizen/cz-cli

Description: Scenario: Everything Node.JS lives within a subfolder e.g myGitRepo/source/package.json: "devDependencies": { "commitizen": "^4.0.3", "cz-conventional-changelog": "^3.0.2", "husky": "^3.0.9" }, "config": { "commitizen": { "path": "cz-con...

Open Graph Description: Scenario: Everything Node.JS lives within a subfolder e.g myGitRepo/source/package.json: "devDependencies": { "commitizen": "^4.0.3", "cz-conventional-changelog": "^3.0.2", "husky": "^3.0.9" }, "co...

X Description: Scenario: Everything Node.JS lives within a subfolder e.g myGitRepo/source/package.json: "devDependencies": { "commitizen": "^4.0.3", "cz-conventional-changelog&q...

Opengraph URL: https://github.com/commitizen/cz-cli/issues/683

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Fails in hook mode when package is a subdirectory of git repo","articleBody":"### Scenario:\r\n\r\nEverything Node.JS lives within a subfolder e.g myGitRepo/source/package.json:\r\n```\r\n  \"devDependencies\": {\r\n    \"commitizen\": \"^4.0.3\",\r\n    \"cz-conventional-changelog\": \"^3.0.2\",\r\n    \"husky\": \"^3.0.9\"\r\n  },\r\n  \"config\": {\r\n    \"commitizen\": {\r\n      \"path\": \"cz-conventional-changelog\"\r\n    }\r\n  },\r\n  \"husky\": {\r\n    \"hooks\": {\r\n      \"prepare-commit-msg\": \"exec \u003c /dev/tty \u0026\u0026 npx git cz --hook || true\"\r\n    }\r\n  }\r\n```\r\n\r\nOverriding `config.commitizen.path` to the plain npm module name `cz-conventional-changelog` (as per #469) is sufficient to get `npx git cz` working, BUT...\r\n\r\n### Problem:\r\n\r\nTrying to use the husky hook (which is from the README) will throw:\r\n```\r\nmyGitRepo/source $ git commit\r\n# (Prompting works fine, but then...)\r\nError: ENOENT: no such file or directory, open '/myCoolParentFolder/myGitRepo/source/.git/COMMIT_EDITMSG\r\n```\r\n\r\nNote that it's always taking the package.json folder, not the current working directory e.g:\r\n```\r\nmyGitRepo/source/packages $ git commit\r\n# (Also prompts fine, but tries to write to same wrong .git folder...)\r\nError: ENOENT: no such file or directory, open '/myCoolParentFolder/myGitRepo/source/.git/COMMIT_EDITMSG\r\n```\r\n\r\nIt doesn't seem to be possible to override via environment variables (e.g. by messing with `GIT_DIR` in the husky hook statement like they do [here](https://github.com/typicode/husky/issues/364) or [here](https://github.com/typicode/husky/issues/584)), because [cli/strategies/git-cz.js](https://github.com/commitizen/cz-cli/blob/master/src/cli/strategies/git-cz.js) explicitly calls `commitizen.commit` with `repoPath = process.cwd()`:\r\n\r\n```\r\n  commit(sh, inquirer, process.cwd(), prompter, {\r\n      args: parsedGitCzArgs,\r\n      disableAppendPaths: true,\r\n      emitData: true,\r\n      quiet: false,\r\n      retryLastCommit,\r\n      hookMode\r\n    }, function (error) {\r\n      if (error) {\r\n        throw error;\r\n      }\r\n    });\r\n```\r\n\r\n...and [git/commit.js](https://github.com/commitizen/cz-cli/blob/master/src/git/commit.js) uses that repoPath to store the captured message:\r\n```\r\nconst commitFilePath = path.join(repoPath, '/.git/COMMIT_EDITMSG');\r\n```\r\n\r\nThis issue only affects running in hook mode, because in standard `git cz` we just pass the message through as an argument to a spawned git process, which manages to figure out that it's in a subfolder of a repository.\r\n\r\n### Fix Investigation:\r\n\r\nI had a look around to try and figure what a fix might look like, but I don't really understand why `cliPath` and `repoPath` are tracked as separate variables when the CLI strategy seems to just force `repoPath` to the package root?","author":{"url":"https://github.com/athewsey","@type":"Person","name":"athewsey"},"datePublished":"2019-10-22T04:27:21.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":4},"url":"https://github.com/683/cz-cli/issues/683"}

route-pattern/_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format)
route-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:55702c32-0468-4263-340d-635a8b2184e3
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-idDFEE:20E521:3DA99:56781:6A62F8A1
html-safe-nonce610dd8241da73e652fb57de3d735d0ae76641fb9d60558599e6e9263a73b3462
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJERkVFOjIwRTUyMTozREE5OTo1Njc4MTo2QTYyRjhBMSIsInZpc2l0b3JfaWQiOiI0MTYwNjAwMzc4Njg0ODQ3NjkiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ==
visitor-hmac1d202713029c7a90dcfa48729cd43fdef06f05f9a5ee044250254fb82b01ba59
hovercard-subject-tagissue:510421904
github-keyboard-shortcutsrepository,issues,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///voltron/issues_fragments/issue_layout
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/commitizen/cz-cli/683/issue_layout
twitter:imagehttps://opengraph.githubassets.com/b7c53b2d51a22393e2ddbe2dceeb169212fa7633693a50439719bcf9dff9e8b6/commitizen/cz-cli/issues/683
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/b7c53b2d51a22393e2ddbe2dceeb169212fa7633693a50439719bcf9dff9e8b6/commitizen/cz-cli/issues/683
og:image:altScenario: Everything Node.JS lives within a subfolder e.g myGitRepo/source/package.json: "devDependencies": { "commitizen": "^4.0.3", "cz-conventional-changelog": "^3.0.2", "husky": "^3.0.9" }, "co...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernameathewsey
hostnamegithub.com
expected-hostnamegithub.com
None59e40dc698184067b40ef2d941585f66ed42711564a879644f984f1eacea129c
turbo-cache-controlno-preview
go-importgithub.com/commitizen/cz-cli git https://github.com/commitizen/cz-cli.git
octolytics-dimension-user_id11980392
octolytics-dimension-user_logincommitizen
octolytics-dimension-repository_id34230966
octolytics-dimension-repository_nwocommitizen/cz-cli
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id34230966
octolytics-dimension-repository_network_root_nwocommitizen/cz-cli
turbo-body-classeslogged-out env-production page-responsive
disable-turbofalse
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
releaseb4f544bf80583e749557efd76afda56317b6252d
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/commitizen/cz-cli/issues/683#start-of-content
https://github.com/
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fcommitizen%2Fcz-cli%2Fissues%2F683
GitHub CopilotWrite better code with AIhttps://github.com/features/copilot
GitHub Copilot appDirect agents from issue to mergehttps://github.com/features/ai/github-app
MCP RegistryNewIntegrate external toolshttps://github.com/mcp
ActionsAutomate any workflowhttps://github.com/features/actions
CodespacesInstant dev environmentshttps://github.com/features/codespaces
IssuesPlan and track workhttps://github.com/features/issues
Code ReviewManage code changeshttps://github.com/features/code-review
Code QualityEnforce quality at mergehttps://github.com/features/code-quality
GitHub Advanced SecurityFind and fix vulnerabilitieshttps://github.com/security/advanced-security
Code securitySecure your code as you buildhttps://github.com/security/advanced-security/code-security
Secret protectionStop leaks before they starthttps://github.com/security/advanced-security/secret-protection
Why GitHubhttps://github.com/why-github
Documentationhttps://docs.github.com
Bloghttps://github.blog
Changeloghttps://github.blog/changelog
Marketplacehttps://github.com/marketplace
View all featureshttps://github.com/features
Enterpriseshttps://github.com/enterprise
Small and medium teamshttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
App Modernizationhttps://github.com/solutions/use-case/app-modernization
DevSecOpshttps://github.com/solutions/use-case/devsecops
DevOpshttps://github.com/solutions/use-case/devops
CI/CDhttps://github.com/solutions/use-case/ci-cd
View all use caseshttps://github.com/solutions/use-case
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
View all industrieshttps://github.com/solutions/industry
View all solutionshttps://github.com/solutions
AIhttps://github.com/resources/articles?topic=ai
Software Developmenthttps://github.com/resources/articles?topic=software-development
DevOpshttps://github.com/resources/articles?topic=devops
Securityhttps://github.com/resources/articles?topic=security
View all topicshttps://github.com/resources/articles
Customer storieshttps://github.com/customer-stories
Events & webinarshttps://github.com/resources/events
Ebooks & reportshttps://github.com/resources/whitepapers
Business insightshttps://github.com/solutions/executive-insights
GitHub Skillshttps://skills.github.com
Documentationhttps://docs.github.com
Customer supporthttps://support.github.com
Community forumhttps://github.com/orgs/community/discussions
Trust centerhttps://github.com/trust-center
Partnershttps://github.com/partners
View all resourceshttps://github.com/resources
GitHub SponsorsFund open source developershttps://github.com/open-source/sponsors
Security Labhttps://securitylab.github.com
Maintainer Communityhttps://maintainers.github.com
Acceleratorhttps://github.com/open-source/accelerator
GitHub Starshttps://stars.github.com
Archive Programhttps://archiveprogram.github.com
Topicshttps://github.com/topics
Trendinghttps://github.com/trending
Collectionshttps://github.com/collections
Enterprise platformAI-powered developer platformhttps://github.com/enterprise
GitHub Advanced SecurityEnterprise-grade security featureshttps://github.com/security/advanced-security
Copilot for BusinessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/enterprise/premium-support
Pricinghttps://github.com/pricing
Search syntax tipshttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
documentationhttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fcommitizen%2Fcz-cli%2Fissues%2F683
Sign up https://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fvoltron%2Fissues_fragments%2Fissue_layout&source=header-repo&source_repo=commitizen%2Fcz-cli
Reloadhttps://github.com/commitizen/cz-cli/issues/683
Reloadhttps://github.com/commitizen/cz-cli/issues/683
Reloadhttps://github.com/commitizen/cz-cli/issues/683
Please reload this pagehttps://github.com/commitizen/cz-cli/issues/683
commitizen https://github.com/commitizen
cz-clihttps://github.com/commitizen/cz-cli
Notifications https://github.com/login?return_to=%2Fcommitizen%2Fcz-cli
Fork 563 https://github.com/login?return_to=%2Fcommitizen%2Fcz-cli
Star 17.5k https://github.com/login?return_to=%2Fcommitizen%2Fcz-cli
Code https://github.com/commitizen/cz-cli
Issues 169 https://github.com/commitizen/cz-cli/issues
Pull requests 26 https://github.com/commitizen/cz-cli/pulls
Actions https://github.com/commitizen/cz-cli/actions
Projects https://github.com/commitizen/cz-cli/projects
Wiki https://github.com/commitizen/cz-cli/wiki
Security and quality 0 https://github.com/commitizen/cz-cli/security
Insights https://github.com/commitizen/cz-cli/pulse
Code https://github.com/commitizen/cz-cli
Issues https://github.com/commitizen/cz-cli/issues
Pull requests https://github.com/commitizen/cz-cli/pulls
Actions https://github.com/commitizen/cz-cli/actions
Projects https://github.com/commitizen/cz-cli/projects
Wiki https://github.com/commitizen/cz-cli/wiki
Security and quality https://github.com/commitizen/cz-cli/security
Insights https://github.com/commitizen/cz-cli/pulse
Fails in hook mode when package is a subdirectory of git repohttps://github.com/commitizen/cz-cli/issues/683#top
https://github.com/athewsey
athewseyhttps://github.com/athewsey
on Oct 22, 2019https://github.com/commitizen/cz-cli/issues/683#issue-510421904
#469https://github.com/commitizen/cz-cli/issues/469
herehttps://github.com/typicode/husky/issues/364
herehttps://github.com/typicode/husky/issues/584
cli/strategies/git-cz.jshttps://github.com/commitizen/cz-cli/blob/master/src/cli/strategies/git-cz.js
git/commit.jshttps://github.com/commitizen/cz-cli/blob/master/src/git/commit.js
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.