From 18c5c58f2e3f90a03cd13eee0bc6025c9a46e2cd Mon Sep 17 00:00:00 2001 From: Nicolas Boisselier Date: Tue, 13 Feb 2024 08:52:34 +0100 Subject: [PATCH] etc/profile.d/nb.sh --- etc/profile.d/nb.sh | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/etc/profile.d/nb.sh b/etc/profile.d/nb.sh index 86d43256..8ca8e35a 100644 --- a/etc/profile.d/nb.sh +++ b/etc/profile.d/nb.sh @@ -22,14 +22,19 @@ nb_repos_status() { shell_help "List repos git status" "$@" && return local status i branch local ret=0 + local repo_filter="$1" local sav_pwd=${PWD:-$(pwd)} + local repo - for i in ${@:-$(nb_repos)}; do - cd "$i" || continue + for repo in ${@:-$(nb_repos)}; do + [ -n "$repo_filter" -a "$repo_filter" != "$repo" ] && continue + cd "$repo" || continue - local u=$( ls -1dl "$i" | awk '{print $3}' ) + local u=$( ls -1dl "$repo" | awk '{print $3}' ) if [ "$u" != "$USER" ]; then - printf "%s %s\n" "$i" "WRONG OWNER" + #printf "%s %s\n" "$repo" "WRONG OWNER" + sudo -i -u "$u" nb_repos_status "$repo" + [ "$?" != "0" ] && ret=1 continue fi @@ -41,7 +46,7 @@ nb_repos_status() { git checkout --quiet "$branch" 2>/dev/null || continue status=$(git status --short | grep -v '^#'|sed 's/^/ /') || continue [ -n "$status" ] && status=$'\n'"$status" && ret=1 - printf "%s %s\n" "$i [$branch]" "$status" + printf "%s %s\n" "$repo [$branch]" "$status" done -- 2.47.3