mirror of
ssh://git.janware.com/janware/proj/jw-pkg
synced 2026-04-24 09:13:37 +02:00
pgit.sh: Beautify logging
Log to stderr and add some ASCII-art around the output. Also, add a --porcelain option to allow more stable output parsing. Subsequently, use that option in make targets parsing the output, notably make diff and make git-show-xxx. Signed-off-by: Jan Lindemann <jan@janware.com>
This commit is contained in:
parent
0ca51e16ee
commit
27bf98f747
2 changed files with 46 additions and 10 deletions
|
|
@ -305,7 +305,7 @@ pull-all: purge git-get git-pull-all
|
||||||
touch pull.done
|
touch pull.done
|
||||||
|
|
||||||
diff-all diff: $(SSH_WRAPPER_SH)
|
diff-all diff: $(SSH_WRAPPER_SH)
|
||||||
$(PGIT_SH) diff
|
$(PGIT_SH) --porcelain diff
|
||||||
|
|
||||||
get-official: git-get-official
|
get-official: git-get-official
|
||||||
get-maintainer: git-get-maintainer
|
get-maintainer: git-get-maintainer
|
||||||
|
|
@ -321,10 +321,10 @@ git-push-all: $(SSH_WRAPPER_SH)
|
||||||
$(PGIT_SH) push $(PGIT_SH_OPTS_NETWORK) --all --recurse-submodules=on-demand
|
$(PGIT_SH) push $(PGIT_SH_OPTS_NETWORK) --all --recurse-submodules=on-demand
|
||||||
|
|
||||||
git-diff: $(SSH_WRAPPER_SH)
|
git-diff: $(SSH_WRAPPER_SH)
|
||||||
$(PGIT_SH) diff
|
$(PGIT_SH) --porcelain diff
|
||||||
|
|
||||||
git-short-diff: $(SSH_WRAPPER_SH)
|
git-short-diff: $(SSH_WRAPPER_SH)
|
||||||
$(PGIT_SH) diff --shortstat
|
$(PGIT_SH) --porcelain diff --shortstat
|
||||||
|
|
||||||
git-status:
|
git-status:
|
||||||
$(PGIT_SH) status -uno
|
$(PGIT_SH) status -uno
|
||||||
|
|
@ -349,7 +349,7 @@ git-get-%: $(SSH_WRAPPER_SH)
|
||||||
$(PGIT_SH_GET) $(PGIT_SH_OPTS_NETWORK) --refspec "$*:master:current-branch"
|
$(PGIT_SH_GET) $(PGIT_SH_OPTS_NETWORK) --refspec "$*:master:current-branch"
|
||||||
|
|
||||||
git-show-non-master-branches:
|
git-show-non-master-branches:
|
||||||
$(Q)$(PGIT_SH) branch 2>&1 | \
|
$(Q)$(PGIT_SH) --porcelain branch 2>&1 | \
|
||||||
sed '/^#\|^*/!d; s/.*git -C //; s/ *branch *//; s/ *\* *//' | \
|
sed '/^#\|^*/!d; s/.*git -C //; s/ *branch *//; s/ *\* *//' | \
|
||||||
while read p; do \
|
while read p; do \
|
||||||
read b ;\
|
read b ;\
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,13 @@
|
||||||
|
|
||||||
log()
|
log()
|
||||||
{
|
{
|
||||||
echo "$myname $*"
|
local prefix="| "
|
||||||
|
[ "$porcelain" = 0 ] || prefix=""
|
||||||
|
if [ "$1" ]; then
|
||||||
|
echo "$prefix$*" >&2
|
||||||
|
else
|
||||||
|
sed "s/^/$prefix/" >&2
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
err()
|
err()
|
||||||
|
|
@ -38,6 +44,26 @@ fat_marker()
|
||||||
log "# ====================================================$(counter) $@"
|
log "# ====================================================$(counter) $@"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
log_start_stop()
|
||||||
|
{
|
||||||
|
[ "$porcelain" = 1 ] || return
|
||||||
|
local b e
|
||||||
|
if [ "$1" = start ]; then
|
||||||
|
b=","
|
||||||
|
e=">"
|
||||||
|
else
|
||||||
|
b="\`"
|
||||||
|
e="<"
|
||||||
|
fi
|
||||||
|
shift
|
||||||
|
echo "$b----------------------------------------------- Running $cmdline --$e--" >&2
|
||||||
|
}
|
||||||
|
|
||||||
|
goodbye()
|
||||||
|
{
|
||||||
|
log_start_stop stop
|
||||||
|
}
|
||||||
|
|
||||||
#
|
#
|
||||||
# Guess and set the following global variables:
|
# Guess and set the following global variables:
|
||||||
#
|
#
|
||||||
|
|
@ -72,7 +98,11 @@ set_global_variables()
|
||||||
run_git()
|
run_git()
|
||||||
{
|
{
|
||||||
marker git "$@"
|
marker git "$@"
|
||||||
git "$@"
|
if [ "$porcelain" = 1 ]; then
|
||||||
|
git "$@"
|
||||||
|
else
|
||||||
|
git "$@" 2>&1 | log
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
# ----------------- Commands
|
# ----------------- Commands
|
||||||
|
|
@ -194,7 +224,7 @@ cmd_get()
|
||||||
|
|
||||||
if [ -z "$projects" ]; then
|
if [ -z "$projects" ]; then
|
||||||
projects=`$jw_projects projects list-repos --from-owner $from_user $remote_base`
|
projects=`$jw_projects projects list-repos --from-owner $from_user $remote_base`
|
||||||
[ "$?" != 0 ] && exit 1
|
[ "$?" != 0 ] && fatal "Failed to enumerate repositories"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "$remote_user" ]; then
|
if [ "$remote_user" ]; then
|
||||||
|
|
@ -224,7 +254,7 @@ cmd_get()
|
||||||
[ "$refspec_arg" -a "$refspec_arg" != "$from_user:$from_ref:$to_ref" ] && log_refspec="$log_refspec ($refspec_arg)"
|
[ "$refspec_arg" -a "$refspec_arg" != "$from_user:$from_ref:$to_ref" ] && log_refspec="$log_refspec ($refspec_arg)"
|
||||||
fat_marker "Getting project $project_name from $log_refspec"
|
fat_marker "Getting project $project_name from $log_refspec"
|
||||||
if [ -d $project_dir ]; then
|
if [ -d $project_dir ]; then
|
||||||
run_git -C $project_dir remote | grep -q "^$remote_name$" || {
|
git -C $project_dir remote | grep -q "^$remote_name$" || {
|
||||||
run_git -C $project_dir remote add $remote_name $pull_url
|
run_git -C $project_dir remote add $remote_name $pull_url
|
||||||
[ "$from_user" = "$remote_user" ] || run_git -C $project_dir remote set-url --push $remote_name no_push
|
[ "$from_user" = "$remote_user" ] || run_git -C $project_dir remote set-url --push $remote_name no_push
|
||||||
}
|
}
|
||||||
|
|
@ -265,7 +295,9 @@ cmd_diff()
|
||||||
)
|
)
|
||||||
|
|
||||||
myname=${0##*/}
|
myname=${0##*/}
|
||||||
log "Running $0 $@"
|
cmdline="$myname $*"
|
||||||
|
porcelain=0
|
||||||
|
log_start_stop start
|
||||||
log "GIT_SSH=$GIT_SSH"
|
log "GIT_SSH=$GIT_SSH"
|
||||||
log "JW_PKG_SSH_EXTRA_OPTS=$JW_PKG_SSH_EXTRA_OPTS"
|
log "JW_PKG_SSH_EXTRA_OPTS=$JW_PKG_SSH_EXTRA_OPTS"
|
||||||
|
|
||||||
|
|
@ -280,6 +312,9 @@ while [ "${1:0:1}" = - ]; do
|
||||||
global_remote_base="$2"
|
global_remote_base="$2"
|
||||||
shift
|
shift
|
||||||
;;
|
;;
|
||||||
|
'--porcelain')
|
||||||
|
porcelain=1
|
||||||
|
;;
|
||||||
esac
|
esac
|
||||||
shift
|
shift
|
||||||
done
|
done
|
||||||
|
|
@ -299,12 +334,13 @@ while [ "${1:0:1}" = - ]; do
|
||||||
case $1 in
|
case $1 in
|
||||||
'--login')
|
'--login')
|
||||||
remote_user="$2"
|
remote_user="$2"
|
||||||
shift 2
|
shift
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
break
|
break
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
shift
|
||||||
done
|
done
|
||||||
|
|
||||||
case $cmd in
|
case $cmd in
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue