зеркало из https://github.com/mislav/hub.git
25 строки
683 B
Bash
Executable File
25 строки
683 B
Bash
Executable File
#!/bin/bash
|
|
# A wrapper for system git that prevents commands such as `clone` or `fetch` to be
|
|
# executed in testing. It logs commands to "~/.history" so afterwards it can be
|
|
# asserted that they ran.
|
|
|
|
command="$1"
|
|
[ "$command" = "config" ] || echo git "$@" >> "$HOME"/.history
|
|
|
|
case "$command" in
|
|
"clone" | "fetch" | "pull" | "push" )
|
|
# don't actually execute these commands
|
|
exit
|
|
;;
|
|
* )
|
|
# note: `submodule add` also initiates a clone, but we work around it
|
|
if [ "$command $2 $3" = "remote add -f" ]; then
|
|
subcommand=$2
|
|
shift 3
|
|
exec "$HUB_SYSTEM_GIT" $command $subcommand "$@"
|
|
else
|
|
exec "$HUB_SYSTEM_GIT" "$@"
|
|
fi
|
|
;;
|
|
esac
|