1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
#!/bin/bash export LOG_PREFIX="[fetch_code $remote @ $checkout -> $path]" log "fetch!" git clone "$remote" "$path" if [ ! $? -eq 0 ]; then log "D: failed to clone" exit 1 fi cd "$path" log "checkout $checkout" git reset --hard "$checkout" if [ ! $? -eq 0 ]; then log "D: can't reset to $checkout" cd - exit 1 fi cd -