Skip to content

Instantly share code, notes, and snippets.

@KenshoFujisaki
Last active August 29, 2015 14:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save KenshoFujisaki/2734293810fd01181a0e to your computer and use it in GitHub Desktop.
Save KenshoFujisaki/2734293810fd01181a0e to your computer and use it in GitHub Desktop.
svndiff (svn差分確認のための関数。コードレビュー効率化のためのショートカット)
# ------------------------------------------------------------------------
# svndiff
# ------------------------------------------------------------------------
function svndiff() {
help() {
echo "Usage: svndiff [option] [filename]"
echo "Customize: ~/.zshrc"
return
}
if [ $# -eq 0 ] ; then
help
return
fi
for arg in $* ; do
# 引数一つ一つについてcase文で条件分岐
case $arg in
-h|--help)
help
return
;;
# svn diff を unified diff
-d|--unified-diff)
/usr/bin/svn diff --diff-cmd diff -x '-U20 -w'
return
;;
# modified状態のファイル名取得
-mf|--modified-files)
svn status | awk '$1~/M/{print $2}'
return
;;
# リポジトリ内で変更のあるファイル全てのファイル名取得
-af|--all-files)
svn status
return
;;
# 変更のあったファイルをvimdiff
-v|--vimdiff)
svn diff
return
;;
# その他の場合
*)
svn diff $arg
esac
done
return
}
_svndiffcmd() {
_arguments \
'(- *)'{-h,--help}'[show help]' \
{-d,--unified-diff}'[unified diff]' \
{-mf,--modified-files}'[modified files]' \
{-af,--all-files}'[all files]' \
{-v,--vimdiff}'[vimdiff]' \
'*: :_files'
}
compdef _svndiffcmd svndiff
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment