Skip to content

Commit

Permalink
chore: only apply commit convention to PR titles (#11296)
Browse files Browse the repository at this point in the history
  • Loading branch information
ArnaudBarre committed Dec 14, 2022
1 parent 44fb01a commit 27362cb
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 108 deletions.
2 changes: 1 addition & 1 deletion .github/PULL_REQUEST_TEMPLATE.md
Expand Up @@ -20,7 +20,7 @@
### Before submitting the PR, please make sure you do the following

- [ ] Read the [Contributing Guidelines](https://github.com/vitejs/vite/blob/main/CONTRIBUTING.md).
- [ ] Read the [Pull Request Guidelines](https://github.com/vitejs/vite/blob/main/CONTRIBUTING.md#pull-request-guidelines) and follow the [Commit Convention](https://github.com/vitejs/vite/blob/main/.github/commit-convention.md).
- [ ] Read the [Pull Request Guidelines](https://github.com/vitejs/vite/blob/main/CONTRIBUTING.md#pull-request-guidelines) and follow the [PR Title Convention](https://github.com/vitejs/vite/blob/main/.github/commit-convention.md).
- [ ] Check that there isn't already a PR that solves the problem the same way to avoid creating a duplicate.
- [ ] Provide a description in this PR that addresses **what** the PR is solving, or reference the issue that it solves (e.g. `fixes #123`).
- [ ] Ideally, include relevant tests that fail without this PR but pass with it.
61 changes: 3 additions & 58 deletions .github/commit-convention.md
Expand Up @@ -8,64 +8,21 @@ Messages must be matched by the following regex:

<!-- prettier-ignore -->
```js
/^(revert: )?(feat|fix|docs|dx|refactor|perf|test|workflow|build|ci|chore|types|wip|release|deps)(\(.+\))?: .{1,50}/
/^(revert: )?(feat|fix|docs|style|refactor|perf|test|build|ci|chore)(\(.+\))?!?: .{1,50}/
```

#### Examples

Appears under "Features" header, `dev` subheader:

```
feat(dev): add 'comments' option
```

Appears under "Bug Fixes" header, `dev` subheader, with a link to issue #28:

```
fix(dev): fix dev error
close #28
```

Appears under "Performance Improvements" header, and under "Breaking Changes" with the breaking change explanation:

```
perf(build): remove 'foo' option
BREAKING CHANGE: The 'foo' option has been removed.
```

The following commit and commit `667ecc1` do not appear in the changelog if they are under the same release. If not, the revert commit appears under the "Reverts" header.

```
perf(build)!: remove 'foo' option
revert: feat(compiler): add 'comments' option
This reverts commit 667ecc1654a317a13331b17617d973392f415f02.
```

### Full Message Format

A commit message consists of a **header**, **body** and **footer**. The header has a **type**, **scope** and **subject**:

```
<type>(<scope>): <subject>
<BLANK LINE>
<body>
<BLANK LINE>
<footer>
```

The **header** is mandatory and the **scope** of the header is optional.

### Revert

If the commit reverts a previous commit, it should begin with `revert: `, followed by the header of the reverted commit. In the body, it should say: `This reverts commit <hash>.`, where the hash is the SHA of the commit being reverted.

### Type

If the prefix is `feat`, `fix` or `perf`, it will appear in the changelog. However, if there is any [BREAKING CHANGE](#footer), the commit will always appear in the changelog.

Other prefixes are up to your discretion. Suggested prefixes are `docs`, `chore`, `style`, `refactor`, and `test` for non-changelog related tasks.
If the PR reverts a previous commit, it should begin with `revert: `, followed by the header of the reverted commit

### Scope

Expand All @@ -78,15 +35,3 @@ The subject contains a succinct description of the change:
- use the imperative, present tense: "change" not "changed" nor "changes"
- don't capitalize the first letter
- no dot (.) at the end

### Body

Just as in the **subject**, use the imperative, present tense: "change" not "changed" nor "changes".
The body should include the motivation for the change and contrast this with previous behavior.

### Footer

The footer should contain any information about **Breaking Changes** and is also the place to
reference GitHub issues that this commit **Closes**.

**Breaking Changes** should start with the word `BREAKING CHANGE:` with a space or two newlines. The rest of the commit message is then used for this.
17 changes: 0 additions & 17 deletions .github/semantic.yml

This file was deleted.

6 changes: 6 additions & 0 deletions .github/workflows/semantic-pull-request.yml
Expand Up @@ -15,5 +15,11 @@ jobs:
steps:
- name: Validate PR title
uses: amannn/action-semantic-pull-request@v5
with:
subjectPattern: ^(?![A-Z]).+$
subjectPatternError: |
The subject "{subject}" found in the pull request title "{title}"
didn't match the configured pattern. Please ensure that the subject
doesn't start with an uppercase character.
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
4 changes: 2 additions & 2 deletions CONTRIBUTING.md
Expand Up @@ -181,10 +181,10 @@ You can set the `DEBUG` environment variable to turn on debugging logs (e.g. `DE

- Make sure tests pass!

- Commit messages must follow the [commit message convention](./.github/commit-convention.md) so that changelogs can be automatically generated. Commit messages are automatically validated before commit (by invoking [Git Hooks](https://git-scm.com/docs/githooks) via [simple-git-hooks](https://github.com/toplenboren/simple-git-hooks)).

- No need to worry about code style as long as you have installed the dev dependencies. Modified files are automatically formatted with Prettier on commit (by invoking [Git Hooks](https://git-scm.com/docs/githooks) via [simple-git-hooks](https://github.com/toplenboren/simple-git-hooks)).

- PR title must follow the [commit message convention](./.github/commit-convention.md) so that changelogs can be automatically generated.

## Maintenance Guidelines

> The following section is mostly for maintainers who have commit access, but it's helpful to go through if you intend to make non-trivial contributions to the codebase.
Expand Down
3 changes: 1 addition & 2 deletions package.json
Expand Up @@ -94,8 +94,7 @@
"vue": "^3.2.45"
},
"simple-git-hooks": {
"pre-commit": "pnpm exec lint-staged --concurrent false",
"commit-msg": "pnpm exec tsx scripts/verifyCommit.ts $1"
"pre-commit": "pnpm exec lint-staged --concurrent false"
},
"lint-staged": {
"*": [
Expand Down
28 changes: 0 additions & 28 deletions scripts/verifyCommit.ts

This file was deleted.

0 comments on commit 27362cb

Please sign in to comment.