Guest User

Untitled

a guest
Nov 21st, 2017
389
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.33 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. if [ $# -eq 0 ]; then
  4. echo "Usage: $0 SVNURL" 1>&2
  5. exit 1
  6. fi
  7.  
  8. if ! command -v svn2git >/dev/null 2>&1 ; then
  9. echo "Cannot find svn2git. Please install the svn2git Ruby gem"
  10. exit 1
  11. fi
  12.  
  13. git svn --version > /dev/null 2>&1
  14. if [ $? -ne 0 ]; then
  15. echo "git-svn not found. Please install git-svn to continue."
  16. exit 1
  17. fi
  18.  
  19. SVN_URL="$1"
  20. REPO_NAME=`basename $1`
  21. GIT_EDITOR=`git config --get --global core.editor`
  22.  
  23. echo "Retrieving authors from $SVN_URL..."
  24. svn log -q ${SVN_URL} | awk -F '|' '/^r/ {sub("^ ", "", $2); sub(" $", "", $2); print $2" = "$2" <"$2">"}' | sort -u > authors-transform.txt
  25. printf "\n\nIn order to properly map svn committers to git, you will have to manually edit the list.\n"
  26. printf "For example, youre going to replace lines like: \n\twildcatw = wildcatw <wildcatw> \nwith: \n\twildcatw = Wilbur Wildcat <wilbur@arizona.edu>\n\n"
  27. read -p "Press [Enter] key to start $GIT_EDITOR to edit the list and make sure to SAVE THE FILE BEFORE EXITING..."
  28. $GIT_EDITOR authors-transform.txt
  29.  
  30. mkdir ${REPO_NAME}
  31. cd ${REPO_NAME}
  32. svn2git ${SVN_URL} --authors=../authors-transform.txt
  33.  
  34. if [ $? -eq 0 ]; then
  35. echo "Cleaning up..."
  36. rm ../authors-transform.txt
  37. echo "Created git repo in $REPO_NAME"
  38. exit 0
  39. else
  40. echo "Conversion failed. Leaving authors-transform.txt in place"
  41. exit 1
  42. fi
Add Comment
Please, Sign In to add comment