@@ -132,11 +132,13 @@ def test_get_commits_author_and_email():
132132def test_get_commits_without_email (mocker : MockFixture ):
133133 raw_commit = (
134134 "a515bb8f71c403f6f7d1c17b9d8ebf2ce3959395\n "
135+ "95bbfc703eb99cb49ba0d6ffd8469911303dbe63 12d3b4bdaa996ea7067a07660bb5df4772297bdd\n "
135136 "\n "
136137 "user name\n "
137138 "\n "
138139 "----------commit-delimiter----------\n "
139140 "12d3b4bdaa996ea7067a07660bb5df4772297bdd\n "
141+ "de33bc5070de19600f2f00262b3c15efea762408\n "
140142 "feat(users): add username\n "
141143 "user name\n "
142144 "\n "
@@ -159,16 +161,19 @@ def test_get_commits_without_email(mocker: MockFixture):
159161def test_get_commits_without_breakline_in_each_commit (mocker : MockFixture ):
160162 raw_commit = (
161163 "ae9ba6fc5526cf478f52ef901418d85505109744\n "
164+ "ff2f56ca844de72a9d59590831087bf5a97bac84\n "
162165 "bump: version 2.13.0 → 2.14.0\n "
163166 "GitHub Action\n "
164167 "action@github.com\n "
165168 "----------commit-delimiter----------\n "
166169 "ff2f56ca844de72a9d59590831087bf5a97bac84\n "
170+ "b4dc83284dc8c9729032a774a037df1d1f2397d5 20a54bf1b82cd7b573351db4d1e8814dd0be205d\n "
167171 "Merge pull request #332 from cliles/feature/271-redux\n "
168172 "User\n "
169173 "user@email.com\n "
170174 "Feature/271 redux----------commit-delimiter----------\n "
171175 "20a54bf1b82cd7b573351db4d1e8814dd0be205d\n "
176+ "658f38c3fe832cdab63ed4fb1f7b3a0969a583be\n "
172177 "feat(#271): enable creation of annotated tags when bumping\n "
173178 "User 2\n "
174179 "user@email.edu\n "
@@ -193,6 +198,55 @@ def test_get_commits_without_breakline_in_each_commit(mocker: MockFixture):
193198 )
194199
195200
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+ "maintainer@email.com\n "
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+ "action@github.com\n "
214+ "----------commit-delimiter----------\n "
215+ "ff2f56ca844de72a9d59590831087bf5a97bac84\n "
216+ "\n "
217+ "Initial commit\n "
218+ "User\n "
219+ "user@email.com\n "
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 == "maintainer@email.com"
231+ assert commits [1 ].author_email == "action@github.com"
232+ assert commits [2 ].author_email == "user@email.com"
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+
196250def test_get_commits_with_signature ():
197251 config_file = ".git/config"
198252 config_backup = ".git/config.bak"
0 commit comments