Open main menu

Changes

Git svn

8,157 bytes added, 21:20, 21 October 2020
m
= Background ={{historical svn}}__TOC__
== Windows =relax branches at github ==== Test 1 ===Based You should install [[http://git-scm.com/book/ch8-1.html on thismsysgit]] and [http://iacoware.wordpress.com/2009/10/02/howto-use-svnsync-to-mirror-a-repository-on-windows/ this article, to do the commands.]
md C:\relax\svn\trunk== The relax_trunk == svnadmin create --pre-1.4-compatible CGo to https:/relax/svngithub.com/trunknmr-relax/relax_trunk <br>Click '''Fork'''.svn
Now add this as a private remote, by setting the remote name '''hub'''.<source lang="bash"> # Windows md set relax_trunk="C:\WinPython27\relax\svn\branches\relax_disprelax_trunk" set GIT_USER_NAME="GIT_USER_NAME" md %relax_trunk% cd %relax_trunk% # Linux bash ; svnadmin create --pre-1.4-compatible C:relax_trunk=$HOME/relax/svn/branches/relax_disp/.svnrelax_trunk GIT_USER_NAME="GIT_USER_NAME" mkdir -p ${relax_trunk} cd $relax_trunk
echo exit 0 > Cgit init # Windows git remote add origin https://%GIT_USER_NAME%@github.com/nmr-relax/svnrelax_trunk.git git remote add hub https:/trunk/%GIT_USER_NAME%@github.svncom/hooks%GIT_USER_NAME%/pre-revprop-changerelax_trunk.batgit echo exit 0 > C# Linux git remote add origin https://${GIT_USER_NAME}@github.com/nmr-relax/svn/branchesrelax_trunk.git git remote add hub https:/relax_disp/${GIT_USER_NAME}@github.svncom/hooks${GIT_USER_NAME}/pre-revprop-changerelax_trunk.batgit
svnsync init file:///C:/relax/svn/trunk/.svn http://svn.gna.org/svn/relax/trunk/ svnsync init file:///C:/relax/svn/branches/relax_disp/.svn http://svn.gna.org/svn/relax/branches/relax_disp/ # Be aware, Or if your repo is bigyou have setup a SSH key in github, it could take a loooot of timeand tested with: ssh -T git@github.com # Example. 20500 commits, took from 22 PM to 23 PMgit remote set-url origin git@github. svnsync sync filecom:///C:/nmr-relax/svn/trunk/relax_trunk.svngit svnsync sync filegit remote set-url hub git@github.com:${GIT_USER_NAME}///C:/relax/svn/branches/relax_disp/relax_trunk.svngit
cd C:\relaxgit fetch origin git svn clone file:checkout --track origin///C:/relax/svn/trunk -smaster git svn clone file:///C:/relax/svn/branches/relax_disp -sfetch hub
=== Test 2 === #Build[http://www.tfnico.com/presentations/git-and-subversion Based on these posts] and on [http://trac.parrot.org/parrot/wiki/git-svn-tutorial these posts]. scons
* ## Now we add the user scripts repo # Windows git clone https://%GIT_USER_NAME%@github.com/nmr-relax/relax_scripts.git # Linux git clone https://${GIT_USER_NAME}@github.com/nmr-r is for the revision relax/relax_scripts.git</source> Go to start taking history fromhttps://github.com/nmr-relax/relax_scripts <br>Click '''Fork'''.<source lang="bash"> cd relax_scripts # Windows git remote add hub https://%GIT_USER_NAME%@github.com/%GIT_USER_NAME%/relax_scripts.git # Linux git remote add hub https://${GIT_USER_NAME}@github.com/${GIT_USER_NAME}/relax_scripts. If you want git</source> == The relax_disp ==Go to include all of the history, just leave that option off, but it will take a very long time, and you really donhttps://github.com/nmr-relax/relax_disp <br>Click '''Fork'''t need all of it. The older  Now add this as a revision you chooseprivate remote, by setting the longer it will take to importremote name '''hub'''. But you will not be able to <source lang="bash"> # Windows set relax_disp="C:\WinPython27\relax\relax_disp" set GIT_USER_NAME="GIT_USER_NAME" md %relax_disp% cd %relax_disp% # Linux bash ; relax_disp=$HOME/relax/relax_disp GIT_USER_NAME="GIT_USER_NAME" mkdir -p ${relax_disp} cd $relax_disp  git init # Windows git remote add origin https://%GIT_USER_NAME%@github.com/nmr-relax/relax_disp.git git remote add hub https://%GIT_USER_NAME%@github.com/%GIT_USER_NAME%/relax_disp.git # Linux git remote add origin https://${GIT_USER_NAME}@github.com/nmr-relax/relax_disp.git git remote add hub https://${GIT_USER_NAME}@github.com/${GIT_USER_NAME}/relax_disp.git   git fetch origin git blame" past checkout --track origin/master git fetch hub  #Build scons  ## Now we add the earliest revision you importuser scripts repo # Windows git clone https://%GIT_USER_NAME%@github. Choose wiselycom/nmr-relax/relax_scripts.git md C# Linux git clone https://${GIT_USER_NAME}@github.com/nmr-relax/relax_scripts.git</source> Go to https:\//github.com/nmr-relax/relax_scripts <br>Click '''Fork'''.<source lang="bash"> cd Crelax_scripts # Windows git remote add hub https:\relax//%GIT_USER_NAME%@github.com/%GIT_USER_NAME%/relax_scripts.git # Linux git remote add hub https://${GIT_USER_NAME}@github.com/${GIT_USER_NAME}/relax_scripts.git</source> = How the import to github was done =[http://www.tfnico.com/presentations/git-and-subversion Based on these posts] and on [http://trac.parrot.org/parrot/wiki/git-svn clone -r 20000tutorial this recommended post], and [http:HEAD //john.albin.net/git/convert-subversion-to-git also this post.] You need an [[Authors#authors.txt | authors.txt]] file, to correctly convert the metadata.<source lang="bash"> bash ; relax=$HOME/backup/relax ; relax_trunk=${relax}/relax_trunk ; relax_disp=${relax}/relax_disp ; GIT_USER_NAME="GIT_USER_NAME" mkdir -p ${relax_trunk} ${relax_disp} ;  git svnclone http://svn.gna.org/svn/relax/trunk--no-metadata -A authors.txt ${relax_trunk} ; cp authors.txt ${relax_trunk} ; cat ${relax_trunk}/.git/config cp ${relax_trunk}/.git/config ${relax_trunk}/.git/config_bckThis takes awk '{gsub(a,b);print}' a =".*authorsfile =.*" b=" authorsfile = ${relax_trunk}/authors.txt" ${relax_trunk}/.git/config_bck > ${relax_trunk}/.git/config cat ${relax_trunk}/.git/config  git svn clone http://svn.gna.org/svn/relax/branches/relax_disp --no-metadata -A authors.txt ${relax_disp} ; cp authors.txt ${relax_disp} ; cat ${relax_disp}/.git/config cp ${relax_disp}/.git/config ${relax_disp}/.git/config_bck awk '{gsub(a,b);print}' a=".*authorsfile =.*" b=" authorsfile = ${relax_disp}/authors.txt" ${relax_disp}/.git/config_bck > ${relax_disp}/.git/config cat ${relax_disp}/.git/config</source> == Setup remotes to github ===== For branch trunk ===<source lang="bash"> cd $relax_trunk git config --add user.name "Your Name" git config --add user.email you@example.com git config --add core.editor "nano" git config --add github.user ${GIT_USER_NAME} # If you are a member of the organization, with writing permissions, then do: git remote add origin https://${GIT_USER_NAME}@github.com/nmr-relax/relax_trunk.git</source>Now go to github.com at https://github.com/organizations/nmr-relax click '''Repositories -> New'''.<br>Call it '''relax_trunk'''. We want to preserve history , so do not '''Initialize this repository with a README''' or anything like, README or .gitignore. <br> Then send svn branch master of to github<source lang="bash"> git push -u origin master</source> === For branch relax_disp ===<source lang="bash"> cd $relax_disp git config --add user.name "Your Name" git config --add user.email you@example.com git config --add core.editor "nano" git config --add github.user ${GIT_USER_NAME} # If you are a member of the organization, with writing permissions, then do: git remote add origin https://${GIT_USER_NAME}@github.com/nmr-relax/relax_disp.git</source> Now go to github.com at that revision; to update https://github.com/organizations/nmr-relax click '''Repositories -> New'''.<br>Call it '''relax_disp'''. We want to HEADpreserve history , so do not '''Initialize this repository with a README''' or anything like, you now need README or .gitignore. <br> Then send svn branch master of to github<source lang="bash"> git push -u origin master</source> == git operations ==Get new changes from svn repository and push to github git co master git svn fetch git rebase--onto remotes/git-svn git push origin master == Saving credentials ==See [http://stackoverflow.com/questions/14629107/how-to-input-password-to-git-pull-command this post] echo "machine github.com login ${GIT_USER_NAME} password SECRET" >> ~/.netrc chmod 0600 ~/.netrc ls -la ~/.netrc cat ~/.netrc == Setup cronjob ==Checking each 15 minutes<source lang="bash">crontab -e # Add*/15 * * * * $HOME/backup/nmrrelax_sync_svn_git.sh</source> == Sync script from SVN to Github ==<source lang="bash">#!/bin/bash# -*- coding: UTF-8 -*-# Script for syncing SVN to git automatically using cron.# # exec testexec_test () {[ $? -eq 0 ] && echo "-- Command successfully executed" || echo "-- Command failed; exit 1"} # Filenamesurlhost="http://www.mail-archive.com/relax-commits@gna.org/"mydate=`date '+%Y%m%d_%H%M'`mytime=`date '+%T %Y%m%d'` # Set paths to do the mail syncbackupfolder="${HOME}/backup/nmrrelax_svn_git_sync"backupfolderurl="${backupfolder}/commit_url_dumps"dumpdate="commits_url.txt"curfile="currev.txt"prevfile="prevrev.txt"branchfile="curbranch.txt"mkdir -p $backupfolder $backupfolderurl # Set paths to GITrelax=$HOME/backup/relaxrelax_trunk=${relax}/relax_trunkrelax_disp=${relax}/relax_disp # Loggingexec 3>&1 4>&2trap 'exec 2>&4 1>&3' 0 1 2 3exec 1>>${backupfolder}/nmrrelax_svn_git_sync.log 2>&1# Everything below will go to the log file dump_base () {echo "###########################"echo "STARTING on: $mytime"echo "Dumping URL webpage revisions..."#lftp -e "open ftp://${dbuser}:${dbpwd}@${dbhost} && mirror --no-perms --exclude-glob backup_scripts/ --exclude-glob cache/ --exclude-glob LocalSettings.php --parallel=10 && bye"lynx -dump $urlhost > ${backupfolderurl}/${dumpdate}currev=`grep -E '^ \* \[5\]r' ${backupfolderurl}/${dumpdate} | awk '{print $2}' | cut -c5-`branch=`grep -E '^ \* \[5\]r' -A 5 ${backupfolderurl}/${dumpdate} | grep -m 1 -e '\/branches\/relax_disp\|\/trunk'` # Echo revision to logecho "Current revision is: $currev"# Write to current revision fileecho "$currev" > ${backupfolder}/${curfile} # Write to current branch fileecho "$branch" > ${backupfolder}/${branchfile} # Make string replacements in branch file## Replace empty spaces with nothingsed -i 's/ \+//g' ${backupfolder}/${branchfile}## Replace with relax trunksed -i "s/.*\/trunk.*/trunk/g" ${backupfolder}/${branchfile}## Replace with relax dispsed -i "s/.*\/branches\/relax_disp.*/relax_disp/g" ${backupfolder}/${branchfile}# Set current branch from the filecurbranch=`cat ${backupfolder}/${branchfile}` # Echo branch to logecho "This is branch: $curbranch"  # If previous revision does not exist, which then create it.if [ ! -e ${backupfolder}/${prevfile} ] ; thentouch ${backupfolder}/${prevfile}fi} do_git_sync () {echo "Checking if need for for new commits ..."DIFF=`diff -q ${backupfolder}/${curfile} ${backupfolder}/${prevfile}`echo -e "Difference between current revision and current current revision is very similar :\n${DIFF}\n"DIFFARR=($DIFF)LENDIFFARR=${#DIFFARR[@]}if [ "$LENDIFFARR" -gt "0" ]then echo -e "#Now doing git sync for: $curbranch"echo "Changed revision to: ${currev}"echo "$currev" > ${backupfolder}/${prevfile} if [ "$curbranch" == "trunk" ]thenecho "Now doing something for trunk"cd $relax_trunkgit svn fetchgit rebase --onto remotes/git-svn up git push origin masterfi if [ "$curbranch" == "relax_disp" ]thenecho "Now doing something for relax_disp"cd $relax_dispgit svn fetchgit rebase--onto remotes/git-svngit push origin masterfi fi} dump_base ; exec_testdo_git_sync ; exec_test echo "Done, quit!"</source> = See also =[[Category:git]][[Category:Relax]]
Trusted, Bureaucrats
4,223

edits