Commit eca2cae2 authored by Sebastian Neuser's avatar Sebastian Neuser

Merge branch '2019-10-27-009-gitlab_migration'

parents 28e848d9 70a382fd
Pipeline #785 failed with stages
in 1 second
Dateiname: 2019-10-27-009-gitlab_migration
Datum: 2019-10-27
Art: Definition interner Prozesse
Der Vorstand möge beschließen...
Alle Git-Repositories von gitlab.com nach gitlab.hasi.it umzuziehen.
Genehmigung von Anträgen erfolgt fortan mittels GPG-signierter Commits.
Vergangene Beschlüsse müssen einmalig mit einem Sammel-Beschluss-Commit bestätigt werden.
#!/bin/sh -e
# Signs and/or merges <3Si resolutions
# --- V A R I A B L E S --- #
# These can be overridden
COMMITTEE=${COMMITTEE:-haggl moe nanooq}
DOMAIN=${DOMAIN:-chaos-siegen.de}
MAIN_BRANCH=${MAIN_BRANCH:-master}
UPSTREAM=${UPSTREAM:-origin}
# For internal purposes
SCRIPT_NAME=`basename $0`
# --- S U B R O U T I N E S --- #
print_help_message_and_exit() {
cat << EOM
usage: $SCRIPT_NAME [-h]
$SCRIPT_NAME [-v] [-i <ID>] [-p] [-s] -A <file>
$SCRIPT_NAME [-v] [-i <ID>] [-p] [-s] -a <file>
$SCRIPT_NAME [-v] [-i <ID>] [-p] -s
$SCRIPT_NAME [-v] -c
$SCRIPT_NAME [-v] [-i <ID>] [-p] [-s] -m
Signs and/or merges <3Si resolutions
options:
-A rename a resolution file according to convention and do everything -a does
-a add resolution (creates a new branch and a commit with appropriate message)
-c just check and list signatures
-h show this help message
-i use given identity (e.g. an e-mail address) for commit signature
-m check signatures and merge branch into $MAIN_BRANCH if required signatures are found
-p push to upstream repository if operation was successful
-s approve resolution (creates a signed commit with appropriate message)
-v enable debug output
positional arguments:
none
variables:
COMMITTEE list of e-mail address local-parts whose signatures are required
example: "alice bob" => requires signatures from alice@\$DOMAIN and bob@\$DOMAIN
default: $COMMITTEE
DOMAIN e-mail domain, see \$COMMITTEE; default: $DOMAIN
MAIN_BRANCH main git branch; default: $MAIN_BRANCH
UPSTREAM upstream git remote; default: $UPSTREAM
examples:
Add a new resolution, renaming it according to convention, sign it and push the new branch:
$SCRIPT_NAME -A foobar -sp
or shorter:
$SCRIPT_NAME -spA foobar
Approve resolution and synchronize upstream:
$SCRIPT_NAME -sp
Approve resolution, check signatures, merge current branch and push to upstream:
$SCRIPT_NAME -smp
Add a new resolution as-is, without signing it:
$SCRIPT_NAME -a 2019-10-27-042-foobar
Approve resolution using explicit identity:
$SCRIPT_NAME -i haggl@$DOMAIN -s 2019-10-21-008-spende
Override COMMITTEE (e.g. for test purposes, works for all variables mentioned above):
COMMITTEE=haggl $SCRIPT_NAME -mp
EOM
exit
}
# --- M A I N S C R I P T --- #
while getopts "A:a:chi:mpsv" option; do
case $option in
A) ADD=1; RENAME=1; file="$OPTARG" ;;
a) ADD=1; file="$OPTARG" ;;
c) CHECK=1 ;;
i) IDENTITY="$OPTARG" ;;
m) MERGE=1 ;;
p) PUSH=1 ;;
s) SIGN=1 ;;
v) VERBOSE=1 ;;
*) print_help_message_and_exit
esac
done
shift `expr $OPTIND - 1`
test "$ADD" -o "$CHECK" -o "$MERGE" -o "$SIGN" || print_help_message_and_exit
if [ "$ADD" ]; then
if [ "$RENAME" ]; then
latest=$(git ls-files | grep '\-[0-9]\{3\}-' | cut -d'-' -f4 | sort | tail -n1 \
| sed 's:0*\([1-9][0-9]*\):\1:')
test "$VERBOSE" && printf "Latest resolution: %03d\n" $latest
let number=$latest+1
printf -v number '%03d' $number
test "$VERBOSE" && echo "Next resolution: $number"
name="$(date +%Y-%m-%d)-$number-$file"
mv $file $name
file=$name
test "$VERBOSE" && echo "File name: $file"
fi
git checkout -b $file $MAIN_BRANCH
git stage $file
git commit -m"Add resolution $file"
fi
branch=$(git branch | grep \* | cut -d' ' -f2)
if [ "$SIGN" ]; then
git commit --allow-empty --gpg-sign=$IDENTITY -m"Approve resolution $branch"
fi
if [ "$CHECK" -o "$MERGE" ]; then
commits=$(git rev-list $MAIN_BRANCH..$branch)
test "$VERBOSE" && echo -e "Commits in branch $branch:\n$commits"
for commit in $commits; do
signatures="$signatures $(git verify-commit $commit 2>&1 \
| grep -e "<.*@$DOMAIN>" \
| sed 's:.*<\(.*\)@.*>.*:\1:')"
done
test "$VERBOSE" && echo "Found signatures:$signatures"
for person in $COMMITTEE; do
echo $signatures | grep -q $person && {
echo -e "\e[32m✓\e[0m $person"
} || {
echo -e "\e[31mx\e[0m $person"
errcode=1
}
done
test "$errcode" && exit $errcode
test "$MERGE" || exit
git checkout $MAIN_BRANCH
git merge --no-edit --no-ff $branch
git branch -d $branch
test "$PUSH" || exit
git push --delete $UPSTREAM $branch
git push $UPSTREAM $MAIN_BRANCH
exit
fi
if [ "$PUSH" ]; then
git push -u $UPSTREAM $branch
fi
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment