Changes
Jump to navigation
Jump to search
← Older edit
Git svn
3,619 bytes added
,
21:20, 21 October 2020
m
added
Category:Relax
using
HotCat
{{historical svn}}
__TOC__
= relax branches at github =
You should install [[msysgit]] on windows, to do the commands.
git remote add origin https://${GIT_USER_NAME}@github.com/nmr-relax/relax_trunk.git
git remote add hub https://${GIT_USER_NAME}@github.com/${GIT_USER_NAME}/relax_trunk.git
# Or if you have setup a SSH key in github, and tested with: ssh -T git@github.com
git remote set-url origin git@github.com:nmr-relax/relax_trunk.git
git remote set-url hub git@github.com:${GIT_USER_NAME}/relax_trunk.git
git fetch origin
git checkout --track origin/master
git fetch hub
#Build
scons
git checkout --track origin/master
git fetch hub
#Build
scons
## Now we add the user scripts repo
# Windows
bash ;
relax=$HOME/backup/relax ;
relax_trunk=${relax}/relax_trunk ;
relax_disp=${relax}/relax_disp ;
relax_trunk=${relax}/relax_trunk ;
GIT_USER_NAME="GIT_USER_NAME"
mkdir -p ${relax_trunk} ${relax_disp} ;
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 test
exec_test () {
[ $? -eq 0 ] && echo "-- Command successfully executed" || echo "-- Command failed; exit 1"
}
# Filenames
urlhost="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 sync
backupfolder="${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 GIT
relax=$HOME/backup/relax
relax_trunk=${relax}/relax_trunk
relax_disp=${relax}/relax_disp
# Logging
exec 3>&1 4>&2
trap 'exec 2>&4 1>&3' 0 1 2 3
exec 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 log
echo "Current revision is: $currev"
# Write to current revision file
echo "$currev" > ${backupfolder}/${curfile}
# Write to current branch file
echo "$branch" > ${backupfolder}/${branchfile}
# Make string replacements in branch file
## Replace empty spaces with nothing
sed -i 's/ \+//g' ${backupfolder}/${branchfile}
## Replace with relax trunk
sed -i "s/.*\/trunk.*/trunk/g" ${backupfolder}/${branchfile}
## Replace with relax disp
sed -i "s/.*\/branches\/relax_disp.*/relax_disp/g" ${backupfolder}/${branchfile}
# Set current branch from the file
curbranch=`cat ${backupfolder}/${branchfile}`
# Echo branch to log
echo "This is branch: $curbranch"
# If previous revision does not exist, then create it.
if [ ! -e ${backupfolder}/${prevfile} ] ; then
touch ${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:\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" ]
then
echo "Now doing something for trunk"
cd $relax_trunk
git svn fetch
git rebase --onto remotes/git-svn
git push origin master
fi
if [ "$curbranch" == "relax_disp" ]
then
echo "Now doing something for relax_disp"
cd $relax_disp
git svn fetch
git rebase --onto remotes/git-svn
git push origin master
fi
fi
}
dump_base ; exec_test
do_git_sync ; exec_test
echo "Done, quit!"
</source>
= See also =
[[Category:git]]
[[Category:Relax]]
Bugman
Trusted,
Bureaucrats
4,228
edits
Navigation menu
Personal tools
Create account
Log in
Namespaces
Page
Discussion
Variants
Views
Read
View source
View history
More
Search
Navigation
Main page
Homepage
Installation guides
Community portal
Recent changes
Random page
Help
Tools
Upload file
Special pages
Printable version