mirror of
				https://github.com/ruby/ruby.git
				synced 2022-11-09 12:17:21 -05:00 
			
		
		
		
	 a1e589498d
			
		
	
	
		a1e589498d
		
	
	
	
	
		
			
			if the tag is already checked out, to optimize the execution time. I'm going to prepare a task depending on this tool, and I want that to finish fast and output nothing when it's already up-to-date. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63883 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
		
			
				
	
	
		
			46 lines
		
	
	
	
		
			1.1 KiB
		
	
	
	
		
			Bash
		
	
	
		
			Executable file
		
	
	
	
	
			
		
		
	
	
			46 lines
		
	
	
	
		
			1.1 KiB
		
	
	
	
		
			Bash
		
	
	
		
			Executable file
		
	
	
	
	
| #!/bin/sh
 | |
| set -e
 | |
| 
 | |
| if (cd -P .) 2>/dev/null; then
 | |
|     CHDIR='cd -P'
 | |
| else
 | |
|     CHDIR='cd'
 | |
| fi
 | |
| 
 | |
| quiet=
 | |
| branch=
 | |
| 
 | |
| until [ $# = 0 ]; do
 | |
|     case "$1" in
 | |
| 	--) shift; break;;
 | |
| 	-C|--directory) shift; $CHDIR "$1";;
 | |
| 	-C*) $CHDIR `expr "$1" : '-C\(.*\)'`;;
 | |
| 	--directory=*) $CHDIR `expr "$1" : '[^=]*=\(.*\)'`;;
 | |
| 	-q) quiet=1;;
 | |
| 	-b|--branch) shift; branch="$1";;
 | |
| 	-b*) branch=`expr "$1" : '-b\(.*\)'`;;
 | |
| 	--branch=*) branch=`expr "$1" : '[^=]*=\(.*\)'`;;
 | |
| 	-*) echo "unknown option: $1" 1>&2; exit 1;;
 | |
| 	*) break;;
 | |
|     esac
 | |
|     shift
 | |
| done
 | |
| 
 | |
| url="$1"
 | |
| dir="$2"
 | |
| shift 2
 | |
| [ x"$branch" = x ] && unset branch || :
 | |
| if [ -d "$dir" ]; then
 | |
|     if [ x"$(git -C "$dir" describe --tags)" = x"$branch" ]; then
 | |
|         exit 0 # already up-to-date
 | |
|     fi
 | |
|     echo updating `expr "/$dir/" : '.*/\([^/][^/]*\)/'` ...
 | |
|     [ $quiet ] || set -x
 | |
|     $CHDIR "$dir"
 | |
|     ${branch+git} ${branch+fetch} ${branch+"$@"}
 | |
|     exec git ${branch+checkout} "${branch-pull}" "$@"
 | |
| else
 | |
|     echo retrieving `expr "/$dir/" : '.*/\([^/][^/]*\)/'` ...
 | |
|     [ $quiet ] || set -x
 | |
|     exec git clone ${branch+--branch} ${branch+"$branch"} "$url" "$dir" "$@"
 | |
| fi
 |