#!/bin/sh # An example hook script for the "post-receive" event. # # The "post-receive" script is run after receive-pack has accepted a pack # and the repository has been updated. It is passed arguments in through # stdin in the form # # For example: # aa453216d1b3e49e7f6f98441fa56946ddcd6a20 68f7abf4e6f922807889f52bc043ecd31b79f814 refs/heads/master # # see contrib/hooks/ for a sample, or uncomment the next line and # rename the file to "post-receive". echo " ----------------------------- " echo "| Inside post-receive hook file |" echo " ----------------------------- " read oldRev newRev refName echo " Printing arguments passed to this file:" echo " Old Revision = $oldRev" echo " New Revision = $newRev" echo " Reference Name = $refName" newCommitMsg=$(git log -n 1 --pretty=format:%s $newRev) echo " New Commit Message = " $newCommitMsg cd D:/Code/Learning/GitSvnWorkflow/2-Git-Svn-Repo echo "Directory changed to 2-Git-Svn-Repo" unset GIT_DIR case "$refName" in refs/tags/*) # This is a tag push tagName=$(echo $refName | cut -d \/ -f 3) echo "Tag Push. Creating svn tag with name = $tagName" git svn tag $tagName echo "Svn Tag created successfully." ;; refs/heads/*) # This is a head push echo "Head Push" echo " Fetching from git-bare-repo..." git fetch git-bare-repo echo " Changes fetched and are placed inside remote branch named git-bare-repo/master" echo " Merging master with remote branch named git-bare-repo/master" git merge git-bare-repo/master -Xtheirs -m "$newRev: $newCommitMsg" echo " Merge complete." echo " Starting svn dcommit ..." git svn dcommit --add-author-from echo "Svn dcommit was successful." ;; esac echo " ------------------------------------------ " echo "| post-receive hook file execution complete |" echo " ------------------------------------------ "