summaryrefslogtreecommitdiff
path: root/tcwg-update-tested.sh
blob: 286eaebc6847a88c3a300a7347ec6c72e7697bbd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#!/bin/bash

set -ef -o pipefail

# shellcheck source=jenkins-helpers.sh
. "$(dirname $0)"/jenkins-helpers.sh
convert_args_to_variables "$@"

# Make shellcheck happy and workaround Jenkins not defining variables
# for empty arguments.
GIT_COMMIT="${GIT_COMMIT-HEAD}"
GIT_COMMIT_1="${GIT_COMMIT_1-HEAD}"
GIT_COMMIT_2="${GIT_COMMIT_2-HEAD}"
verbose="${verbose-true}"

# Jenkins doesn't define variables when parameter value is empty,
# so enable "set -u" only after above binding of variables.
set -u

if $verbose; then set -x; fi

if [ x"$USER" = x"tcwg-buildslave" ]; then
    git config --global user.name "TCWG Buildslave"
    git config --global user.email tcwg-buildslave@linaro.org
fi
git -C abe push gerrit $GIT_COMMIT:refs/heads/tested
git -C jenkins-scripts push gerrit $GIT_COMMIT_1:refs/heads/tested

pushd dockerfiles
GIT_COMMIT_2=$(git rev-parse $GIT_COMMIT_2)
git review -s
git checkout -B tcwg-tested origin/tcwg-tested
if [ x"$(git diff HEAD $GIT_COMMIT_2 | wc -l)" != x"0" ]; then
    # Make sure to generate merge commit so that we can attach gerrit's Change-Id to it
    git merge --no-ff -X theirs $GIT_COMMIT_2
    # Make sure there are no differences between merge result and $GIT_COMMIT_2
    if [ x"$(git diff HEAD $GIT_COMMIT_2 | wc -l)" != x"0" ]; then
	echo "ERROR: dockerfiles merge not clean"
	exit 1
    fi
    # Generate gerrit's Change-Id
    git commit --amend -C HEAD
    # Make sure there's no stale rebase from previous review.
    rm -rf .git/rebase-merge
    # Submit review against tcwg-llvmprod branch
    git review -y tcwg-tested
    ssh -p29418 review.linaro.org gerrit review --code-review 2 --submit "$(git rev-parse HEAD)"
fi
popd