Subversion checkout from a GitHub repository which contains symlinks
I have a project hosted on GitHub and I use Git for source versioning.
I have to pull the code on another platform but it can't have Git, so I am using Subversion Support of GitHub to checkout the code, but it doesn't handle symlinks.
For example, on my machine I have a symlink :
sf -> ../lib/vendor/symfony/data/web/sf
But when the sources are updated on the remote platform, I have this :
$ svn up
# updating sources...
$ cat sf
../lib/vendor/symfony/data/web/sf
Any ideas?
Update
If possible I want to avoid the script solution, other开发者_运维问答 developers may also pull sources from Subversion for example.
GitHub's subversion support has been updated to handle symlinks.
It works for checking out from a git repo with symlinks:
$ svn co https://github.com/nickh/repo_with_symlinks
...
A repo_with_symlinks/trunk/app/lib/foo
A repo_with_symlinks/trunk/app/lib/foo/bar.txt
A repo_with_symlinks/trunk/foo
Checked out revision 1.
$ ls -al repo_with_symlinks/trunk/foo
lrwxr-xr-x 1 github staff 11 Dec 23 23:11 foo -> app/lib/foo
And when committing symlinks from svn clients:
$ ln -s app/lib/foo/bar.txt bar.txt
$ svn add bar.txt
A bar.txt
$ svn commit -m 'added a symlink'
Adding trunk/bar.txt
Transmitting file data .
Committed revision 2.
This IS really what's stored in the history. When Git sees this content in the log, instead of literally putting it in a file like Subversion does, it actually creates a symbolic link (see entry.c:113 for proof). There are two solutions as I see it:
- GitHub must detect that this is a symbolic link and represent the it differently through the SVN interface.
- You must use some sort of post-receive hook in Subversion to locally detect and replace such files with symbolic links. Don't actually touch the remote repository, otherwise the Git-side will have problems.
UPDATE: GitHub has fixed the problem now.
Subversion seems to handle symlinks, but in a tricky way.
For your problem, you could try to reconvert back your symlinks to real ones, for example with some script like this (just showing the idea, untested):
#!/usr/bin/env bash
file=$1
filecontent=`cat $1`
if [[ -f "$filecontent" ]]; then
svn delete $file --force
svn commit -m "Deleting broken symlink $file"
svn update
ln -s $filecontent $file
svn add --force $file
svn commit -m "Recreating broken symlink $file"
fi
The svn instructions sequence comes from this question.
精彩评论