@@ -132,11 +132,13 @@ def test_get_commits_author_and_email():
132
132
def test_get_commits_without_email (mocker : MockFixture ):
133
133
raw_commit = (
134
134
"a515bb8f71c403f6f7d1c17b9d8ebf2ce3959395\n "
135
+ "95bbfc703eb99cb49ba0d6ffd8469911303dbe63 12d3b4bdaa996ea7067a07660bb5df4772297bdd\n "
135
136
"\n "
136
137
"user name\n "
137
138
"\n "
138
139
"----------commit-delimiter----------\n "
139
140
"12d3b4bdaa996ea7067a07660bb5df4772297bdd\n "
141
+ "de33bc5070de19600f2f00262b3c15efea762408\n "
140
142
"feat(users): add username\n "
141
143
"user name\n "
142
144
"\n "
@@ -159,16 +161,19 @@ def test_get_commits_without_email(mocker: MockFixture):
159
161
def test_get_commits_without_breakline_in_each_commit (mocker : MockFixture ):
160
162
raw_commit = (
161
163
"ae9ba6fc5526cf478f52ef901418d85505109744\n "
164
+ "ff2f56ca844de72a9d59590831087bf5a97bac84\n "
162
165
"bump: version 2.13.0 → 2.14.0\n "
163
166
"GitHub Action\n "
164
167
165
168
"----------commit-delimiter----------\n "
166
169
"ff2f56ca844de72a9d59590831087bf5a97bac84\n "
170
+ "b4dc83284dc8c9729032a774a037df1d1f2397d5 20a54bf1b82cd7b573351db4d1e8814dd0be205d\n "
167
171
"Merge pull request #332 from cliles/feature/271-redux\n "
168
172
"User\n "
169
173
170
174
"Feature/271 redux----------commit-delimiter----------\n "
171
175
"20a54bf1b82cd7b573351db4d1e8814dd0be205d\n "
176
+ "658f38c3fe832cdab63ed4fb1f7b3a0969a583be\n "
172
177
"feat(#271): enable creation of annotated tags when bumping\n "
173
178
"User 2\n "
174
179
@@ -193,6 +198,55 @@ def test_get_commits_without_breakline_in_each_commit(mocker: MockFixture):
193
198
)
194
199
195
200
201
+ def test_get_commits_with_and_without_parents (mocker : MockFixture ):
202
+ raw_commit = (
203
+ "4206e661bacf9643373255965f34bbdb382cb2b9\n "
204
+ "ae9ba6fc5526cf478f52ef901418d85505109744 bf8479e7aa1a5b9d2f491b79e3a4d4015519903e\n "
205
+ "Merge pull request from someone\n "
206
+ "Maintainer\n "
207
+
208
+ "This is a much needed feature----------commit-delimiter----------\n "
209
+ "ae9ba6fc5526cf478f52ef901418d85505109744\n "
210
+ "ff2f56ca844de72a9d59590831087bf5a97bac84\n "
211
+ "Release 0.1.0\n "
212
+ "GitHub Action\n "
213
+
214
+ "----------commit-delimiter----------\n "
215
+ "ff2f56ca844de72a9d59590831087bf5a97bac84\n "
216
+ "\n "
217
+ "Initial commit\n "
218
+ "User\n "
219
+
220
+ "----------commit-delimiter----------\n "
221
+ )
222
+ mocker .patch ("commitizen.cmd.run" , return_value = FakeCommand (out = raw_commit ))
223
+
224
+ commits = git .get_commits ()
225
+
226
+ assert commits [0 ].author == "Maintainer"
227
+ assert commits [1 ].author == "GitHub Action"
228
+ assert commits [2 ].author == "User"
229
+
230
+ assert commits [
0 ].
author_email == "[email protected] "
231
+ assert commits [
1 ].
author_email == "[email protected] "
232
+ assert commits [
2 ].
author_email == "[email protected] "
233
+
234
+ assert commits [0 ].title == "Merge pull request from someone"
235
+ assert commits [1 ].title == "Release 0.1.0"
236
+ assert commits [2 ].title == "Initial commit"
237
+
238
+ assert commits [0 ].body == "This is a much needed feature"
239
+ assert commits [1 ].body == ""
240
+ assert commits [2 ].body == ""
241
+
242
+ assert commits [0 ].parents == [
243
+ "ae9ba6fc5526cf478f52ef901418d85505109744" ,
244
+ "bf8479e7aa1a5b9d2f491b79e3a4d4015519903e" ,
245
+ ]
246
+ assert commits [1 ].parents == ["ff2f56ca844de72a9d59590831087bf5a97bac84" ]
247
+ assert commits [2 ].parents == []
248
+
249
+
196
250
def test_get_commits_with_signature ():
197
251
config_file = ".git/config"
198
252
config_backup = ".git/config.bak"
0 commit comments