| 1 | ## Script to initialize the git repository and link it to the svn. |
|---|
| 2 | ## The synchronization requires two pushes |
|---|
| 3 | ## (1st push=svn dcommit, 2nd push=git push) |
|---|
| 4 | ## WARNING: we assume the svn and the git are up-to-date |
|---|
| 5 | ## https://lmdz-forge.lmd.jussieu.fr/mediawiki/Planets/index.php/Git-svn |
|---|
| 6 | |
|---|
| 7 | SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) |
|---|
| 8 | cd ${SCRIPT_DIR}/.. |
|---|
| 9 | |
|---|
| 10 | echo "WARNING: this script will setup the git repository." |
|---|
| 11 | echo "It will connect the git to the svn (git svn init) and" |
|---|
| 12 | echo "install a hook to ensure the synchronization between the two." |
|---|
| 13 | echo "The hook (UTIL/pre-push) will be called at each git push." |
|---|
| 14 | # echo "or download it in the git-trunk/ folder (and link with git-svn)." |
|---|
| 15 | |
|---|
| 16 | # while true; do |
|---|
| 17 | # read -p "Do you wish to continue? [Y/n] " yn |
|---|
| 18 | # case $yn in |
|---|
| 19 | # [Yy]* ) break;; |
|---|
| 20 | # [Nn]* ) exit;; |
|---|
| 21 | # * ) break;; |
|---|
| 22 | # esac |
|---|
| 23 | # done |
|---|
| 24 | |
|---|
| 25 | # URL=git@gitlab.in2p3.fr:la-communaut-des-mod-les-atmosph-riques-plan-taires/git-trunk.git |
|---|
| 26 | # LOCAL_URL=`git remote get-url origin 2>/dev/null` |
|---|
| 27 | # if [ "${LOCAL_URL}" != "${URL}" ];then |
|---|
| 28 | # git clone ${URL} |
|---|
| 29 | # cd git-trunk |
|---|
| 30 | # fi |
|---|
| 31 | |
|---|
| 32 | ### link svn to git as git-svn branch |
|---|
| 33 | ### (need git-svn to work) |
|---|
| 34 | git svn init https://svn.lmd.jussieu.fr/Planeto/trunk |
|---|
| 35 | |
|---|
| 36 | git update-ref refs/remotes/git-svn refs/remotes/origin/master |
|---|
| 37 | # git svn rebase # not used (we assume we're up-to-date) |
|---|
| 38 | |
|---|
| 39 | ### install pre-push hook to ensure |
|---|
| 40 | ### users push only commits in sync with svn |
|---|
| 41 | |
|---|
| 42 | # save users hooks just in case |
|---|
| 43 | echo "Saving old hooks in .git/hooks/save ..." |
|---|
| 44 | mkdir -p .git/hooks |
|---|
| 45 | if [ -d .git/hooks ];then |
|---|
| 46 | mkdir -p .git/hooks/save |
|---|
| 47 | mv .git/hooks/p* .git/hooks/save |
|---|
| 48 | fi |
|---|
| 49 | echo "Copying lmdz hooks in .git/hooks ..." |
|---|
| 50 | cd .git/hooks |
|---|
| 51 | for hook in ../../UTIL/hooks/*; do |
|---|
| 52 | file=$(basename $hook) |
|---|
| 53 | echo $file |
|---|
| 54 | ln -s $hook $file |
|---|
| 55 | done |
|---|
| 56 | |
|---|