From: Sébastien Lesaint Date: Thu, 2 Jul 2015 13:03:00 +0000 (+0200) Subject: use a private repo before building in generate_batch_reports.sh X-Git-Tag: 5.2-RC1~1250 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=53af877a1ac5e9777f0a78b8ee1779b918b695ec;p=sonarqube.git use a private repo before building in generate_batch_reports.sh --- diff --git a/scripts/generate_batch_reports.sh b/scripts/generate_batch_reports.sh index 227d734b923..605839fc895 100755 --- a/scripts/generate_batch_reports.sh +++ b/scripts/generate_batch_reports.sh @@ -16,6 +16,29 @@ set -euo pipefail +function clean() { + rm -Rf $BUILD_DIR +} + +function createPrivateClone() { + BRANCH=$(git symbolic-ref -q HEAD) + BRANCH=${BRANCH##refs/heads/} + BRANCH=${BRANCH:-HEAD} + LOCATION=$(pwd) + REPO_DIR=$(git rev-parse --show-toplevel) + REPO_NAME=${REPO_DIR##*/} + RELATIVE_PATH=${LOCATION#$REPO_DIR} + + # create temp directory and register trap to clean it on exit + BUILD_DIR=$(mktemp -d -t ${REPO_NAME}.XXXXXXXX 2>/dev/null) + trap "clean" INT TERM EXIT + + # Private build + cd $REPO_DIR + git clone --single-branch -slb "${BRANCH}" . ${BUILD_DIR} + cd ${BUILD_DIR}${RELATIVE_PATH} +} + DUMP_DIR="/tmp/batch_dumps" HISTORY_LENGTH=30 SONAR_HOST="http://localhost:9000" @@ -25,20 +48,11 @@ SONAR_JDBC_URL="jdbc:postgresql://localhost:5432/sonar" SONAR_JDBC_USERNAME="sonar" SONAR_JDBC_PASSWORD="sonar" -function clean() { - git co $branch_name - git branch -D working_branch -} - -trap "clean" EXIT +createPrivateClone # retrieve ${HISTORY_LENGTH} commits for the current directory git log -${HISTORY_LENGTH} --pretty=%h -- . | tac > /tmp/sha1s.txt -branch_name=$(git symbolic-ref -q HEAD) -branch_name=${branch_name##refs/heads/} -branch_name=${branch_name:-HEAD} - git co -b working_branch while read sha1; do echo $sha1