Skip to content

Commit 96d842d

Browse files
committed
test: add more test for revert commit
1 parent 8cdbac8 commit 96d842d

2 files changed

Lines changed: 50 additions & 3 deletions

File tree

parser.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ var (
3232
HEADER_PATTERN = regexp.MustCompile(`^(?:fixup!\s*)?(\w*)(\(([\w\$\.\*/-]*)\))?(!?):\s(.*)$`)
3333
FOOTER_PATTERN = regexp.MustCompile(`^([\w\s\-]+):\s(.*)$`)
3434
REVERT_HEADER_PATTERN = regexp.MustCompile(`^(?i)revert\s(.*)$`)
35-
REVERT_BODY_PATTERN = regexp.MustCompile(`^(?i)This\sreverts\scommit\s(\w+)\.?$`)
35+
REVERT_BODY_PATTERN = regexp.MustCompile(`(?i)This\sreverts\scommit\s(\w+)\.?`)
3636
)
3737

3838
func splitToLines(text string) []string {
@@ -108,7 +108,7 @@ func (m Message) GetFooter() []Footer {
108108

109109
footer := Footer{
110110
Tag: "revert",
111-
Title: m.Body,
111+
Title: header.Subject,
112112
Content: content,
113113
}
114114

parser_test.go

Lines changed: 48 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,54 @@ This reverts commit bf08694.`,
3737
footer: []Footer{
3838
{
3939
Tag: "revert",
40-
Title: "This reverts commit bf08694.",
40+
Title: "deprecated",
41+
Content: "bf08694",
42+
},
43+
},
44+
},
45+
{
46+
name: "revert commit with other body",
47+
args: args{
48+
message: `Revert "deprecated"
49+
This reverts commit bf08694.
50+
51+
Fixing these warnings, unfortunately also means, that hot code
52+
(which reloads a shared library during runtime) can not use V
53+
constants, because the private static C variables in the shared
54+
library will not be initialized by _vinit(), which is only called
55+
by the main V program.
56+
57+
For example in examples/hot_reload/bounce.v, using 'gx.blue',
58+
defined as:
59+
' blue = Color { r: 0, g: 0, b: 255 }'
60+
... will instead use a const with all 0 fields (i.e. a black color).`,
61+
},
62+
want: Message{
63+
Header: `Revert "deprecated"`,
64+
Body: `This reverts commit bf08694.
65+
66+
Fixing these warnings, unfortunately also means, that hot code
67+
(which reloads a shared library during runtime) can not use V
68+
constants, because the private static C variables in the shared
69+
library will not be initialized by _vinit(), which is only called
70+
by the main V program.
71+
72+
For example in examples/hot_reload/bounce.v, using 'gx.blue',
73+
defined as:
74+
' blue = Color { r: 0, g: 0, b: 255 }'
75+
... will instead use a const with all 0 fields (i.e. a black color).`,
76+
Footer: []string{},
77+
},
78+
header: Header{
79+
Type: "revert",
80+
Scope: "",
81+
Subject: "deprecated",
82+
Important: false,
83+
},
84+
footer: []Footer{
85+
{
86+
Tag: "revert",
87+
Title: "deprecated",
4188
Content: "bf08694",
4289
},
4390
},

0 commit comments

Comments
 (0)