Rework git-status-recursive and convert to git sub-command
Signed-off-by: Knut Ahlers <knut@ahlers.me>
This commit is contained in:
parent
e945a5d9cf
commit
3d33b8d73b
2 changed files with 28 additions and 16 deletions
28
bin/git-status-recursive
Executable file
28
bin/git-status-recursive
Executable file
|
@ -0,0 +1,28 @@
|
|||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
CHECK=$(printf '\u2705')
|
||||
CROSS=$(printf '\u274C')
|
||||
|
||||
startpath=$(pwd)
|
||||
|
||||
function check() {
|
||||
bash -euo pipefail -c "LANG=C $1" && echo -n "${CHECK}" || echo -n "${CROSS}"
|
||||
}
|
||||
|
||||
for repo in $(find . -name ".git"); do
|
||||
cd $(dirname $repo)
|
||||
reponame=$(short_path)
|
||||
|
||||
clean=$(check 'git status | grep -q "nothing to commit"')
|
||||
remote=$(check 'git remote -vv | grep -q "push"')
|
||||
ahead=$(check 'git status | grep -q "is up to date with"')
|
||||
branch=$(check 'git branch --show-current | grep -qE "(develop|main|master)"')
|
||||
|
||||
echo -e "${reponame}\t${branch}\t${clean}\t${remote}\t${ahead}"
|
||||
|
||||
cd $startpath
|
||||
done | sort | column -t -N "Repo,B,C,R,U" -s $'\t'
|
||||
|
||||
echo
|
||||
echo "B = On base-branch, C = Clean, R = Remote set, U = Up to date with remote"
|
|
@ -1,16 +0,0 @@
|
|||
#!/bin/bash
|
||||
|
||||
[ -e ~/.bashcolors ] && . ~/.bashcolors
|
||||
|
||||
startpath=$(pwd)
|
||||
|
||||
for repo in $(find . -name ".git"); do
|
||||
repodir=$(dirname $repo)
|
||||
reponame=$(basename $repodir)
|
||||
cd $repodir
|
||||
LANG=C git status | grep -q "nothing to commit"
|
||||
state=$?
|
||||
cd $startpath
|
||||
echo -n "$reponame: "
|
||||
[ $state -eq 0 ] && echo -e "${PR_GREEN}Up-2-date${PR_NC}" || echo -e "${PR_BR_RED}Changes available${PR_NC}"
|
||||
done
|
Loading…
Reference in a new issue