Created
June 3, 2016 06:54
-
-
Save anonymous/a9ea11803a1fa12cf06656e47d8b7a09 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
set -e | |
set -x | |
TRUE_CMD=$(which true) | |
p_repo_dir=${WORKSPACE}/test/clone | |
repo_dir=${p_repo_dir}/internal_repo | |
mkdir -p ${p_repo_dir} | |
if ! test -d "${repo_dir}" ; then | |
pushd ${p_repo_dir} | |
git clone ssh://<gerrit_repo>:29418/internal_repo.git \ | |
&& scp -p -P 29418 <gerrit_repo>:hooks/commit-msg internal_repo/.git/hooks/ | |
popd | |
pushd ${repo_dir} | |
git remote add upstream http://upstream.git | |
git remote update | |
popd | |
fi | |
pushd ${repo_dir} | |
git remote -v | |
git reset --hard || true | |
git checkout master || true | |
# git branch -D remote_branch internal_branch || true | |
# git checkout -b remote_branch upstream/remote_branch | |
git checkout remote_branch | |
OLD_SHA=$(git rev-parse --verify HEAD) | |
git pull --rebase upstream remote_branch | |
NEW_SHA=$(git rev-parse --verify HEAD) | |
if [[ "${OLD_SHA}" != "${NEW_SHA}" ]]; then | |
# git checkout -b internal_branch origin/internal_branch | |
git checkout internal_branch | |
git pull --rebase origin internal_branch | |
for i in $(git log --reverse --pretty=format:"%H" ${OLD_SHA}..${NEW_SHA}); do | |
git log -n 1 | |
git cherry-pick --abort || true | |
git cherry-pick -x --keep-redundant-commits --allow-empty $i || git cherry-pick --abort | |
git add -A | |
GIT_EDITOR=${TRUE_CMD} git commit --amend --allow-empty | |
git log -n 1 | |
git push origin HEAD:refs/for/internal_branch || true | |
done | |
fi | |
popd |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment