Debian Codegraph @

tests/test-contrib-check-commit.t

raw
1 Test the 'check-commit' script
2 ==============================
3
4 A fine patch:
5
6 $ cat > patch-with-long-header.diff << EOF
7 > # HG changeset patch
8 > # User timeless <[email protected]>
9 > # Date 1448911706 0
10 > # Mon Nov 30 19:28:26 2015 +0000
11 > # Node ID c41cb6d2b7dbd62b1033727f8606b8c09fc4aa88
12 > # Parent 42aa0e570eaa364a622bc4443b0bcb79b1100a58
13 > # ClownJoke This is a veryly long header that should not be warned about because its not the description
14 > bundle2: use Oxford comma (issue123) (BC)
15 >
16 > diff --git a/hgext/transplant.py b/hgext/transplant.py
17 > --- a/hgext/transplant.py
18 > +++ b/hgext/transplant.py
19 > @@ -599,7 +599,7 @@
20 > return
21 > if not (opts.get('source') or revs or
22 > opts.get('merge') or opts.get('branch')):
23 > - raise error.Abort(_('no source URL, branch revision or revision '
24 > + raise error.Abort(_('no source URL, branch revision, or revision '
25 > 'list provided'))
26 > if opts.get('all'):
27 >
28 > + def blahblah(x):
29 > + pass
30 > EOF
31 $ cat patch-with-long-header.diff | $TESTDIR/../contrib/check-commit
32
33 This would normally be against the rules, but it's okay because that's
34 what tagging and signing looks like:
35
36 $ cat > creates-a-tag.diff << EOF
37 > # HG changeset patch
38 > # User Augie Fackler <[email protected]>
39 > # Date 1484787778 18000
40 > # Wed Jan 18 20:02:58 2017 -0500
41 > # Branch stable
42 > # Node ID c177635e4acf52923bc3aa9f72a5b1ad1197b173
43 > # Parent a1dd2c0c479e0550040542e392e87bc91262517e
44 > Added tag 4.1-rc for changeset a1dd2c0c479e
45 >
46 > diff --git a/.hgtags b/.hgtags
47 > --- a/.hgtags
48 > +++ b/.hgtags
49 > @@ -150,3 +150,4 @@ 438173c415874f6ac653efc1099dec9c9150e90f
50 > eab27446995210c334c3d06f1a659e3b9b5da769 4.0
51 > b3b1ae98f6a0e14c1e1ba806a6c18e193b6dae5c 4.0.1
52 > e69874dc1f4e142746ff3df91e678a09c6fc208c 4.0.2
53 > +a1dd2c0c479e0550040542e392e87bc91262517e 4.1-rc
54 > EOF
55 $ $TESTDIR/../contrib/check-commit < creates-a-tag.diff
56
57 A patch with lots of errors:
58
59 $ cat > patch-with-long-header.diff << EOF
60 > # HG changeset patch
61 > # User timeless
62 > # Date 1448911706 0
63 > # Mon Nov 30 19:28:26 2015 +0000
64 > # Node ID c41cb6d2b7dbd62b1033727f8606b8c09fc4aa88
65 > # Parent 42aa0e570eaa364a622bc4443b0bcb79b1100a58
66 > # ClownJoke This is a veryly long header that should not be warned about because its not the description
67 > transplant/foo: this summary is way too long use Oxford comma (bc) (bug123) (issue 244)
68 >
69 > diff --git a/hgext/transplant.py b/hgext/transplant.py
70 > --- a/hgext/transplant.py
71 > +++ b/hgext/transplant.py
72 > @@ -599,7 +599,7 @@
73 > return
74 > if not (opts.get('source') or revs or
75 > opts.get('merge') or opts.get('branch')):
76 > - raise error.Abort(_('no source URL, branch revision or revision '
77 > + raise error.Abort(_('no source URL, branch revision, or revision '
78 > 'list provided'))
79 > if opts.get('all'):
80 > EOF
81 $ cat patch-with-long-header.diff | $TESTDIR/../contrib/check-commit
82 1: username is not an email address
83 # User timeless
84 7: summary keyword should be most user-relevant one-word command or topic
85 transplant/foo: this summary is way too long use Oxford comma (bc) (bug123) (issue 244)
86 7: (BC) needs to be uppercase
87 transplant/foo: this summary is way too long use Oxford comma (bc) (bug123) (issue 244)
88 7: use (issueDDDD) instead of bug
89 transplant/foo: this summary is way too long use Oxford comma (bc) (bug123) (issue 244)
90 7: no space allowed between issue and number
91 transplant/foo: this summary is way too long use Oxford comma (bc) (bug123) (issue 244)
92 7: summary line too long (limit is 78)
93 transplant/foo: this summary is way too long use Oxford comma (bc) (bug123) (issue 244)
94 [1]
95
96 A patch with other errors:
97
98 $ cat > patch-with-long-header.diff << EOF
99 > # HG changeset patch
100 > # User timeless
101 > # Date 1448911706 0
102 > # Mon Nov 30 19:28:26 2015 +0000
103 > # Node ID c41cb6d2b7dbd62b1033727f8606b8c09fc4aa88
104 > # Parent 42aa0e570eaa364a622bc4443b0bcb79b1100a58
105 > # ClownJoke This is a veryly long header that should not be warned about because its not the description
106 > This has no topic and ends with a period.
107 >
108 > diff --git a/hgext/transplant.py b/hgext/transplant.py
109 > --- a/hgext/transplant.py
110 > +++ b/hgext/transplant.py
111 > @@ -599,7 +599,7 @@
112 > if opts.get('all'):
113 >
114 >
115 > +
116 > + some = otherjunk
117 > +
118 > +
119 > + def blah_blah(x):
120 > + pass
121 > +
122 >
123 > EOF
124 $ cat patch-with-long-header.diff | $TESTDIR/../contrib/check-commit
125 1: username is not an email address
126 # User timeless
127 7: don't capitalize summary lines
128 This has no topic and ends with a period.
129 7: summary line doesn't start with 'topic: '
130 This has no topic and ends with a period.
131 7: don't add trailing period on summary line
132 This has no topic and ends with a period.
133 [1]