|
1 | | -# Cov Commit Parser |
2 | | - |
| 1 | +# Parser |
3 | 2 |
|
4 | | -A simple parser for [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/). |
| 3 | +A simple go parser for [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/) |
5 | 4 |
|
6 | | -## Usage |
7 | | -When run without any arguments, `ccp version` will parse the commits at the current HEAD and output a single line containing a version number. This version number is the recommended version to use for the next build, based on the commit messages included since the latest tag on the branch. |
| 5 | +### Usage |
8 | 6 |
|
9 | | -The current version number is determined by the tag representing the latest semantic version. This can be overridden using the `--current` flag. |
| 7 | +```go |
| 8 | +var msg = `feat(scope): description |
10 | 9 |
|
11 | | -Use the `--since` flag to specify a commit hash, branch name or tag to adjust the commits used during the parsing. |
| 10 | +this is first line in body |
12 | 11 |
|
13 | | -### Use as a library |
14 | | -The tool can also be embedded into existing Go programs. The example below returns a new version based on the starting version `1.0.0` and using the single commit on the `HEAD` of a git repository in the directory `repo_path`: |
15 | | -```go |
16 | | -commitMessages, err := git.GetCommitsInDirectory("repo_path", "HEAD~1", "HEAD") |
17 | | -if err != nil { |
18 | | - fmt.Printf("Error: %s", err.Error()) |
19 | | -} |
| 12 | +this is second line in body |
| 13 | +
|
| 14 | +Ref: #123 |
| 15 | +Date: 01-01-2021 |
| 16 | +By: John Doe` |
20 | 17 |
|
21 | | -v, err := ccp.GetNextVersion("1.0.0", commitMessages, ccp.DefaultPatchTypes) |
| 18 | +commit, err := Parse(msg) |
22 | 19 | if err != nil { |
23 | 20 | fmt.Printf("Error: %s", err.Error()) |
24 | 21 | } |
| 22 | +fmt.Printf("%#v", commit) |
25 | 23 |
|
26 | | -fmt.Println(v) |
| 24 | +/* |
| 25 | +commitMsg = &parser.Commit{ |
| 26 | + Header: parser.Header{ |
| 27 | + Type: "feat", |
| 28 | + Scope: "scope", |
| 29 | + Description: "description", |
| 30 | + FullHeader: "feat(scope): description", |
| 31 | + }, |
| 32 | + Body: "this is first line in body\n\nthis is second line in body", |
| 33 | + Footer: parser.Footer{ |
| 34 | + Notes: []parser.FooterNote{ |
| 35 | + parser.FooterNote{ |
| 36 | + Token: "Ref", |
| 37 | + Value: "#123", |
| 38 | + }, |
| 39 | + parser.FooterNote{ |
| 40 | + Token: "Date", |
| 41 | + Value: "01-01-2021", |
| 42 | + }, |
| 43 | + parser.FooterNote{ |
| 44 | + Token: "By", |
| 45 | + Value: "John Doe", |
| 46 | + }, |
| 47 | + }, |
| 48 | + FullFooter: "Ref: #123\nDate: 01-01-2021\nBy: John Doe", |
| 49 | + }, |
| 50 | + BreakingChange: false, |
| 51 | + FullCommit: "feat(scope): description\n\nthis is first line in body\n\nthis is second line in body\n\nRef: #123\nDate: 01-01-2021\nBy: John Doe", |
| 52 | +} |
| 53 | +*/ |
27 | 54 | ``` |
| 55 | + |
| 56 | +### Fork |
| 57 | + |
| 58 | +This parser is a fork of [cov-commit-parser](github.com/mbamber/cov-commit-parser) by [Matthew Bamber](github.com/mbamber/) |
| 59 | + |
| 60 | +### License |
| 61 | + |
| 62 | +[MIT License](https://github.com/conventionalcommit/parser/tree/master/LICENSE.md) |
| 63 | + |
0 commit comments