config/git: improve hook and scripts
This commit is contained in:
parent
e4e1ef292e
commit
0b08febafd
|
@ -119,10 +119,10 @@
|
||||||
|
|
||||||
# diffs
|
# diffs
|
||||||
d = diff
|
d = diff
|
||||||
dm = !git diff $(git merge-base $(git main) HEAD)
|
dm = !git diff $(git merge-base $(git main) HEAD) # [d]iff to [m]ain
|
||||||
dw = diff --color-words
|
dw = diff --color-words # [d]iff [w]ords
|
||||||
dc = diff --color-words="[^[:space:]]|([[:alnum:]]|UTF_8_GUARD)+"
|
dc = diff --color-words="[^[:space:]]|([[:alnum:]]|UTF_8_GUARD)+" # [d]iff [c]haracters
|
||||||
du = diff @{push}
|
du = diff @{push} # [d]iff [u]pstream
|
||||||
|
|
||||||
# MODIFY
|
# MODIFY
|
||||||
|
|
||||||
|
|
|
@ -25,10 +25,9 @@ if beginswith $'\n#' "$original"; then
|
||||||
done
|
done
|
||||||
done <<<"$(git -P diff --cached --name-only -r)" &&
|
done <<<"$(git -P diff --cached --name-only -r)" &&
|
||||||
expr substr "$common" 1 "$count" | sed 's|.local/bin/scripts|bin|') || exit 0
|
expr substr "$common" 1 "$count" | sed 's|.local/bin/scripts|bin|') || exit 0
|
||||||
case "$path" in ([0-9]*) path="${path#*/}";; esac
|
case "$path" in ([0-9]-*) path="${path#*-}";; esac
|
||||||
path="${path#.}"
|
|
||||||
{
|
{
|
||||||
echo "${path%-}:"
|
echo "$path" | sed 's|^\.||;s|/\?$|: |'
|
||||||
echo "$original"
|
echo "$original"
|
||||||
} > "$COMMIT_MSG_FILE"
|
} > "$COMMIT_MSG_FILE"
|
||||||
fi
|
fi
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
#!/bin/sh -ex
|
#!/bin/sh -e
|
||||||
# Clones from resolving the arguments and switches into the new directory
|
# Clones from resolving the arguments and switches into the new directory
|
||||||
# ARGS see git-repo, all arguments beyond the first three are forwarded to git-clone
|
# ARGS: see git-repo, all arguments beyond the first three are forwarded to git clone
|
||||||
remote=$(git-repo "$@")
|
remote=$(git-repo "$@")
|
||||||
echo "Cloning $remote"
|
echo "Cloning $remote"
|
||||||
test $1 = https && shift
|
test $1 = https && shift
|
||||||
|
@ -14,7 +14,8 @@ case $# in
|
||||||
(*) dir="${prefix}_$2";;
|
(*) dir="${prefix}_$2";;
|
||||||
esac;;
|
esac;;
|
||||||
esac
|
esac
|
||||||
shift $(expr $# \& $# \< 3 \| 3)
|
case "$4" in (-*|"") cdir="$2";; (*) cdir="$4";; esac
|
||||||
|
shift $(expr 3 \& $# \> 3 \| $#)
|
||||||
git clone $remote "$@" $dir --recurse-submodules
|
git clone $remote "$@" $dir --recurse-submodules
|
||||||
cd "${dir:-${4:-$2}}"
|
cd "${dir:-$cdir}"
|
||||||
exec
|
exec
|
||||||
|
|
|
@ -3,11 +3,17 @@
|
||||||
# Usage:
|
# Usage:
|
||||||
# git repo <url>
|
# git repo <url>
|
||||||
# git repo <host> <repo> [user]
|
# git repo <host> <repo> [user]
|
||||||
test "$1" = https && https=true && shift
|
|
||||||
case "$1" in
|
case "$1" in
|
||||||
(http*) echo "$1" | sed "s|.*//\([^/]*\)/\(.*\)|git@\1:\2.git|" ;;
|
(http*)
|
||||||
(git:*|ssh:*) echo "$1" ;;
|
if expr "$1" : ".*:" >/dev/null
|
||||||
(*)
|
then echo "$1" | sed "s|.*//\([^/]*\)/\(.*\)|git@\1:\2.git|"
|
||||||
|
exit
|
||||||
|
else http=$1 && shift
|
||||||
|
fi;;
|
||||||
|
(git:*|ssh:*)
|
||||||
|
echo "$1"
|
||||||
|
exit;;
|
||||||
|
esac
|
||||||
case $1 in
|
case $1 in
|
||||||
(socha) user=software-challenge; host=git@github.com;;
|
(socha) user=software-challenge; host=git@github.com;;
|
||||||
(hub) host=git@github.com;;
|
(hub) host=git@github.com;;
|
||||||
|
@ -16,8 +22,7 @@ case "$1" in
|
||||||
esac
|
esac
|
||||||
user=${3:-${user:-$(git config user.name)}}
|
user=${3:-${user:-$(git config user.name)}}
|
||||||
repo=${2:-$(basename $PWD)}
|
repo=${2:-$(basename $PWD)}
|
||||||
if test "$https"
|
if test "$http"
|
||||||
then echo "https://${host#git*@}/$user/$repo.git"
|
then echo "$http://${host#git*@}/$user/$repo.git"
|
||||||
else echo "$host:$user/$repo.git"
|
else echo "$host:$user/$repo.git"
|
||||||
fi
|
fi
|
||||||
esac
|
|
||||||
|
|
Loading…
Reference in New Issue