diff --git a/pr_agent/git_providers/bitbucket_server_provider.py b/pr_agent/git_providers/bitbucket_server_provider.py index dcdedaddb..d256a808a 100644 --- a/pr_agent/git_providers/bitbucket_server_provider.py +++ b/pr_agent/git_providers/bitbucket_server_provider.py @@ -139,8 +139,7 @@ def get_files(self): #gets the best common ancestor: https://git-scm.com/docs/git-merge-base @staticmethod def get_best_common_ancestor(source_commits_list, destination_commits_list, guaranteed_common_ancestor) -> str: - destination_commit_hashes = {commit['id'] for commit in destination_commits_list} - destination_commit_hashes.add(guaranteed_common_ancestor) + destination_commit_hashes = {commit['id'] for commit in destination_commits_list} | {guaranteed_common_ancestor} for commit in source_commits_list: for parent_commit in commit['parents']: diff --git a/tests/unittest/test_bitbucket_provider.py b/tests/unittest/test_bitbucket_provider.py index fb7eb2939..93c368e1c 100644 --- a/tests/unittest/test_bitbucket_provider.py +++ b/tests/unittest/test_bitbucket_provider.py @@ -23,21 +23,17 @@ def test_parse_pr_url(self): assert pr_number == 1 def mock_get_content_of_file(self, project_key, repository_slug, filename, at=None, markup=None): - if at == '9c1cffdd9f276074bfb6fb3b70fbee62d298b058': - return 'file\nwith\nsome\nlines\nto\nemulate\na\nreal\nfile\n' - elif at == '2a1165446bdf991caf114d01f7c88d84ae7399cf': - return 'file\nwith\nmultiple \nlines\nto\nemulate\na\nfake\nfile\n' - elif at == 'f617708826cdd0b40abb5245eda71630192a17e3': - return 'file\nwith\nmultiple \nlines\nto\nemulate\na\nreal\nfile\n' - elif at == 'cb68a3027d6dda065a7692ebf2c90bed1bcdec28': - return 'file\nwith\nsome\nchanges\nto\nemulate\na\nreal\nfile\n' - elif at == '1905dcf16c0aac6ac24f7ab617ad09c73dc1d23b': - return 'file\nwith\nsome\nlines\nto\nemulate\na\nfake\ntest\n' - elif at == 'ae4eca7f222c96d396927d48ab7538e2ee13ca63': - return 'readme\nwithout\nsome\nlines\nto\nsimulate\na\nreal\nfile' - elif at == '548f8ba15abc30875a082156314426806c3f4d97': - return 'file\nwith\nsome\nlines\nto\nemulate\na\nreal\nfile' - return '' + content_map = { + '9c1cffdd9f276074bfb6fb3b70fbee62d298b058': 'file\nwith\nsome\nlines\nto\nemulate\na\nreal\nfile\n', + '2a1165446bdf991caf114d01f7c88d84ae7399cf': 'file\nwith\nmultiple \nlines\nto\nemulate\na\nfake\nfile\n', + 'f617708826cdd0b40abb5245eda71630192a17e3': 'file\nwith\nmultiple \nlines\nto\nemulate\na\nreal\nfile\n', + 'cb68a3027d6dda065a7692ebf2c90bed1bcdec28': 'file\nwith\nsome\nchanges\nto\nemulate\na\nreal\nfile\n', + '1905dcf16c0aac6ac24f7ab617ad09c73dc1d23b': 'file\nwith\nsome\nlines\nto\nemulate\na\nfake\ntest\n', + 'ae4eca7f222c96d396927d48ab7538e2ee13ca63': 'readme\nwithout\nsome\nlines\nto\nsimulate\na\nreal\nfile', + '548f8ba15abc30875a082156314426806c3f4d97': 'file\nwith\nsome\nlines\nto\nemulate\na\nreal\nfile' + } + + return content_map.get(at, '') ''' tests the 2-way diff functionality where the diff should be between the HEAD of branch b and node c