Allow to run git-extras within git-bulk (#1008)

Co-authored-by: guenthgr <guenther.grill@frauscher.com>
Fix https://github.com/tj/git-extras/issues/1007
This commit is contained in:
Günther Grill 2022-12-07 06:58:18 +01:00 committed by GitHub
parent 960ec8d2fd
commit 7c4152ce83
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 6 deletions

View file

@ -133,12 +133,15 @@ function executBulkOp () {
eval cd "\"$rwsdir\""
local actual=$(pwd)
[ "${quiet?}" != "false" ] && echo 1>&2 "Executing bulk operation in workspace ${inverse}$actual${reset}"
eval find -L . -name ".git" | while read line; do
allGitFolders=( $(eval find -L . -name ".git") )
for line in ${allGitFolders[@]}; do
local gitrepodir=${line::${#line}-5} # cut the .git part of find results to have the root git directory of that repository
eval cd "\"$gitrepodir\"" # into git repo location
local curdir=$(pwd)
local leadingpath=${curdir#${actual}}
[ "${quiet?}" != "false" ] && echo 1>&2 "Current repository: ${leadingpath%/*}/${bldred}${curdir##*/}${reset}"
[ "${quiet?}" != "false" ] && echo 1>&2 "Current repository: ${leadingpath%/*}/${bldred}${curdir##*/}${reset}"
guardedExecution "$@"
eval cd "\"$rwsdir\"" # back to origin location of last find command
done

View file

@ -44,8 +44,8 @@ fi
if [ -n "$SUMMARY_BY_LINE" ]; then
paths=( "$@" )
else
commit=""
test $# -ne 0 && commit=$*
commit="HEAD"
[ $# -ne 0 ] && commit=$*
fi
project=${PWD##*/}
@ -191,13 +191,14 @@ if [ -n "$SUMMARY_BY_LINE" ]; then
echo " authors :"
lines "${paths[@]}" | sort | uniq -c | sort -rn | format_authors
else
echo " repo age : $(repository_age)"
# shellcheck disable=SC2086
echo " active : $(active_days $commit) days"
# shellcheck disable=SC2086
echo " commits : $(commit_count $commit)"
if test "$commit" = ""; then
# The file count doesn't support passing a git ref so ignore it if a ref is given
if [ "$commit" == "HEAD" ]; then
echo " files : $(file_count)"
fi
echo " authors : "