2020
2121def test_git_object_eq ():
2222 git_commit = git .GitCommit (
23- rev = "sha1-code" , title = "this is title" , body = "this is body"
23+ rev = "sha1-code" ,
24+ title = "this is title" ,
25+ body = "this is body" ,
2426 )
2527 git_tag = git .GitTag (rev = "sha1-code" , name = "0.0.1" , date = "2020-01-21" )
2628
@@ -132,11 +134,13 @@ def test_get_commits_author_and_email():
132134def test_get_commits_without_email (mocker : MockFixture ):
133135 raw_commit = (
134136 "a515bb8f71c403f6f7d1c17b9d8ebf2ce3959395\n "
137+ "95bbfc703eb99cb49ba0d6ffd8469911303dbe63 12d3b4bdaa996ea7067a07660bb5df4772297bdd\n "
135138 "\n "
136139 "user name\n "
137140 "\n "
138141 "----------commit-delimiter----------\n "
139142 "12d3b4bdaa996ea7067a07660bb5df4772297bdd\n "
143+ "de33bc5070de19600f2f00262b3c15efea762408\n "
140144 "feat(users): add username\n "
141145 "user name\n "
142146 "\n "
@@ -159,16 +163,19 @@ def test_get_commits_without_email(mocker: MockFixture):
159163def test_get_commits_without_breakline_in_each_commit (mocker : MockFixture ):
160164 raw_commit = (
161165 "ae9ba6fc5526cf478f52ef901418d85505109744\n "
166+ "ff2f56ca844de72a9d59590831087bf5a97bac84\n "
162167 "bump: version 2.13.0 → 2.14.0\n "
163168 "GitHub Action\n "
164169 "action@github.com\n "
165170 "----------commit-delimiter----------\n "
166171 "ff2f56ca844de72a9d59590831087bf5a97bac84\n "
172+ "b4dc83284dc8c9729032a774a037df1d1f2397d5 20a54bf1b82cd7b573351db4d1e8814dd0be205d\n "
167173 "Merge pull request #332 from cliles/feature/271-redux\n "
168174 "User\n "
169175 "user@email.com\n "
170176 "Feature/271 redux----------commit-delimiter----------\n "
171177 "20a54bf1b82cd7b573351db4d1e8814dd0be205d\n "
178+ "658f38c3fe832cdab63ed4fb1f7b3a0969a583be\n "
172179 "feat(#271): enable creation of annotated tags when bumping\n "
173180 "User 2\n "
174181 "user@email.edu\n "
@@ -193,6 +200,55 @@ def test_get_commits_without_breakline_in_each_commit(mocker: MockFixture):
193200 )
194201
195202
203+ def test_get_commits_with_and_without_parents (mocker : MockFixture ):
204+ raw_commit = (
205+ "4206e661bacf9643373255965f34bbdb382cb2b9\n "
206+ "ae9ba6fc5526cf478f52ef901418d85505109744 bf8479e7aa1a5b9d2f491b79e3a4d4015519903e\n "
207+ "Merge pull request from someone\n "
208+ "Maintainer\n "
209+ "maintainer@email.com\n "
210+ "This is a much needed feature----------commit-delimiter----------\n "
211+ "ae9ba6fc5526cf478f52ef901418d85505109744\n "
212+ "ff2f56ca844de72a9d59590831087bf5a97bac84\n "
213+ "Release 0.1.0\n "
214+ "GitHub Action\n "
215+ "action@github.com\n "
216+ "----------commit-delimiter----------\n "
217+ "ff2f56ca844de72a9d59590831087bf5a97bac84\n "
218+ "\n "
219+ "Initial commit\n "
220+ "User\n "
221+ "user@email.com\n "
222+ "----------commit-delimiter----------\n "
223+ )
224+ mocker .patch ("commitizen.cmd.run" , return_value = FakeCommand (out = raw_commit ))
225+
226+ commits = git .get_commits ()
227+
228+ assert commits [0 ].author == "Maintainer"
229+ assert commits [1 ].author == "GitHub Action"
230+ assert commits [2 ].author == "User"
231+
232+ assert commits [0 ].author_email == "maintainer@email.com"
233+ assert commits [1 ].author_email == "action@github.com"
234+ assert commits [2 ].author_email == "user@email.com"
235+
236+ assert commits [0 ].title == "Merge pull request from someone"
237+ assert commits [1 ].title == "Release 0.1.0"
238+ assert commits [2 ].title == "Initial commit"
239+
240+ assert commits [0 ].body == "This is a much needed feature"
241+ assert commits [1 ].body == ""
242+ assert commits [2 ].body == ""
243+
244+ assert commits [0 ].parents == [
245+ "ae9ba6fc5526cf478f52ef901418d85505109744" ,
246+ "bf8479e7aa1a5b9d2f491b79e3a4d4015519903e" ,
247+ ]
248+ assert commits [1 ].parents == ["ff2f56ca844de72a9d59590831087bf5a97bac84" ]
249+ assert commits [2 ].parents == []
250+
251+
196252def test_get_commits_with_signature ():
197253 config_file = ".git/config"
198254 config_backup = ".git/config.bak"
0 commit comments