@@ -26,20 +26,18 @@ ORIGINAL_TARGET="$( grep 'sonar\.branch\.target' "$1" | sed 's=^.*[:=] *==' )"
2626
2727BRANCH=
2828TARGET=" $ORIGINAL_TARGET "
29- FETCH=
3029
31- if [ -n " $TRAVIS_PULL_REQUEST " -a " $TRAVIS_PULL_REQUEST " != false ]; then
30+ if [ -n " $TRAVIS_PULL_REQUEST " -a " $TRAVIS_PULL_REQUEST " != " false" ]; then
3231 # PRs work per default, remove sonar.branch.* since they only work with sonar.pullrequest.*
3332 echo " Detected PR '$TRAVIS_PULL_REQUEST '"
3433 TARGET=
35- FETCH=" $TRAVIS_BRANCH "
3634elif [ -n " $TRAVIS_TAG " ]; then
3735 # Tag build is either master or testnet
3836 echo " Detected tag '$TRAVIS_TAG '"
3937 BRANCH=" $TRAVIS_BRANCH "
4038 case " $TRAVIS_TAG " in
41- * test* ) TARGET=testnet; FETCH=testnet ; ;;
42- * ) TARGET=master; FETCH=master ; ;;
39+ * test* ) TARGET=testnet; ;;
40+ * ) TARGET=master; ;;
4341 esac
4442else
4543 BRANCH=" $TRAVIS_BRANCH "
4846 # Long-lived branches stand for themselves, no target
4947 echo " Detected long-lived branch '$TRAVIS_BRANCH '"
5048 TARGET=
51- FETCH=" $TRAVIS_BRANCH "
5249 ;;
5350 * test* release* )
5451 # Testnet release branch will be merged into testnet
5552 echo " Detected testnet release branch '$TRAVIS_BRANCH '"
5653 TARGET=testnet
57- FETCH=testnet
5854 ;;
5955 * release* )
6056 # Release branch will be merged into default (master)
6157 echo " Detected release branch '$TRAVIS_BRANCH '"
6258 TARGET=master
63- FETCH=master
6459 ;;
6560 * )
6661 # All other branches should have sonar.branch.target in their
6762 # sonar.properties, leave it unchanged
6863 echo " Detected normal branch '$TRAVIS_BRANCH '"
69- FETCH=" $TARGET "
7064 esac
7165fi
7266
73- echo " Branch '$BRANCH ', target '$TARGET ', fetch target '$FETCH '"
67+ echo " Branch '$BRANCH ', target '$TARGET '"
68+
69+ git fetch --no-tags --unshallow
70+ git fetch --no-tags origin +refs/heads/$TRAVIS_BRANCH :refs/remotes/origin/$TRAVIS_BRANCH
71+ if [ -n " $TARGET " ]; then
72+ git fetch --no-tags origin +refs/heads/$TARGET :refs/remotes/origin/$TARGET
73+ fi
7474
7575if [ " x$TARGET " != " x$ORIGINAL_TARGET " ]; then
7676 clear_branch " $1 "
8181if [ -n " $BRANCH " ]; then
8282 echo " sonar.branch.name=$BRANCH " >> " $1 "
8383fi
84- # if [ -n "$FETCH" ]; then
85- # Unfortunately this leads to sonar failing. Apparently it needs a full
86- # clone, not a shallow one. Since our repo is somewhat large and this is
87- # only required for blame annotations, disabled for now.
88- # git fetch --depth=50 origin "$FETCH:$FETCH"
89- # fi
9084
9185exit 0
0 commit comments