conventional-changelog / conventional-changelog/commitlint
Plugins should be provided with git diff
- Dominant language
- TypeScript
- Stars
- 18.7k
- Forks
- 970
- Avg merge
- 7h 33m
- Merged PRs (30d)
- 49
Description
This is a feature request to provide the output of changed files, such as `git diff --cached --name-only --diff-filter=ACM`. The purpose of this feature is to provide a way to verify if changes described within a conventional commit's `scope` are actually all within that scope.
## Expected Behavior
Naive example:
```js
plugin: {
rules: {
'bounded-scope': (parsed) => {
console.log(parsed.diff);
const scope = parsed.scope;
if (scope === 'test1') {
changedStartsWithScope = parsed.diff.every((path) => path.startsWith('apps/test1'));
return [changedStartsWithScope, 'all files with scope test1 should start with apps/test1'];
}
return [true];
}
}
}
echo "feat(test1): random subject" | npm run commitlint
[ '.gitignore', 'apps/test1/testing.js' ]
⧗ input: feat(test1): random subject
✖ all files with scope test1 should start with apps/test1 [scope-bounded]
✖ found 1 problems, 0 warnings
```
## Current Behavior
No way of determining which files have been changed by the commit.
## Affected packages
- [ ] cli
- [x] core
- [ ] prompt
- [ ] config-angular
## Context
I'm trying to create a plugin which queries Nx to determine if the changes in the commit match the scope provided, otherwise requiring you to not specify a scope.
Contributor guide
Research direction
Start in the core package and trace how plugin rules receive parsed commit data. The request proposes exposing paths from `git diff --cached --name-only --diff-filter=ACM` as `parsed.diff`; done means a plugin can inspect those paths and enforce the scope example, with core tests covering the exposed data.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- git, typescript
- Domain
- tooling
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100