export files from git for sync using ftp upload
I had to use GIT.
Everybody was using it and some recent forced contemplation at subversion merging made me finally give it a try. But I was reluctant. Partially because of the Linus speech at Google where he was bashing the Subversion guys, partly because of it's sheer difficulty. I really don't like any of those 2 factors. Not one bit. But the added value may surpass the second one. I won't say more about the first one.
So I adapted my export files from svn for sync using ftp upload for git.
Here it is:
#!/bin/sh
# Exports GIT changed files to a chosen location
echo "Repository local path:"
read repositoryUrl
echo "Start commit:"
read startRevision
echo "End commit:"
read endRevision
echo "Export location:"
read exportLocation
currentFolder=$PWD
cd $repositoryUrl
git diff $startRevision..$endRevision --name-status | grep "^[AM].*\.\w\{2,4\}$" | awk '{print $2}' | sort -u | \
while read FN
do
echo "exporting $FN ..."
mkdir -p $exportLocation`dirname /$FN`
git show $endRevision:$FN > $exportLocation/$FN
done
cd $currentFolder
Issues I have yet to fix and clear out:
- I did not find a way to get the diff from the central origin/master. I am guessing that the commits are the same local and remote once you push/pull them (like svn commit) but I'm not 100% sure until I'll use this in a production scenario with lots of activity. The distributed nature of the sistem may give me some bad "aha" moments
- diff with ".." seems to be so smart that it does not list stuff you added and also deleted before the last commit. Well that's how it looks...
- I am not sure how diff works (there I said it) right now. I think and hope it'n not just diffing the 2 commits but also all the ones that happened between them. More experimenting should clear this out for me


0 Comments:
Post a Comment
Links to this post:
Create a Link
<< Home