63 lines
1.5 KiB
Bash
Executable File
63 lines
1.5 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
# File: uniglot-clone
|
|
#
|
|
# Description: This is a convenience script to ensure our hooks are standardized.
|
|
#
|
|
# Package: AniNIX/Uniglot
|
|
# Copyright: WTFPL
|
|
#
|
|
# Author: DarkFeather <ircs://aninix.net:6697/DarkFeather>
|
|
|
|
function uniglotClone() {
|
|
target="$1"
|
|
git-clone "$target"
|
|
clone="$(basename "$1" | sed 's/.git$//')"
|
|
cd "$clone"
|
|
}
|
|
|
|
|
|
### usage
|
|
### param retcode: what to return
|
|
function usage() {
|
|
retcode="$1"
|
|
echo "Usage: $0 # Update the current clone"
|
|
echo " $0 -t target # Clone the target and set hooks"
|
|
echo " $0 -h # Help"
|
|
echo Add -v for verbosity.
|
|
}
|
|
|
|
### Main
|
|
if [ `basename "$0"` == "uniglot-clone" ]; then
|
|
while getopts 'ht:v' OPTION; do
|
|
case "$OPTION" in
|
|
h) echo AniNIX/Uniglot git-clone standardization; usage 0 ;;
|
|
t) target="$OPTARG" ;;
|
|
v) set -x ;;
|
|
*) usage 1 ;;
|
|
esac
|
|
done
|
|
|
|
if [ -n "$target" ]; then
|
|
uniglotClone "$target"
|
|
cd "$(basename "$target" | sed 's/.git$//')"
|
|
fi
|
|
|
|
# Sanity
|
|
if [ ! -d .git ]; then
|
|
echo "This should be run from the root of the clone."
|
|
exit 2
|
|
fi
|
|
|
|
# Standardizations
|
|
|
|
# If the repo is Uniglot...
|
|
if git config remote.origin.url | grep -q AniNIX/Uniglot; then
|
|
# Set the hooks to the local directory
|
|
git config core.hooksPath $PWD/Hooks
|
|
else
|
|
# Otherwise set it to the global hooks
|
|
git config core.hooksPath /opt/aninix/Uniglot/Hooks
|
|
fi
|
|
fi
|