config/git: improve username handling

This commit is contained in:
xeruf 2022-07-03 22:33:28 +02:00
parent cefd400322
commit e5332e9a48
3 changed files with 13 additions and 8 deletions

View File

@ -107,7 +107,7 @@
lg = lgr HEAD @{push}
lo = log --pretty=tformat:'%C(auto)%h%d %s %Cgreen(%cd) %Cblue<%an>%Creset' --date=human --no-merges
lp = log -p --date=local
my = lo --author [Jj]anek
my = lo --author "xeru\\|anek"
standup = my --since yesterday --all
co-authors = !git log | grep -i Co-Authored | awk '!a[$0]++'

View File

@ -13,8 +13,11 @@ if test -d ".git"
then repo="$(basename "$PWD")"
git remote set-url origin "$(git-repo "${3:-github.com}" "$repo" "$2" "${@:4}")"
else repo="$1" && shift
# TODO cd into 1-/0-forks
git-get "${3:-github.com}" "$repo" "${2:-$(git config --get user.name)}" "${@:4}"
test -d "$d1" && cd "$d1/0-forks"
if ! git-get "${3:-github.com}" "$repo" "${2:-$(git config --get user.name)}" "${@:4}"
then repo="$1-$repo"
git-get "${3:-github.com}" "$repo" "${2:-$(git config --get user.name)}" "${@:4}"
fi
cd "$(expr "$4" \| "$repo")"
fi
user="${1:-$repo}"

View File

@ -5,11 +5,13 @@ remote=$(git-repo "$@")
echo "Cloning $remote"
case $# in
(1) dir=$(basename ${remote%.git});;
(3) prefix=$(echo "$3" | sed "s|\(.\)\b.*$|\1|")
case "$2" in
("$prefix"*) ;;
(*) dir="${prefix}_$2";;
esac;;
(3) test "$3" != "$(git config --get user.name)" &&
prefix=$(echo "$3" | sed "s|\(.\)\b.*$|\1|") &&
case "$2" in
("$prefix"*) ;;
("$(git config --get user.name)") ;;
(*) dir="${prefix}_$2";;
esac;;
esac
shift 3
git clone $remote "$@" $dir --recurse-submodules