Skip to content

Commit

Permalink
feat: allow fixup and amend in subject
Browse files Browse the repository at this point in the history
Ref: #34
  • Loading branch information
gbprod committed Dec 7, 2023
1 parent 6856a5f commit b84b3dc
Show file tree
Hide file tree
Showing 8 changed files with 32,265 additions and 31,891 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
- name: Install Node.js
uses: actions/setup-node@v3
with:
node-version: '18.x'
node-version: '20.10.x'
registry-url: 'https://registry.npmjs.org'
- name: Install dependencies
run: npm ci
Expand Down
57 changes: 55 additions & 2 deletions corpus/subject.txt
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,8 @@ This should not exists
--------------------------------------------------------------------------------

(source
(subject)
(ERROR))
(subject)
(ERROR))

================================================================================
Subject with type and scope
Expand Down Expand Up @@ -157,3 +157,56 @@ feat(issue42): allow numbers in scope

(source
(subject))

================================================================================
Parse fixup!
================================================================================
fixup! allow fixup

--------------------------------------------------------------------------------

(source
(subject
(subject_prefix)))

================================================================================
Parse amend! with conventional commit
================================================================================
amend! feat(test): allow fixup

--------------------------------------------------------------------------------

(source
(subject
(subject_prefix)
(prefix
(type)
(scope))))

================================================================================
Parse amend! with conventional commit and overflow
================================================================================
amend! feat(test): allow fixup with an overflow on the subject

--------------------------------------------------------------------------------

(source
(subject
(subject_prefix)
(prefix
(type)
(scope))
(overflow)))

================================================================================
Parse fixup! with conventional commit and no scope
================================================================================
amend! feat: allow fixup

--------------------------------------------------------------------------------

(source
(subject
(subject_prefix)
(prefix
(type))))
3 changes: 3 additions & 0 deletions grammar.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ module.exports = grammar({

subject: ($) =>
seq(
optional(
seq(alias(choice('fixup!', 'amend!'), $.subject_prefix), WHITESPACE)
),
choice(
seq(NOT_A_COMMENT, SUBJECT),
seq($.prefix, $._conventional_subject)
Expand Down
27 changes: 7 additions & 20 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions queries/highlights.scm
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,6 @@
(breaking_change (value) @text)

(scissor) @comment
(subject_prefix) @keyword

(ERROR) @error
35 changes: 35 additions & 0 deletions src/grammar.json
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,41 @@
"subject": {
"type": "SEQ",
"members": [
{
"type": "CHOICE",
"members": [
{
"type": "SEQ",
"members": [
{
"type": "ALIAS",
"content": {
"type": "CHOICE",
"members": [
{
"type": "STRING",
"value": "fixup!"
},
{
"type": "STRING",
"value": "amend!"
}
]
},
"named": true,
"value": "subject_prefix"
},
{
"type": "PATTERN",
"value": "[\\f\\v ]+"
}
]
},
{
"type": "BLANK"
}
]
},
{
"type": "CHOICE",
"members": [
Expand Down
8 changes: 8 additions & 0 deletions src/node-types.json
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,10 @@
{
"type": "prefix",
"named": true
},
{
"type": "subject_prefix",
"named": true
}
]
}
Expand Down Expand Up @@ -1060,6 +1064,10 @@
"type": "squash",
"named": false
},
{
"type": "subject_prefix",
"named": true
},
{
"type": "supprimé :",
"named": false
Expand Down
Loading

0 comments on commit b84b3dc

Please sign in to comment.