Created
September 15, 2010 16:03
-
-
Save mcarneiro/580966 to your computer and use it in GitHub Desktop.
bash commands for SVN
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
if [ "$1" = "?" ] | |
then | |
B1="\033[1m"; | |
B2="\033[0m"; | |
echo -e ""; | |
echo -e "${B1}AUTHOR${B2}"; | |
echo -e " Marcelo Miranda Carneiro - [email protected]"; | |
echo -e ""; | |
echo -e "${B1}INFO${B2} (release 2011-01-11)"; | |
echo -e " log changes by user (SVN)"; | |
echo -e ""; | |
echo -e "${B1}USAGE${B2}"; | |
echo -e " log-by-user SVN_PARAMETERS USERNAME"; | |
echo -e ""; | |
echo -e "${B1}EXAMPLES${B2}"; | |
echo -e " log-by-user -l10 \"mcarneiro\""; | |
echo -e " log-by-user -r10:HEAD \"mcarneiro\""; | |
echo -e ""; | |
exit 1; | |
fi | |
svn log -v $1 | sed -n "/"$2"/,/-----$/ p" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
if [ "$1" = "?" ] | |
then | |
B1="\033[1m"; | |
B2="\033[0m"; | |
echo -e ""; | |
echo -e "${B1}AUTHOR${B2}"; | |
echo -e " Marcelo Miranda Carneiro - [email protected]"; | |
echo -e ""; | |
echo -e "${B1}INFO${B2} (release 2011-01-11)"; | |
echo -e " add files and folders recursivelly applying the current \"svn:ignore\" property"; | |
echo -e ""; | |
echo -e "${B1}USAGE${B2}"; | |
echo -e " svn-ignore-add FOLDER_NAME"; | |
echo -e ""; | |
exit 1; | |
fi | |
svn add $1 --force --depth empty; svn pset svn:ignore "$(svn pget svn:ignore .)" $1; svn add $1 --force --depth files; | |
DIRECTORIES=(`svn st $1 | grep "^?" | awk '{print$2}'`); | |
if [ "$DIRECTORIES" != "" ] | |
then | |
for a in "${DIRECTORIES[@]}"; | |
do | |
if [ -d "$a" ] | |
then | |
svn-ignore-add $a; | |
fi; | |
done; | |
fi; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# quick way to get svn revision. useful for using in another functions | |
# usage svn-rev [FOLDER] | |
if [ "$1" = "?" ] | |
then | |
B1="\033[1m"; | |
B2="\033[0m"; | |
echo -e ""; | |
echo -e "${B1}AUTHOR${B2}"; | |
echo -e " Marcelo Miranda Carneiro - [email protected]"; | |
echo -e ""; | |
echo -e "${B1}INFO${B2} (release 2011-01-11)"; | |
echo -e " quick way to get svn revision. useful for using with another functions"; | |
echo -e ""; | |
echo -e "${B1}USAGE${B2}"; | |
echo -e " svn-rev [FOLDER]"; | |
echo -e ""; | |
exit 1; | |
fi | |
svn info $1 | grep "Revision:" | awk '{print$2}' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
if [ "$1" = "?" ] | |
then | |
B1="\033[1m"; | |
B2="\033[0m"; | |
echo -e ""; | |
echo -e "${B1}AUTHOR${B2}"; | |
echo -e " Marcelo Miranda Carneiro - [email protected]"; | |
echo -e ""; | |
echo -e "${B1}INFO${B2} (release 2011-01-11)"; | |
echo -e " Gets only the url from svn info command"; | |
echo -e ""; | |
echo -e "${B1}USAGE${B2}"; | |
echo -e " svn-url [BACK] [FOLDER]"; | |
echo -e ""; | |
echo -e " BACK number of \"back directories\" from the current url"; | |
echo -e " FOLDER folder to execute svn info"; | |
echo -e ""; | |
echo -e "${B1}EXAMPLES${B2}"; | |
echo -e " svn-url # https://svn.domain:8443/svn/project/branches/" | |
echo -e " svn-url 1 # https://svn.desenv:8443/svn/project/" | |
echo -e " svn-url 0 test/ # https://svn.desenv:8443/svn/project/branches/test/" | |
echo -e ""; | |
exit 1; | |
fi | |
URL_BACK_NUM="0" | |
URL=$(svn info $2 | grep "URL:" | awk '{print $2}')"/" | |
if [ "$1" != "" ] | |
then | |
URL_BACK_NUM="$1" | |
fi | |
if [ "$URL_BACK_NUM" = "0" ] | |
then | |
echo $URL | |
else | |
URL_TO_FILTER=$(echo $URL | awk -F "/" '{print $(NF+'$(($URL_BACK_NUM))')}') | |
echo $URL | awk -F "$URL_TO_FILTER/" '{print$1}' | |
fi |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
B1="\033[1m"; | |
B2="\033[0m"; | |
if [ "$1" = "?" ] | |
then | |
echo -e ""; | |
echo -e "${B1}AUTHOR${B2}"; | |
echo -e " Marcelo Miranda Carneiro - [email protected]"; | |
echo -e ""; | |
echo -e "${B1}INFO${B2} (release Qua 14 Set 2011 12:43:13 BRT)"; | |
echo -e " Creates a zip file with the modified or created files from a range of revisions"; | |
echo -e ""; | |
echo -e "${B1}USAGE${B2}"; | |
echo -e " zip-by-log [FILENAME] SVN_PARAMETERS"; | |
echo -e ""; | |
echo -e "${B1}EXAMPLES${B2}"; | |
echo -e " zip-by-log -l10"; | |
echo -e " zip-by-log ftp.zip -l10"; | |
echo -e " zip-by-log ftp.zip \"-r10 -r20\""; | |
echo -e ""; | |
exit 1; | |
fi | |
if [ "$#" = "2" ]; | |
then | |
FILENAME=$1; | |
LOG=$2; | |
else | |
LOG=$1; | |
FILENAME="log_$LOG"; | |
fi | |
HASZIP=`which zip`; | |
SVN_URL=`svn info | grep "URL:" | awk '{print $2}'`"/"; | |
PATH_TO_FILTER="$( echo $SVN_URL | awk -F "/" '{print $(NF-1)}')"; | |
ARGUMENTS=`svn log $LOG -v | grep $PATH_TO_FILTER | grep -E "\s+?[AMR]" | awk -F "$PATH_TO_FILTER/" '{print $2}' | awk '{print $1}' | grep "\." | sort -u`; | |
if [ "$HASZIP" = "" ]; | |
then | |
echo -e "Adding files to ${B1}\"$FILENAME.tar\"${B2}: " | |
tar -cvf "$FILENAME".tar $ARGUMENTS; | |
else | |
echo -e "Adding files to ${B1}\"$FILENAME.zip\"${B2}: " | |
zip "$FILENAME".zip $ARGUMENTS; | |
fi; | |
echo -e "${B1}Finished!${B2}"; | |
exit 1; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
if [ "$1" = "?" ] | |
then | |
B1="\033[1m"; | |
B2="\033[0m"; | |
echo -e ""; | |
echo -e "${B1}AUTHOR${B2}"; | |
echo -e " Marcelo Miranda Carneiro - [email protected]"; | |
echo -e ""; | |
echo -e "${B1}INFO${B2} (release 2011-02-18)"; | |
echo -e " Creates a zip file with the modified or created files from the current changes on working copy"; | |
echo -e ""; | |
echo -e "${B1}USAGE${B2}"; | |
echo -e " zip-by-log [FILENAME]"; | |
echo -e ""; | |
echo -e "${B1}EXAMPLES${B2}"; | |
echo -e " zip-by-status # if no name is passed, creates a 'status.zip' file"; | |
echo -e " zip-by-status ftp.zip"; | |
echo -e ""; | |
exit 1; | |
fi | |
FILENAME=$1; | |
if [ "$FILENAME" = "" ]; | |
then | |
FILENAME="status.zip"; | |
fi | |
zip $FILENAME $(svn st | grep "^[AM]" | awk '{print$(NF)}') |
All commands have a new "help" option. Ex.: "svn-url ?"
I moved these commands to a github repository at https://github.com/mcarneiro/bash-stuff
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This scripts were made in Mac osx 10.5.8 using the native bash. Obviously its required a command-line version of SVN.
To make this commands work, edit or create the
.bash_profile
in the current user folder:Place these files on the
~/bin/
folder and give them permission to execute: