Skip to content

Instantly share code, notes, and snippets.

@noel-yap
Last active August 29, 2015 14:05
Show Gist options
  • Select an option

  • Save noel-yap/2d084b543cfab0782edc to your computer and use it in GitHub Desktop.

Select an option

Save noel-yap/2d084b543cfab0782edc to your computer and use it in GitHub Desktop.
#!/bin/bash -evx
PERFORCE_DEPOT_PATH=$1@all
GIT_REPOSITORY_URL=$2
git_project_name=$(echo ${GIT_REPOSITORY_URL} | sed -e 's|^.*/||' -e 's|\.git||')
rm -rf ${git_project_name}
git clone ${GIT_REPOSITORY_URL}
(
cd ${git_project_name}
if [ -f .git/refs/remotes/p4/master ]
then
git update-ref refs/remotes/p4/master $(git log --format='%H' | head -n 1)
git symbolic-ref refs/remotes/p4/HEAD refs/remotes/p4/master
git-p4 sync ${PERFORCE_DEPOT_PATH} || true
git-p4 rebase
else
(
cd ..
git-p4 clone ${PERFORCE_DEPOT_PATH} ${git_project_name}
)
fi
git push origin master
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment