From 55464a64a0a05c36529f0394efc9ba1759cd596c Mon Sep 17 00:00:00 2001 From: muthukrishnan24 Date: Mon, 17 Jan 2022 09:50:16 +0530 Subject: [PATCH 1/5] fix: set header during descriptionToken instead of bodyToken --- parser.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/parser.go b/parser.go index d213147..82484b7 100644 --- a/parser.go +++ b/parser.go @@ -47,8 +47,8 @@ func (p *Parser) parse(input string) (*Commit, error) { c.scope = t.Value case descriptionToken: c.description = t.Value + c.header = strings.TrimSpace(lex.Get(0, t.End)) case bodyToken: - c.header = strings.TrimSpace(lex.Get(0, t.Start)) c.body = strings.TrimSpace(t.Value) case footerKeyToken: if footerStartPos == 0 { From 80cdf8b17a579b001405e2ed21e35d82405f669b Mon Sep 17 00:00:00 2001 From: Muthu Krishnan Date: Sat, 15 Mar 2025 18:58:04 +0530 Subject: [PATCH 2/5] ci: add github action to test PR: #2 --- .github/workflows/go.yml | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 .github/workflows/go.yml diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml new file mode 100644 index 0000000..8585c8f --- /dev/null +++ b/.github/workflows/go.yml @@ -0,0 +1,25 @@ +name: Go + +on: + push: + branches: [ "master" ] + pull_request: + branches: [ "master" ] + +jobs: + + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: Set up Go + uses: actions/setup-go@v4 + with: + go-version: '1.20' + + - name: Build + run: go build -v ./... + + - name: Test + run: go test -v ./... From ccc9ebe2c2f5621009efc33fc7164b3552c946d1 Mon Sep 17 00:00:00 2001 From: Muthu Krishnan Date: Sat, 15 Mar 2025 19:11:50 +0530 Subject: [PATCH 3/5] ci: add workflow_dispatch --- .github/workflows/go.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index 8585c8f..4f09e45 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -5,6 +5,7 @@ on: branches: [ "master" ] pull_request: branches: [ "master" ] + workflow_dispatch: jobs: From 313aae6faad22dd54d08a3db4069eddcde3d9623 Mon Sep 17 00:00:00 2001 From: Muthu Krishnan Date: Sat, 15 Mar 2025 19:32:48 +0530 Subject: [PATCH 4/5] ci: add pr types --- .github/workflows/go.yml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index 4f09e45..5d7e27b 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -5,6 +5,14 @@ on: branches: [ "master" ] pull_request: branches: [ "master" ] + types: + - opened + - synchronize + - reopened + - review_requested + pull_request_review: + types: + - submitted workflow_dispatch: jobs: From a8ffa3a0648c20ab4ca1676d037af0b6b150fc5a Mon Sep 17 00:00:00 2001 From: Heinrich Langos Date: Sat, 15 Mar 2025 15:07:51 +0100 Subject: [PATCH 5/5] fix(header): read description delimiter exactly as ": " PR: #1 --- lexer_state.go | 5 +++-- parser_header_test.go | 20 ++++++++++++++++++++ 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/lexer_state.go b/lexer_state.go index b0b4d54..76c29f1 100644 --- a/lexer_state.go +++ b/lexer_state.go @@ -111,12 +111,13 @@ func descriptionDelimiterState(l *lexer) stateFunc { l.Emit(breakingChangeToken) } - l.Take(": ") + l.Next() - if l.Current() != ": " { + if l.Current() != ":" || l.Peek() != ' ' { l.Error(errDescMissingDelimiter) return nil } + l.Next() l.Emit(descDelimiterToken) diff --git a/parser_header_test.go b/parser_header_test.go index cc9c263..71757cf 100644 --- a/parser_header_test.go +++ b/parser_header_test.go @@ -17,6 +17,24 @@ func TestParseHeaderValid(t *testing.T) { "feat: description with body 1, \n\n2, 3 and 4?", "feat1234(@scope/scope1,scope2): description, \n\n body 1 2, 3 and 4?", "1245#feat1234(@scope/scope1,scope2): description, \n\n body 1 2, 3 and 4?", + "feat: description with colon at the end: mid:dle and :start of words", + "feat: description with gitmoji at the end :hammer:", + "feat: description with gitmoji in :hammer: the middle", + "feat: :hammer: description with gitmoji at the start", + "feat(scope): description with colon at the end: mid:dle and :start of words", + "feat(scope): description with gitmoji at the end :hammer:", + "feat(scope): description with gitmoji in :hammer: the middle", + "feat(scope): :hammer: description with gitmoji at the start", + "feat!: description with colon at the end: mid:dle and :start of words", + "feat!: description with gitmoji at the end :hammer:", + "feat!: description with gitmoji in :hammer: the middle", + "feat!: :hammer: description with gitmoji at the start", + "feat(scope)!: description with colon at the end: mid:dle and :start of words", + "feat(scope)!: description with gitmoji at the end :hammer:", + "feat(scope)!: description with gitmoji in :hammer: the middle", + "feat(scope)!: :hammer: description with gitmoji at the start", + `feat: : : A description`, + `feat: :: A description ::`, } p := New() @@ -52,6 +70,8 @@ func TestParseHeaderInvalid(t *testing.T) { `feat((`, `feat():`, `feat):`, + `feat:: A description`, + `feat:::: A description`, } p := New()