feat: recursively scan for unpushed changes git_repos_status.sh
This commit is contained in:
parent
110f50e6fd
commit
3621202548
44
git_repos_status.sh
Executable file
44
git_repos_status.sh
Executable file
@ -0,0 +1,44 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Colors for output
|
||||
RED='\033[0;31m'
|
||||
GREEN='\033[0;32m'
|
||||
YELLOW='\033[1;33m'
|
||||
CYAN='\033[0;36m'
|
||||
NC='\033[0m' # No Color
|
||||
|
||||
# Find all git repos
|
||||
find . -type d -name ".git" | while read gitdir; do
|
||||
repo=$(dirname "$gitdir")
|
||||
cd "$repo" || continue
|
||||
|
||||
echo -e "${CYAN}Repository: $repo${NC}"
|
||||
|
||||
# Latest 2 commits
|
||||
echo -e " ${YELLOW}Latest 2 commits:${NC}"
|
||||
git log --oneline -2 --decorate
|
||||
|
||||
# Uncommitted file count
|
||||
uncommitted=$(git status --porcelain | wc -l | tr -d ' ')
|
||||
if [ "$uncommitted" -eq 0 ]; then
|
||||
echo -e " ${GREEN}Uncommitted files: $uncommitted${NC}"
|
||||
else
|
||||
echo -e " ${RED}Uncommitted files: $uncommitted${NC}"
|
||||
fi
|
||||
|
||||
# Check for unpushed commits
|
||||
git remote update > /dev/null 2>&1
|
||||
ahead=$(git rev-list --count @{u}..HEAD 2>/dev/null)
|
||||
behind=$(git rev-list --count HEAD..@{u} 2>/dev/null)
|
||||
if [ "$ahead" -gt 0 ]; then
|
||||
echo -e " ${YELLOW}Locally committed (not pushed): $ahead commit(s)${NC}"
|
||||
else
|
||||
echo -e " ${GREEN}All local commits are pushed${NC}"
|
||||
fi
|
||||
if [ "$behind" -gt 0 ]; then
|
||||
echo -e " ${RED}Behind remote by $behind commit(s)${NC}"
|
||||
fi
|
||||
|
||||
echo -e "${CYAN}----------------------------------------${NC}"
|
||||
cd - > /dev/null || exit
|
||||
done
|
||||
Loading…
Reference in New Issue
Block a user