Skip to content

Commit

Permalink
feat(git-raw-commits): add support for multiple paths (#1079)
Browse files Browse the repository at this point in the history
  • Loading branch information
mattlewis92 committed Aug 15, 2023
1 parent 49273ee commit 107daf2
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 4 deletions.
4 changes: 2 additions & 2 deletions packages/git-raw-commits/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,9 @@ A function to get debug information.

##### gitOpts.path

Type: `string`
Type: `string` or `array`

Filter commits to the path provided.
Filter commits to the path(s) provided.

##### execOpts

Expand Down
4 changes: 2 additions & 2 deletions packages/git-raw-commits/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@ async function getGitArgs (gitOpts) {
excludes: ['debug', 'from', 'to', 'format', 'path', 'ignore']
}))

// allow commits to focus on a single directory
// allow commits to focus on specific directories.
// this is useful for monorepos.
if (gitOpts.path) {
gitArgs.push('--', gitOpts.path)
gitArgs.push('--', ...Array.isArray(gitOpts.path) ? gitOpts.path : [gitOpts.path])
}

return gitArgs
Expand Down
21 changes: 21 additions & 0 deletions packages/git-raw-commits/test/index.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,27 @@ describe('git-raw-commits', () => {
expect(output).not.toMatch(/Second commit/)
})

it('should allow commits to be scoped to a list of directories', async () => {
let i = 0
let output = ''

for await (let chunk of gitRawCommits({
path: ['./packages/foo', './test2']
}, {
cwd: testTools.cwd
})) {
chunk = chunk.toString()

output += chunk
i++
}

expect(i).toBe(2)
expect(output).toMatch(/First commit/)
expect(output).toMatch(/Second commit/)
expect(output).not.toMatch(/Third commit/)
})

it('should show your git-log command', async () => {
let cmd = ''

Expand Down

0 comments on commit 107daf2

Please sign in to comment.