Skip to content

Commit

Permalink
feat: find a better way to sync forks
Browse files Browse the repository at this point in the history
  • Loading branch information
williamdes committed Apr 4, 2020
1 parent 68610f0 commit d1e9d23
Showing 1 changed file with 16 additions and 11 deletions.
27 changes: 16 additions & 11 deletions entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit d1e9d23

Please sign in to comment.