Two way git mirror: Difference between revisions

Jump to navigation Jump to search
Content deleted Content added
imported>Hendrik Brummermann
No edit summary
imported>Hendrik Brummermann
added support for tags
 
(12 intermediate revisions by the same user not shown)
Line 7: Line 7:
<source lang="bash">
<source lang="bash">
cd /srv/gitsync
cd /srv/gitsync
git clone -bare git@github.com:[account]/[repository].git
git clone --bare git@github.com:[account]/[repository].git
mv [repository].git [repository]
mv [repository].git [repository]
</source>
</source>
Line 37: Line 37:
git fetch --all -p
git fetch --all -p
# push branches from sourceforge to github and via versa.
# push branches from sourceforge to github and via versa.
git push github "refs/remotes/sourceforge/*:refs/heads/*"
git push github "refs/remotes/sourceforge/*:refs/heads/*" "refs/tags/*:refs/tags/*"
git push sourceforge "refs/remotes/github/*:refs/heads/*"
git push sourceforge "refs/remotes/github/*:refs/heads/*" "refs/tags/*:refs/tags/*"
}
}


Line 76: Line 76:
// validate repository name to prevent injection and traversing attacks
// validate repository name to prevent injection and traversing attacks
$repo = $_REQUEST['repository'];
$repo = $_REQUEST['repository'];
if (!preg_match('/^[a-zA-Z0-9]$/', $repo)) {
if (!preg_match('/^[a-zA-Z0-9]+$/', $repo)) {
die('invalid repository name');
die('invalid repository name');
}
}