]> git.nbdom.net Git - nb.git/commitdiff
etc/profile.d/nb.sh
authorNicolas Boisselier <nicolas.boisselier@gmail.com>
Mon, 12 Feb 2024 09:44:04 +0000 (10:44 +0100)
committerNicolas Boisselier <nicolas.boisselier@gmail.com>
Mon, 12 Feb 2024 09:44:04 +0000 (10:44 +0100)
etc/profile.d/nb.sh

index 54ce0fd8052f6e7682ec13178118502246136c4c..33d76749d1a6e29814072a330e27347d7ef305bb 100644 (file)
@@ -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
 }