Skip to content

Commit 9a15f60

Browse files
committed
Let set_sonar_branch manage sonar.branch.target
Fixes #2095
1 parent 9ed91ac commit 9a15f60

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

programs/build_helpers/set_sonar_branch

+10-10
Original file line numberDiff line numberDiff line change
@@ -22,54 +22,54 @@ clear_branch () {
2222
sed -i '/sonar\.branch/d' "$1"
2323
}
2424

25-
TARGET=
25+
ORIGINAL_TARGET="$( grep 'sonar\.branch\.target' "$1" | sed 's=^.*[:=] *==' )"
26+
27+
TARGET="$ORIGINAL_TARGET"
2628
FETCH=
2729

2830
if [ -n "$TRAVIS_PULL_REQUEST" -a "$TRAVIS_PULL_REQUEST" != false ]; then
2931
# PRs work per default
3032
echo "Detected PR '$TRAVIS_PULL_REQUEST'"
31-
clear_branch "$1"
3233
FETCH="$TRAVIS_BRANCH"
3334
elif [ -n "$TRAVIS_TAG" ]; then
3435
# Tag build is either master or testnet
3536
echo "Detected tag '$TRAVIS_TAG'"
36-
clear_branch "$1"
3737
case "$TRAVIS_TAG" in
3838
*test*) TARGET=testnet; FETCH=testnet; ;;
39-
*) FETCH=master; ;;
39+
*) TARGET=master; FETCH=master; ;;
4040
esac
4141
else
4242
case "$TRAVIS_BRANCH" in
43-
master|develop|testnet|next_hardfork)
43+
master|develop|testnet|hardfork)
4444
# Long-lived branches stand for themselves
4545
echo "Detected long-lived branch '$TRAVIS_BRANCH'"
46-
clear_branch "$1"
46+
TARGET="$TRAVIS_BRANCH"
4747
FETCH="$TRAVIS_BRANCH"
4848
;;
4949
*test*release*)
5050
# Testnet release branch will be merged into testnet
5151
echo "Detected testnet release branch '$TRAVIS_BRANCH'"
52-
clear_branch "$1"
5352
TARGET=testnet
5453
FETCH=testnet
5554
;;
5655
*release*)
5756
# Release branch will be merged into default (master)
5857
echo "Detected release branch '$TRAVIS_BRANCH'"
59-
clear_branch "$1"
58+
TARGET=master
6059
FETCH=master
6160
;;
6261
*)
6362
# All other branches should have sonar.branch.target in their
6463
# sonar.properties, leave it unchanged
6564
echo "Detected normal branch '$TRAVIS_BRANCH'"
66-
FETCH="$( grep 'sonar\.branch\.target' "$1" | sed 's=^.*[:=] *==' )"
65+
FETCH="$TARGET"
6766
esac
6867
fi
6968

7069
echo "Branch target '$TARGET', fetch target '$FETCH'"
7170

72-
if [ -n "$TARGET" ]; then
71+
if [ -n "$TARGET" -a "$TARGET" != "$ORIGINAL_TARGET" ]; then
72+
clear_branch "$1"
7373
echo "sonar.branch.target=$TARGET" >>"$1"
7474
fi
7575
#if [ -n "$FETCH" ]; then

0 commit comments

Comments
 (0)