@@ -22,54 +22,54 @@ clear_branch () {
22
22
sed -i ' /sonar\.branch/d' " $1 "
23
23
}
24
24
25
- TARGET=
25
+ ORIGINAL_TARGET=" $( grep ' sonar\.branch\.target' " $1 " | sed ' s=^.*[:=] *==' ) "
26
+
27
+ TARGET=" $ORIGINAL_TARGET "
26
28
FETCH=
27
29
28
30
if [ -n " $TRAVIS_PULL_REQUEST " -a " $TRAVIS_PULL_REQUEST " != false ]; then
29
31
# PRs work per default
30
32
echo " Detected PR '$TRAVIS_PULL_REQUEST '"
31
- clear_branch " $1 "
32
33
FETCH=" $TRAVIS_BRANCH "
33
34
elif [ -n " $TRAVIS_TAG " ]; then
34
35
# Tag build is either master or testnet
35
36
echo " Detected tag '$TRAVIS_TAG '"
36
- clear_branch " $1 "
37
37
case " $TRAVIS_TAG " in
38
38
* test* ) TARGET=testnet; FETCH=testnet; ;;
39
- * ) FETCH=master; ;;
39
+ * ) TARGET=master ; FETCH=master; ;;
40
40
esac
41
41
else
42
42
case " $TRAVIS_BRANCH " in
43
- master|develop|testnet|next_hardfork )
43
+ master|develop|testnet|hardfork )
44
44
# Long-lived branches stand for themselves
45
45
echo " Detected long-lived branch '$TRAVIS_BRANCH '"
46
- clear_branch " $1 "
46
+ TARGET= " $TRAVIS_BRANCH "
47
47
FETCH=" $TRAVIS_BRANCH "
48
48
;;
49
49
* test* release* )
50
50
# Testnet release branch will be merged into testnet
51
51
echo " Detected testnet release branch '$TRAVIS_BRANCH '"
52
- clear_branch " $1 "
53
52
TARGET=testnet
54
53
FETCH=testnet
55
54
;;
56
55
* release* )
57
56
# Release branch will be merged into default (master)
58
57
echo " Detected release branch '$TRAVIS_BRANCH '"
59
- clear_branch " $1 "
58
+ TARGET=master
60
59
FETCH=master
61
60
;;
62
61
* )
63
62
# All other branches should have sonar.branch.target in their
64
63
# sonar.properties, leave it unchanged
65
64
echo " Detected normal branch '$TRAVIS_BRANCH '"
66
- FETCH=" $( grep ' sonar\.branch\.target ' " $1 " | sed ' s=^.*[:=] *== ' ) "
65
+ FETCH=" $TARGET "
67
66
esac
68
67
fi
69
68
70
69
echo " Branch target '$TARGET ', fetch target '$FETCH '"
71
70
72
- if [ -n " $TARGET " ]; then
71
+ if [ -n " $TARGET " -a " $TARGET " != " $ORIGINAL_TARGET " ]; then
72
+ clear_branch " $1 "
73
73
echo " sonar.branch.target=$TARGET " >> " $1 "
74
74
fi
75
75
# if [ -n "$FETCH" ]; then
0 commit comments