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} lg = lgr HEAD @{push}
lo = log --pretty=tformat:'%C(auto)%h%d %s %Cgreen(%cd) %Cblue<%an>%Creset' --date=human --no-merges lo = log --pretty=tformat:'%C(auto)%h%d %s %Cgreen(%cd) %Cblue<%an>%Creset' --date=human --no-merges
lp = log -p --date=local lp = log -p --date=local
my = lo --author [Jj]anek my = lo --author "xeru\\|anek"
standup = my --since yesterday --all standup = my --since yesterday --all
co-authors = !git log | grep -i Co-Authored | awk '!a[$0]++' 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")" then repo="$(basename "$PWD")"
git remote set-url origin "$(git-repo "${3:-github.com}" "$repo" "$2" "${@:4}")" git remote set-url origin "$(git-repo "${3:-github.com}" "$repo" "$2" "${@:4}")"
else repo="$1" && shift else repo="$1" && shift
# TODO cd into 1-/0-forks test -d "$d1" && cd "$d1/0-forks"
git-get "${3:-github.com}" "$repo" "${2:-$(git config --get user.name)}" "${@:4}" 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")" cd "$(expr "$4" \| "$repo")"
fi fi
user="${1:-$repo}" user="${1:-$repo}"

View File

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