def test_branch_updates(self): d = "8a54b585465152ee3323a0d916100621571030be " \ "c01afd06a20ca3b78206652188dbb159cfe4bf23 refs/heads/master" expected_commits = ( dict(rev="1087c75a40b9ec67eb136af23d6e9ec249c8c5d9", files=['hello.txt'], comments='another yet another minor update', change_ts='1355150452'), dict(rev="760856ce0e930e19bae37a4cc6117f748f866a64", files=['bye.txt', 'hello.txt'], comments='addition and deletion', change_ts='1355150497'), dict(rev="c01afd06a20ca3b78206652188dbb159cfe4bf23", files=['a_directory/a_file.txt'], comments='added some more content', change_ts='1355150542') ) parser = GitRefListParser(infile=StringIO(d), cwd=self.repodir) revisions = parser.get_changes("git_test") self.assertEqual(len(revisions), 3) for rev, expected in zip(revisions, expected_commits): self.assertTrue(isinstance(rev, GitRevision)) self.assertTrue(rev.revision == expected["rev"]) self.assertTrue(rev.files == expected["files"]) self.assertTrue(rev.comments == expected["comments"]) self.assertTrue(rev.change_ts == expected["change_ts"]) self.assertTrue(rev.branch == "master") self.assertTrue(rev.project == "git_test")
def test_multibranch_with_merge(self): d = "cf0ca6d1bb52db722a4a171066c37c56033e5d1f " \ "e23905c8518e9dc6a75d2f10bcf1be015d3ab024 refs/heads/branch_x\n" \ "c01afd06a20ca3b78206652188dbb159cfe4bf23 " \ "3a674c37c47bf38278e7ab90a49a6eb1aa43357f refs/heads/master" expected_commits = ( dict(rev="e23905c8518e9dc6a75d2f10bcf1be015d3ab024", branch='branch_x'), dict(rev="cf0ca6d1bb52db722a4a171066c37c56033e5d1f", branch='master'), dict(rev="e23905c8518e9dc6a75d2f10bcf1be015d3ab024", branch='master'), dict(rev="a1a5ad520e31dc5ebbeb8763a49c0e0dd67dbc39", branch='master'), dict(rev="0ac0cbfdfd671a62ca811be3bc2fcc1f05a136c5", branch='master'), dict(rev="3a674c37c47bf38278e7ab90a49a6eb1aa43357f", branch='master') ) parser = GitRefListParser(infile=StringIO(d), cwd=self.repodir) revisions = parser.get_changes("git_test") self.assertEqual(len(revisions), 6) for rev, expected in zip(revisions, expected_commits): self.assertTrue(isinstance(rev, GitRevision)) self.assertTrue(rev.revision == expected["rev"]) self.assertTrue(rev.branch == expected["branch"]) self.assertTrue(rev.project == "git_test")
def test_tag_creation(self): d = "0000000000000000000000000000000000000000 " \ " 6ee7a405669678f4bbc44b9af91751d48ed772db refs/tags/v0.0.1" parser = GitRefListParser(infile=StringIO(d), cwd=self.repodir) revisions = parser.get_changes("git_test") # empty list returned. No changes to push. self.assertEqual(len(revisions), 0) self.assertTrue(isinstance(revisions, list))
def test_branch_deletion(self): d = "5e02a2613c3049414e8781e48b5b443a464bca75 " \ " 0000000000000000000000000000000000000000 refs/heads/branch_a" parser = GitRefListParser(infile=StringIO(d), cwd=self.repodir) revisions = parser.get_changes("git_test") # empty list returned. No changes to push. self.assertEqual(len(revisions), 0) self.assertTrue(isinstance(revisions, list))
def test_forced_update(self): d = "b8cd5a0a639fe40143c84808d5d5dfedd16a2950 " \ "5b036f99ffe71827179c0b72a780887505d605a6 refs/heads/master" expected_commits = ( dict(rev="3a674c37c47bf38278e7ab90a49a6eb1aa43357f", comments='(rewind branch)'), # dummy rewind dict(rev="5b036f99ffe71827179c0b72a780887505d605a6", comments='the bearded chap') ) parser = GitRefListParser(infile=StringIO(d), cwd=self.repodir) revisions = parser.get_changes("git_test") self.assertEqual(len(revisions), 2) for rev, expected in zip(revisions, expected_commits): self.assertTrue(isinstance(rev, GitRevision)) self.assertTrue(rev.revision == expected["rev"]) self.assertTrue(rev.comments == expected["comments"]) self.assertTrue(rev.project == "git_test")
def test_branch_creation(self): d = "0000000000000000000000000000000000000000 " \ "5e02a2613c3049414e8781e48b5b443a464bca75 refs/heads/branch_a" expected_commits = [ dict(rev="5e02a2613c3049414e8781e48b5b443a464bca75", files=['bye.txt', 'hello.txt', 'world'], comments='updated new branch', change_ts='1355152781') ] parser = GitRefListParser(infile=StringIO(d), cwd=self.repodir) revisions = parser.get_changes("git_test2") self.assertEqual(len(revisions), 1) for rev, expected in zip(revisions, expected_commits): self.assertTrue(isinstance(rev, GitRevision)) self.assertTrue(rev.revision == expected["rev"]) self.assertTrue(rev.files == expected["files"]) self.assertTrue(rev.comments == expected["comments"]) self.assertTrue(rev.change_ts == expected["change_ts"]) self.assertTrue(rev.branch == "branch_a") self.assertTrue(rev.project == "git_test2")