Skip to content

Commit 77cb26d

Browse files
refactor: move Commit to separate file
1 parent 33f61dc commit 77cb26d

2 files changed

Lines changed: 36 additions & 35 deletions

File tree

commit.go

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
package parser
2+
3+
// Commit represents a commit that adheres to the conventional commits specification
4+
type Commit struct {
5+
Header Header
6+
Body string
7+
Footer Footer
8+
9+
BreakingChange bool
10+
11+
FullCommit string
12+
}
13+
14+
// Header represents Header in commit message
15+
type Header struct {
16+
Type string
17+
Scope string
18+
Description string
19+
FullHeader string
20+
}
21+
22+
// Footer represents Footer in commit message
23+
type Footer struct {
24+
Notes []FooterNote
25+
FullFooter string
26+
}
27+
28+
// FooterNote represents one footer note in Footer
29+
type FooterNote struct {
30+
Token string
31+
Value string
32+
}
33+
34+
func newFooterNote(token, value string) FooterNote {
35+
return FooterNote{Token: token, Value: value}
36+
}

parser.go

Lines changed: 0 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -13,41 +13,6 @@ var (
1313
errNoNewLine = errors.New("commit description not followed by an empty line")
1414
)
1515

16-
// Commit represents a commit that adheres to the conventional commits specification
17-
type Commit struct {
18-
Header Header
19-
Body string
20-
Footer Footer
21-
22-
BreakingChange bool
23-
24-
FullCommit string
25-
}
26-
27-
// Header represents Header in commit message
28-
type Header struct {
29-
Type string
30-
Scope string
31-
Description string
32-
FullHeader string
33-
}
34-
35-
// Footer represents Footer in commit message
36-
type Footer struct {
37-
Notes []FooterNote
38-
FullFooter string
39-
}
40-
41-
// FooterNote represents one footer note in Footer
42-
type FooterNote struct {
43-
Token string
44-
Value string
45-
}
46-
47-
func newFooterNote(token, value string) FooterNote {
48-
return FooterNote{Token: token, Value: value}
49-
}
50-
5116
// Parse attempts to parse a commit message to a conventional commit
5217
func Parse(message string) (*Commit, error) {
5318
message = strings.TrimRight(message, "\n\t ")

0 commit comments

Comments
 (0)