From 35beb918b7352a7130c889e491e803e67d4b8a7d Mon Sep 17 00:00:00 2001 From: Laura Loghin Date: Mon, 27 Jul 2020 10:48:26 +0300 Subject: [PATCH] Fix commit message test The test that was checking the commit message format was not comparing the PR's HEAD to the right master, even though `origin` was set to the pipeline repository. Fixed this by fetching that repo. This way, `FETCH_HEAD` points to the latest upstream master. Signed-off-by: Laura Loghin --- integration_tests/test_commit_format.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/integration_tests/test_commit_format.py b/integration_tests/test_commit_format.py index f7195d8..7a76530 100644 --- a/integration_tests/test_commit_format.py +++ b/integration_tests/test_commit_format.py @@ -3,12 +3,14 @@ """Test the commit message format.""" import os +import subprocess from utils import get_cmd_output COMMIT_TITLE_MAX_LEN = 50 COMMIT_BODY_LINE_MAX_LEN = 72 BASE_BRANCH = os.environ['BUILDKITE_PULL_REQUEST_BASE_BRANCH'] +BASE_REPO = os.environ['BUILDKITE_REPO'] def test_commit_format(): @@ -19,10 +21,13 @@ def test_commit_format(): [https://www.midori-global.com/blog/2018/04/02/git-50-72-rule] and if commits are signed. """ + # Fetch the upstream repository. + fetch_base_cmd = "git fetch {} {}".format(BASE_REPO, BASE_BRANCH) + subprocess.run(fetch_base_cmd, shell=True, check=True) # Get hashes of PR's commits in their abbreviated form for # a prettier printing. shas_cmd = "git log --no-merges --pretty=%h --no-decorate " \ - "{}..HEAD".format(BASE_BRANCH) + "FETCH_HEAD..HEAD" shas = get_cmd_output(shas_cmd) for sha in shas.split():