summaryrefslogtreecommitdiff
path: root/tcwg-update-tested.sh
blob: 709ded88860d4dc47dce2f5418e2c9c58b79882c (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
50
51
52
53
54
55
56
#!/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

# Repos cloned by Jenkins have the core.hooksPath set to /dev/null, causing
# the "git review" command to fail (see
# https://storyboard.openstack.org/#!/story/2010342) so change it back to
# its default value.
git -C abe config --unset core.hooksPath
git -C abe review -s
git -C abe push gerrit $GIT_COMMIT:refs/heads/tested

git -C jenkins-scripts config --unset core.hooksPath
git -C jenkins-scripts review -s
git -C jenkins-scripts push gerrit $GIT_COMMIT_1:refs/heads/tested

pushd dockerfiles
GIT_COMMIT_2=$(git rev-parse $GIT_COMMIT_2)

git config --unset core.hooksPath
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-tested branch
    git review -y tcwg-tested
    ssh -p29418 review.linaro.org gerrit review --code-review 2 --submit "$(git rev-parse HEAD)"
fi
popd