From 8cfda97202c7bbe5c76707556ece0c7e9c329faa Mon Sep 17 00:00:00 2001 From: Anderson Chauphan Date: Mon, 8 Jan 2024 17:18:13 -0700 Subject: [PATCH] Force PR tests to use a merge commit for testing with --no-ff Never perform a fast-forward merge (--no-ff) for merges used for PR testing. This follows the convention used by GitHub Actions to never allow fast-forward merges and allow consistent output of a merge commit sha1 in TriBITS configure output. --- packages/framework/pr_tools/PullRequestLinuxDriverMerge.py | 4 ++-- .../pr_tools/unittests/test_PullRequestLinuxDriverMerge.py | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/packages/framework/pr_tools/PullRequestLinuxDriverMerge.py b/packages/framework/pr_tools/PullRequestLinuxDriverMerge.py index 6a3e4a9a934e..1da2dfe31a70 100755 --- a/packages/framework/pr_tools/PullRequestLinuxDriverMerge.py +++ b/packages/framework/pr_tools/PullRequestLinuxDriverMerge.py @@ -171,9 +171,9 @@ def merge_branch(source_url, target_branch, sourceSHA): if sha_exists_as_branch_on_remote: print_wrapper("REMARK: Detected ref as a remote branch, will merge as such") - check_call_wrapper(['git', 'merge', '--no-edit', "source_remote/" + sourceSHA]) + check_call_wrapper(['git', 'merge', '--no-ff', '--no-edit', "source_remote/" + sourceSHA]) else: - check_call_wrapper(['git', 'merge', '--no-edit', sourceSHA]) + check_call_wrapper(['git', 'merge', '--no-ff', '--no-edit', sourceSHA]) return 0 diff --git a/packages/framework/pr_tools/unittests/test_PullRequestLinuxDriverMerge.py b/packages/framework/pr_tools/unittests/test_PullRequestLinuxDriverMerge.py index 9dfcbcf36020..aae1f788b350 100755 --- a/packages/framework/pr_tools/unittests/test_PullRequestLinuxDriverMerge.py +++ b/packages/framework/pr_tools/unittests/test_PullRequestLinuxDriverMerge.py @@ -169,7 +169,7 @@ def test_mergeBranch_without_source_remote(self): mock.call(['git', 'fetch', 'origin', 'fake_develop']), mock.call(['git', 'reset', '--hard', 'HEAD']), mock.call(['git', 'checkout', '-B', 'fake_develop', 'origin/fake_develop']), - mock.call(['git', 'merge', '--no-edit', 'df324ae']), + mock.call(['git', 'merge', '--no-ff', '--no-edit', 'df324ae']), ]) return @@ -199,7 +199,7 @@ def test_mergeBranch_with_source_remote(self, m_check_call): mock.call(['git', 'fetch', 'origin', 'fake_develop']), mock.call(['git', 'reset', '--hard', 'HEAD']), mock.call(['git', 'checkout', '-B', 'fake_develop', 'origin/fake_develop']), - mock.call(['git', 'merge', '--no-edit', 'df324ae']), + mock.call(['git', 'merge', '--no-ff', '--no-edit', 'df324ae']), ]) self.assertIn("git remote exists, removing it", m_stdout.getvalue()) return @@ -229,7 +229,7 @@ def test_mergeBranch_ref_is_remote_branch(self, m_check_call): mock.call(['git', 'fetch', 'origin', 'fake_develop']), mock.call(['git', 'reset', '--hard', 'HEAD']), mock.call(['git', 'checkout', '-B', 'fake_develop', 'origin/fake_develop']), - mock.call(['git', 'merge', '--no-edit', 'source_remote/some_ref']), + mock.call(['git', 'merge', '--no-ff', '--no-edit', 'source_remote/some_ref']), ]) self.assertIn("git remote exists, removing it", m_stdout.getvalue()) return