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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow multiple paths in --commit-path #909

Open
rigor789 opened this issue Feb 15, 2022 · 5 comments
Open

Allow multiple paths in --commit-path #909

rigor789 opened this issue Feb 15, 2022 · 5 comments

Comments

@rigor789
Copy link

Hi! 馃憢

Firstly, thanks for your work on this project! 馃檪

Today I used patch-package to patch git-raw-commits@2.0.0 for the project I'm working on.

We're working in a monorepo, and would like to generate changelogs for the whole repo, excluding certain folders. I was able to achieve this using the git pathspec syntax, and a small change in git-raw-commits.

We're now able to use the following to generate the changelog excluding a specific sub-path:

conventional-changelog -p angular -i CHANGELOG.md -s --commit-path='. :!packages/*'

Not sure if this would fit in the scope of this project - but I thought I'd share in case anyone runs into a similar issue.

If this is something you are willing to merge, let me know and I can prepare a PR.

Here is the diff that solved my problem:

diff --git a/node_modules/git-raw-commits/index.js b/node_modules/git-raw-commits/index.js
index 767d4a0..e76c33c 100644
--- a/node_modules/git-raw-commits/index.js
+++ b/node_modules/git-raw-commits/index.js
@@ -32,7 +32,7 @@ function getGitArgs (gitOpts) {
   // allow commits to focus on a single directory
   // this is useful for monorepos.
   if (gitOpts.path) {
-    gitArgs.push('--', gitOpts.path)
+    gitArgs.push('--', ...gitOpts.path.split(' '))
   }
 
   return gitArgs.concat(dargs(gitOpts, {

This issue body was partially generated by patch-package.

@t-kelly
Copy link

t-kelly commented Feb 15, 2022

Literally just digging into this as well! In my case, I want to filter commits that touch:
a) a specific project folder, e.g. packages/a
b) shared scripts across all projects, e.g. shared

Having the ability to specific multiple paths is exactly what's needed!

@rigor789
Copy link
Author

@t-kelly with the above patch you would be able to pass these and I believe would work

--commit-path='packages/a shared'

(may need some trial & error to confirm)

@t-kelly
Copy link

t-kelly commented Feb 16, 2022

Yep! Works like a charm. Also thank you for introducing me to patch package!!! HOW AM I ONLY JUST DISCOVERING THIS!?!

@ecnaidar
Copy link

ecnaidar commented Aug 3, 2022

Also looking at this in relation to lerna/lerna#1257
Thought to generate changelogs myself but seems that it would not be possible without patching (which I would prefer to avoid)
Initially assumed that this param would accept glob pattern and was fiddling with formats so thanks for opening this 馃憤

@cbou
Copy link

cbou commented Jan 29, 2024

This was fixed and merged here: #1079

You don't need to use patch-package. You can use override in package.json.

  "dependencies": {
    "conventional-changelog-core": "^7.0.0"
  },
  "overrides": {
    "conventional-changelog-core": {
      "git-raw-commits": "4.0.0"
    }
  },

I didn't test this exact snippets but the almost the same worked for me for the standard-version package: conventional-changelog/standard-version#959

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

No branches or pull requests

4 participants