From ee743bed04c25162280520539692ca9afbf25462 Mon Sep 17 00:00:00 2001 From: Nicolas Boisselier Date: Mon, 12 Feb 2024 10:44:04 +0100 Subject: [PATCH] etc/profile.d/nb.sh --- etc/profile.d/nb.sh | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/etc/profile.d/nb.sh b/etc/profile.d/nb.sh index 54ce0fd8..33d76749 100644 --- a/etc/profile.d/nb.sh +++ b/etc/profile.d/nb.sh @@ -23,20 +23,33 @@ nb_repos_status() { local status i branch local ret=0 local sav_pwd=${PWD:-$(pwd)} + for i in ${@:-$(nb_repos)}; do cd "$i" || continue + local branch_orig=$(git branch | awk '/^\*/{print $2}') [ -z "$branch_orig" ] && continue + local u=$( ls -1dl "$i" | awk '{print $3}' ) + if [ "$u" != "$USER" ]; then + #echo "$i [WRONG OWNER]" + printf "%s %s\n" "$i [$branch_orig]" "WRONG OWNER" + continue + fi + for branch in $(git branch | sed -E 's/^[\* ]+//'); do - git checkout --quiet "$branch" || continue + + 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" + done git checkout --quiet "$branch_orig" + done + cd "$sav_pwd" return $ret } -- 2.47.3