fix: fetch base branch before performing merge-base
Also make sure the copyright script honors the refspec that's passed on
it's command line.
Signed-off-by: Harrison Mutai <harrison.mutai@arm.com>
Change-Id: I91250c39015129c3c1eef0891ff55ee2ea6f74b1
diff --git a/script/static-checks/check-copyright.py b/script/static-checks/check-copyright.py
index 227a11e..be89496 100755
--- a/script/static-checks/check-copyright.py
+++ b/script/static-checks/check-copyright.py
@@ -181,20 +181,9 @@
Instead of checking all files in the source tree, the script will consider
only files that are modified by the latest patch(es).""",
action="store_true")
-
- (rc, stdout, stderr) = utils.shell_command(['git', 'merge-base', 'HEAD', 'refs/remotes/origin/master'])
- if rc:
- print("Git merge-base command failed. Cannot determine base commit.")
- sys.exit(rc)
- merge_bases = stdout.splitlines()
-
- # This should not happen, but it's better to be safe.
- if len(merge_bases) > 1:
- print("WARNING: Multiple merge bases found. Using the first one as base commit.")
-
parser.add_argument("--from-ref",
help="Base commit in patch mode (default: %(default)s)",
- default=merge_bases[0])
+ default="remotes/origin/integration")
parser.add_argument("--to-ref",
help="Final commit in patch mode (default: %(default)s)",
default="HEAD")
diff --git a/script/static-checks/common.sh b/script/static-checks/common.sh
index 0f76b10..d7a56b7 100644
--- a/script/static-checks/common.sh
+++ b/script/static-checks/common.sh
@@ -4,11 +4,7 @@
# SPDX-License-Identifier: BSD-3-Clause
#
-function get_base_branch() {
- # Remove prefix
- echo origin/${GERRIT_BRANCH#refs/heads/}
-}
-
function get_merge_base() {
- git merge-base HEAD $(get_base_branch) | head -1
+ git fetch origin ${GERRIT_BRANCH#refs/heads/}
+ git merge-base HEAD FETCH_HEAD | head -1
}