def test_log_with_authors(git_repo_config, vcs): # Create a commit with a new author _set_author(git_repo_config.remote_path, 'Another Committer', '*****@*****.**') check_call('cd %s && touch BAZ && git add BAZ && git commit -m "bazzy"' % git_repo_config.remote_path, shell=True) vcs.clone() vcs.update() revisions = list(vcs.log()) assert len(revisions) == 3 revisions = list(vcs.log(author='Another Committer')) assert len(revisions) == 1 assert_revision(revisions[0], author='Another Committer <*****@*****.**>', message='bazzy') revisions = list(vcs.log(author='*****@*****.**')) assert len(revisions) == 1 assert_revision(revisions[0], author='Another Committer <*****@*****.**>', message='bazzy') revisions = list(vcs.log(branch=vcs.get_default_revision(), author='Foo')) assert len(revisions) == 2
def test_log_with_branches(git_repo_config, vcs): # Create another branch and move it ahead of the master branch remote_path = git_repo_config.remote_path check_call('cd %s && git checkout -b B2' % remote_path, shell=True) check_call( 'cd %s && touch BAZ && git add BAZ && git commit -m "second branch commit"' % (remote_path, ), shell=True) # Create a third branch off master with a commit not in B2 check_call('cd %s && git checkout %s' % ( remote_path, vcs.get_default_revision(), ), shell=True) check_call('cd %s && git checkout -b B3' % remote_path, shell=True) check_call( 'cd %s && touch IPSUM && git add IPSUM && git commit -m "3rd branch"' % (remote_path, ), shell=True) vcs.clone() vcs.update() # Ensure git log normally includes commits from all branches revisions = list(vcs.log()) assert len(revisions) == 4 # Git timestamps are only accurate to the second. But since this test # creates these commits so close to each other, there's a race # condition here. Ultimately, we only care that both commits appear # last in the log, so allow them to be out of order. last_rev, previous_rev = _get_last_two_revisions('B3', revisions) assert_revision(last_rev, message='3rd branch', branches=['B3']) assert_revision(previous_rev, message='second branch commit', branches=['B2']) # Note that the list of branches here differs from the hg version # because hg only returns the branch name from the changeset, which # does not include any ancestors. assert_revision(revisions[3], message='test', branches=[vcs.get_default_revision(), 'B2', 'B3']) # Ensure git log with B3 only revisions = list(vcs.log(branch='B3')) assert len(revisions) == 3 assert_revision(revisions[0], message='3rd branch', branches=['B3']) assert_revision(revisions[2], message='test', branches=[vcs.get_default_revision(), 'B2', 'B3']) # Sanity check master check_call('cd %s && git checkout %s' % ( remote_path, vcs.get_default_revision(), ), shell=True) revisions = list(vcs.log(branch=vcs.get_default_revision())) assert len(revisions) == 2
async def test_log_with_authors(git_repo_config, vcs): # Create a commit with a new author _set_author(git_repo_config.remote_path, "Another Committer", "*****@*****.**") check_call( 'cd %s && touch BAZ && git add BAZ && git commit -m "bazzy"' % git_repo_config.remote_path, shell=True, ) await vcs.clone() await vcs.update() revisions = await vcs.log() assert len(revisions) == 3 revisions = await vcs.log(author="Another Committer") assert len(revisions) == 1 assert_revision(revisions[0], author="Another Committer <*****@*****.**>", message="bazzy") revisions = await vcs.log(author="*****@*****.**") assert len(revisions) == 1 assert_revision(revisions[0], author="Another Committer <*****@*****.**>", message="bazzy") revisions = await vcs.log(branch=vcs.get_default_revision(), author="Foo") assert len(revisions) == 2
async def test_simple(vcs): await vcs.clone() await vcs.update() revision = (await vcs.log(parent="HEAD", limit=1))[0] assert len(revision.sha) == 40 assert_revision(revision, author="Foo Bar <*****@*****.**>", message="biz\nbaz\n") revisions = await vcs.log() assert len(revisions) == 2 assert revisions[0].message == "biz\nbaz\n" assert revisions[0].author == "Foo Bar <*****@*****.**>" assert revisions[0].committer == "Foo Bar <*****@*****.**>" assert revisions[0].parents == [revisions[1].sha] assert revisions[0].author_date == revisions[0].committer_date is not None assert revisions[1].message == "test\nlol\n" assert revisions[1].author == "Foo Bar <*****@*****.**>" assert revisions[1].committer == "Foo Bar <*****@*****.**>" assert revisions[1].parents == [] assert revisions[1].author_date == revisions[1].committer_date is not None diff = await vcs.export(revisions[0].sha) assert (diff == """diff --git a/BAR b/BAR new file mode 100644 index 0000000..e69de29 """) revisions = await vcs.log(offset=0, limit=1) assert len(revisions) == 1 assert revisions[0].message == "biz\nbaz\n" revisions = await vcs.log(offset=1, limit=1) assert len(revisions) == 1 assert revisions[0].message == "test\nlol\n"
def test_simple(vcs): vcs.clone() vcs.update() revision = next(vcs.log(parent="HEAD", limit=1)) assert len(revision.sha) == 40 assert_revision( revision, author="Foo Bar <*****@*****.**>", message="biz\nbaz\n", subject="biz", ) revisions = list(vcs.log()) assert len(revisions) == 2 assert revisions[0].subject == "biz" assert revisions[0].message == "biz\nbaz\n" assert revisions[0].author == "Foo Bar <*****@*****.**>" assert revisions[0].committer == "Foo Bar <*****@*****.**>" assert revisions[0].parents == [revisions[1].sha] assert revisions[0].author_date == revisions[0].committer_date is not None assert revisions[0].branches == ["master"] assert revisions[1].subject == "test" assert revisions[1].message == "test\nlol\n" assert revisions[1].author == "Foo Bar <*****@*****.**>" assert revisions[1].committer == "Foo Bar <*****@*****.**>" assert revisions[1].parents == [] assert revisions[1].author_date == revisions[1].committer_date is not None assert revisions[1].branches == ["master"] diff = vcs.export(revisions[0].sha) assert (diff == """diff --git a/BAR b/BAR new file mode 100644 index 0000000..e69de29 """) revisions = list(vcs.log(offset=0, limit=1)) assert len(revisions) == 1 assert revisions[0].subject == "biz" revisions = list(vcs.log(offset=1, limit=1)) assert len(revisions) == 1 assert revisions[0].subject == "test"
def test_simple(vcs): vcs.clone() vcs.update() revision = next(vcs.log(parent='HEAD', limit=1)) assert len(revision.sha) == 40 assert_revision(revision, author='Foo Bar <*****@*****.**>', message='biz\nbaz\n', subject='biz') revisions = list(vcs.log()) assert len(revisions) == 2 assert revisions[0].subject == 'biz' assert revisions[0].message == 'biz\nbaz\n' assert revisions[0].author == 'Foo Bar <*****@*****.**>' assert revisions[0].committer == 'Foo Bar <*****@*****.**>' assert revisions[0].parents == [revisions[1].sha] assert revisions[0].author_date == revisions[0].committer_date is not None assert revisions[0].branches == ['master'] assert revisions[1].subject == 'test' assert revisions[1].message == 'test\nlol\n' assert revisions[1].author == 'Foo Bar <*****@*****.**>' assert revisions[1].committer == 'Foo Bar <*****@*****.**>' assert revisions[1].parents == [] assert revisions[1].author_date == revisions[1].committer_date is not None assert revisions[1].branches == ['master'] diff = vcs.export(revisions[0].sha) assert diff == """diff --git a/BAR b/BAR new file mode 100644 index 0000000..e69de29 """ revisions = list(vcs.log(offset=0, limit=1)) assert len(revisions) == 1 assert revisions[0].subject == 'biz' revisions = list(vcs.log(offset=1, limit=1)) assert len(revisions) == 1 assert revisions[0].subject == 'test'
async def test_log_with_branches(git_repo_config, vcs): # Create another branch and move it ahead of the master branch remote_path = git_repo_config.remote_path check_call("cd %s && git checkout -b B2" % remote_path, shell=True) check_call( 'cd %s && touch BAZ && git add BAZ && git commit -m "second branch commit"' % (remote_path, ), shell=True, ) # Create a third branch off master with a commit not in B2 check_call( "cd %s && git checkout %s" % (remote_path, vcs.get_default_revision()), shell=True, ) check_call("cd %s && git checkout -b B3" % remote_path, shell=True) check_call( 'cd %s && touch IPSUM && git add IPSUM && git commit -m "3rd branch"' % (remote_path, ), shell=True, ) await vcs.clone() await vcs.update() # Ensure git log with B3 only revisions = await vcs.log(branch="B3") assert len(revisions) == 3 assert_revision(revisions[0], message="3rd branch") assert_revision(revisions[2], message="test") # Sanity check master check_call( "cd %s && git checkout %s" % (remote_path, vcs.get_default_revision()), shell=True, ) revisions = await vcs.log(branch=vcs.get_default_revision()) assert len(revisions) == 2