summaryrefslogtreecommitdiff
path: root/src/qcam/assets/feathericons/phone-outgoing.svg
blob: fea27a37d6b09b17bea35f45757500f253cfccb8 (plain)
1
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-phone-outgoing"><polyline points="23 7 23 1 17 1"></polyline><line x1="16" y1="8" x2="23" y2="1"></line><path d="M22 16.92v3a2 2 0 0 1-2.18 2 19.79 19.79 0 0 1-8.63-3.07 19.5 19.5 0 0 1-6-6 19.79 19.79 0 0 1-3.07-8.67A2 2 0 0 1 4.11 2h3a2 2 0 0 1 2 1.72 12.84 12.84 0 0 0 .7 2.81 2 2 0 0 1-.45 2.11L8.09 9.91a16 16 0 0 0 6 6l1.27-1.27a2 2 0 0 1 2.11-.45 12.84 12.84 0 0 0 2.81.7A2 2 0 0 1 22 16.92z"></path></svg>
90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110
#!/bin/sh

# SPDX-License-Identifier: GPL-2.0-or-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:
#
#   <local ref> <local sha1> <remote ref> <remote sha1>

z40=0000000000000000000000000000000000000000

remote_name="$1"
remote_url="$2"

while read -r local_ref local_sha remote_ref remote_sha
do
	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

	# Check if we are creating a new branch or updating an existing one.
	if [ "$remote_sha" = $z40 ]
	then
		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 only.
		range="$remote_sha..$local_sha"
	fi

	#
	# Find invalid commits.
	#
	errors=0
	for commit in $(git rev-list "$range")
	do
		msg=$(git cat-file commit "$commit")

		# 1. The commit message shall not contain a local changelog.
		if echo "$msg" | grep -q '^--- *$'
		then
			echo >&2 "Found local changelog in commit $commit"
			errors=$((errors+1))
		fi

		# 2. The commit message shall have Signed-off-by lines
		# corresponding the committer and the author.
		committer=$(echo "$msg" | grep '^committer ' | head -1 | \
				cut -d ' ' -f 2- | rev | cut -d ' ' -f 3- | rev)
		if ! echo "$msg" | grep -F -q "Signed-off-by: ${committer}"
		then
			echo >&2 "Missing committer Signed-off-by in commit $commit"
			errors=$((errors+1))
		fi

		author=$(echo "$msg" | grep '^author ' | head -1 | \
				cut -d ' ' -f 2- | rev | cut -d ' ' -f 3- | rev)
		if ! echo "$msg" | grep -F -q "Signed-off-by: ${author}"
		then
			echo >&2 "Missing author Signed-off-by in commit $commit"
			errors=$((errors+1))
		fi

		# 3. A Reviewed-by or Acked-by is required.
		if ! echo "$msg" | grep -q '^\(Reviewed\|Acked\)-by: '
		then
			echo >&2 "No Reviewed-by or Acked-by in commit $commit"
			errors=$((errors+1))
		fi

		# 4. The commit message shall not contain a Change-Id.
		if echo "$msg" | grep -q '^Change-Id:'
		then
			echo >&2 "Found Change-Id in commit $commit"
			errors=$((errors+1))
		fi
	done

	if [ $errors != 0 ]
	then
		echo >&2 "Found $errors errors in $local_ref, not pushing"
		exit 1
	fi
done

exit 0