summaryrefslogtreecommitdiff
path: root/utils
diff options
context:
space:
mode:
authorLaurent Pinchart <laurent.pinchart@ideasonboard.com>2021-10-18 08:42:55 +0300
committerLaurent Pinchart <laurent.pinchart@ideasonboard.com>2021-10-19 13:14:54 +0300
commit40d994778127cc95b0c019017500695e88b4ca44 (patch)
tree97c8781953c14d12231584939b17f3b947f1995a /utils
parent78e94065fca63bfc3d00e77928554a440cd493a3 (diff)
utils: hooks: pre-push: Check push to integration/* branches
Branches named integration/* are candidates for merge in the master branch. Subject them to the same checks in the pre-push git hook. An important difference between integration branches and the master branch is that the former are typically created as new branches. We can't check the whole history as there are known bad commits, so we have to identify the base commit for the integration branch. The best approximation is to use the remote master branch for the tree being pushed to. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Diffstat (limited to 'utils')
-rwxr-xr-xutils/hooks/pre-push40
1 files changed, 30 insertions, 10 deletions
diff --git a/utils/hooks/pre-push b/utils/hooks/pre-push
index d13e2c3b..e4187f38 100755
--- a/utils/hooks/pre-push
+++ b/utils/hooks/pre-push
@@ -2,9 +2,9 @@
# SPDX-License-Identifier: GPL-2.0-or-later
-# A hook script to prevent pushing unsuitable commits to the master branch.
-# Unsuitable commits are commits that contain a local changelog below a '---'
-# line. The criteria may get extended later.
+# A hook script to prevent pushing unsuitable commits to the master or
+# integration branches. Criteria to determine unsuitable commits are listed
+# below.
#
# Information about the commits which are being pushed is supplied as lines to
# the standard input in the form:
@@ -13,22 +13,42 @@
z40=0000000000000000000000000000000000000000
+remote_name="$1"
+remote_url="$2"
+
while read -r local_ref local_sha remote_ref remote_sha
do
- if [ "$remote_ref" != refs/heads/master ]
+ case "$remote_ref" in
+ refs/heads/master)
+ ;;
+ refs/heads/integration/*)
+ ;;
+ *)
+ continue
+ esac
+
+ # If the remote branch gets deleted, there's nothing to check.
+ if [ "$local_sha" = $z40 ]
then
continue
fi
- # The remote master branch should never get deleted by this push, so we
- # can assume that local_sha is not 0's. We may however be creating the
- # remote branch, when pushing to a new empty repository for instance.
+ # Check if we are creating a new branch or updating an existing one.
if [ "$remote_sha" = $z40 ]
then
- # New branch, examine all commits
- range="$local_sha"
+ if [ "$remote_ref" = "refs/heads/master" ]
+ then
+ # There are known invalid commits in the full history,
+ # skip the checks if we are pushing the master branch
+ # (for instance to an empty repository).
+ continue
+ else
+ # We're pushing a new integration branch, check all
+ # commits on top of the master branch.
+ range="remotes/$remote_name/master..$local_sha"
+ fi
else
- # Update to existing branch, examine new commits
+ # Update to existing branch, examine new commits only.
range="$remote_sha..$local_sha"
fi