Skip to content

Commit e355120

Browse files
committed
update
1 parent db9b785 commit e355120

7 files changed

Lines changed: 194 additions & 2 deletions

File tree

.github/workflows/ci.yml

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
name: ci
2+
3+
on: [push, pull_request]
4+
5+
jobs:
6+
ci:
7+
runs-on: ${{ matrix.os }}
8+
timeout-minutes: 30
9+
strategy:
10+
matrix:
11+
go: ["^1.17"]
12+
os: [ubuntu-latest, macOS-latest, windows-latest]
13+
name: Go ${{ matrix.go }} in ${{ matrix.os }}
14+
steps:
15+
- uses: actions/checkout@v2
16+
with:
17+
fetch-depth: 0
18+
submodules: true
19+
20+
- uses: actions/setup-go@v2
21+
with:
22+
stable: '!contains(${{ matrix.go }}, "beta") && !contains(${{ matrix.go }}, "rc")'
23+
go-version: ${{ matrix.go }}
24+
25+
- name: Environment
26+
run: |
27+
go version
28+
go env
29+
30+
- name: Lint
31+
uses: golangci/golangci-lint-action@v2
32+
with:
33+
version: v1.42.1
34+
args: --timeout=5m30s
35+
skip-go-installation: true
36+
37+
- name: Format
38+
run: make format-check
39+
40+
- name: Test
41+
run: |
42+
make test
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
# For most projects, this workflow file will not need changing; you simply need
2+
# to commit it to your repository.
3+
#
4+
# You may wish to alter this file to override the set of languages analyzed,
5+
# or to provide custom queries or build logic.
6+
#
7+
# ******** NOTE ********
8+
# We have attempted to detect the languages in your repository. Please check
9+
# the `language` matrix defined below to confirm you have the correct set of
10+
# supported CodeQL languages.
11+
#
12+
name: "CodeQL"
13+
14+
on:
15+
push:
16+
branches: [ master ]
17+
pull_request:
18+
# The branches below must be a subset of the branches above
19+
branches: [ master ]
20+
schedule:
21+
- cron: '43 12 * * 1'
22+
23+
jobs:
24+
analyze:
25+
name: Analyze
26+
runs-on: ubuntu-latest
27+
permissions:
28+
actions: read
29+
contents: read
30+
security-events: write
31+
32+
strategy:
33+
fail-fast: false
34+
matrix:
35+
language: [ 'go' ]
36+
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python' ]
37+
# Learn more:
38+
# https://docs.github.com/en/free-pro-team@latest/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning#changing-the-languages-that-are-analyzed
39+
40+
steps:
41+
- name: Checkout repository
42+
uses: actions/checkout@v2
43+
44+
# Initializes the CodeQL tools for scanning.
45+
- name: Initialize CodeQL
46+
uses: github/codeql-action/init@v1
47+
with:
48+
languages: ${{ matrix.language }}
49+
# If you wish to specify custom queries, you can do so here or in a config file.
50+
# By default, queries listed here will override any specified in a config file.
51+
# Prefix the list here with "+" to use these queries and those in the config file.
52+
# queries: ./path/to/local/query, your-org/your-repo/queries@main
53+
54+
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
55+
# If this step fails, then you should remove it and run the build manually (see below)
56+
- name: Autobuild
57+
uses: github/codeql-action/autobuild@v1
58+
59+
# ℹ️ Command-line programs to run using the OS shell.
60+
# 📚 https://git.io/JvXDl
61+
62+
# ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
63+
# and modify them (or add more) to build your code if your project
64+
# uses a compiled language
65+
66+
#- run: |
67+
# make bootstrap
68+
# make release
69+
70+
- name: Perform CodeQL Analysis
71+
uses: github/codeql-action/analyze@v1

.vscode/settings.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"go.addTags": {
3+
"tags": "json",
4+
"options": "json=omitempty",
5+
"promptForTags": false,
6+
"transform": "snakecase"
7+
},
8+
"go.lintTool": "golangci-lint",
9+
"go.buildFlags": [],
10+
"go.testFlags": ["-v"],
11+
"go.toolsEnvVars": {}
12+
}

LICENSE

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
Copyright (c) 2021 Axetroy
2+
3+
Anti 996 License Version 1.0 (Draft)
4+
5+
Permission is hereby granted to any individual or legal entity
6+
obtaining a copy of this licensed work (including the source code,
7+
documentation and/or related items, hereinafter collectively referred
8+
to as the "licensed work"), free of charge, to deal with the licensed
9+
work for any purpose, including without limitation, the rights to use,
10+
reproduce, modify, prepare derivative works of, distribute, publish
11+
and sublicense the licensed work, subject to the following conditions:
12+
13+
1. The individual or the legal entity must conspicuously display,
14+
without modification, this License and the notice on each redistributed
15+
or derivative copy of the Licensed Work.
16+
17+
2. The individual or the legal entity must strictly comply with all
18+
applicable laws, regulations, rules and standards of the jurisdiction
19+
relating to labor and employment where the individual is physically
20+
located or where the individual was born or naturalized; or where the
21+
legal entity is registered or is operating (whichever is stricter). In
22+
case that the jurisdiction has no such laws, regulations, rules and
23+
standards or its laws, regulations, rules and standards are
24+
unenforceable, the individual or the legal entity are required to
25+
comply with Core International Labor Standards.
26+
27+
3. The individual or the legal entity shall not induce or force its
28+
employee(s), whether full-time or part-time, or its independent
29+
contractor(s), in any methods, to agree in oral or written form, to
30+
directly or indirectly restrict, weaken or relinquish his or her
31+
rights or remedies under such laws, regulations, rules and standards
32+
relating to labor and employment as mentioned above, no matter whether
33+
such written or oral agreement are enforceable under the laws of the
34+
said jurisdiction, nor shall such individual or the legal entity
35+
limit, in any methods, the rights of its employee(s) or independent
36+
contractor(s) from reporting or complaining to the copyright holder or
37+
relevant authorities monitoring the compliance of the license about
38+
its violation(s) of the said license.
39+
40+
THE LICENSED WORK IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
41+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
42+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
43+
IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM,
44+
DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
45+
OTHERWISE, ARISING FROM, OUT OF OR IN ANY WAY CONNECTION WITH THE
46+
LICENSED WORK OR THE USE OR OTHER DEALINGS IN THE LICENSED WORK.

Makefile

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
test:
2+
go test -v --cover -covermode=count -coverprofile=coverage.out ./...
3+
4+
lint:
5+
golangci-lint run ./... -v
6+
7+
format:
8+
go fmt ./...
9+
10+
format-check:
11+
gofmt -l -d ./..

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
[![Build Status](https://github.com/release-lab/conventional-commit-parser/workflows/ci/badge.svg)](https://github.com/release-lab/conventional-commit-parser/actions)
2+
[![Go Report Card](https://goreportcard.com/badge/github.com/release-lab/conventional-commit-parser)](https://goreportcard.com/report/github.com/release-lab/conventional-commit-parser)
3+
![Latest Version](https://img.shields.io/github/v/release/release-lab/conventional-commit-parser.svg)
4+
[![996.icu](https://img.shields.io/badge/link-996.icu-red.svg)](https://996.icu)
5+
![Repo Size](https://img.shields.io/github/repo-size/release-lab/conventional-commit-parser.svg)
6+
17
### Conventional Commit Parser
28

39
This is a parser for [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/)

parser.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,10 @@ var (
3434
REVERT_HEADER_PATTERN = regexp.MustCompile(`^(?i)revert\s(.*)$`)
3535
)
3636

37+
func splitToLines(text string) []string {
38+
return strings.Split(strings.ReplaceAll(text, "\r\n", "\n"), "\n")
39+
}
40+
3741
func (m Message) GetHeader() Header {
3842
headerMatchers := HEADER_PATTERN.FindStringSubmatch(m.Header)
3943
revertHeaderMatchers := REVERT_HEADER_PATTERN.FindStringSubmatch(m.Header)
@@ -62,7 +66,7 @@ func (m Message) GetFooter() []Footer {
6266
footers := make([]Footer, 0)
6367

6468
for _, m := range m.Footer {
65-
lines := strings.Split(strings.ReplaceAll(m, "\r\n", "\n"), "\n")
69+
lines := splitToLines(m)
6670

6771
footer := Footer{}
6872

@@ -146,7 +150,7 @@ func ParseMessage(message string) Message {
146150
footer []string = make([]string, 0)
147151
)
148152

149-
lines := strings.Split(message, "\n")
153+
lines := splitToLines(message)
150154
index := 0
151155

152156
for {

0 commit comments

Comments
 (0)