diff --git a/entrypoint.sh b/entrypoint.sh index 8dbbd3b..c6e4a43 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -6,16 +6,21 @@ SOURCE_URL="$3" FORK_URL="$4" DRY_RUN="$5" +if [ ! -d .cloneDir-source ]; then + git clone --bare --filter=tree:0 --depth "${DEPTH}" --no-single-branch "${SOURCE_URL}" ".cloneDir-source" + cd ".cloneDir-source" +else + cd ".cloneDir-source" + git fetch --all -p -P +fi + +OPTS="" + +if [ "${DRY_RUN}" = "true" ]; then + echo 'Using dry-run mode'; + OPTS="--dry-run" +fi + echo "${BRANCHES}" | sed -n 1'p' | tr ',' '\n' | while read branchName; do - if [ ! -d ".cloneDir-${branchName}" ]; then - rm -rf ".cloneDir-${branchName}" - fi - echo "Get fork sha for branch" - FORK_SHA=$(git ls-remote git@github.com:williamdes/phpmyadmintest.git "refs/heads/${branchName}" | awk '{ print $1}') - echo "Fork sha: ${FORK_SHA}" - echo "Cloning ..." - git clone --bare --depth "${DEPTH}" --single-branch --branch "${branchName}" "${SOURCE_URL}" ".cloneDir-${branchName}" - cd ".cloneDir-${branchName}" - git push --dry-run "${FORK_URL}" $branchName - cd ../ + git push ${OPTS} "${FORK_URL}" $branchName done