Limit clean repos to top 5 and offer gp -y for dirty repos
This commit is contained in:
48
whatsdirty
48
whatsdirty
@@ -372,8 +372,14 @@ print_clean_repositories() {
|
||||
local temp_file="$1"
|
||||
|
||||
if grep -q "^C|" "$temp_file" 2>/dev/null; then
|
||||
printf "\n=== CLEAN REPOSITORIES ===\n\n"
|
||||
grep "^C|" "$temp_file" | sort -t'|' -k2,2n | while IFS='|' read -r _ _ changes repo hours_fmt upstream_status upstream_ahead upstream_behind; do
|
||||
local total_clean
|
||||
total_clean=$(grep -c "^C|" "$temp_file" 2>/dev/null)
|
||||
if [ "$total_clean" -gt 5 ]; then
|
||||
printf "\n=== CLEAN REPOSITORIES (top 5 of %d) ===\n\n" "$total_clean"
|
||||
else
|
||||
printf "\n=== CLEAN REPOSITORIES ===\n\n"
|
||||
fi
|
||||
grep "^C|" "$temp_file" | sort -t'|' -k2,2n | head -5 | while IFS='|' read -r _ _ changes repo hours_fmt upstream_status upstream_ahead upstream_behind; do
|
||||
local upstream_fmt
|
||||
upstream_fmt=$(format_upstream_status "$upstream_status" "$upstream_ahead" "$upstream_behind")
|
||||
printf "%-40s %15s %-10s %-10s %-12b\n" "$repo" "$hours_fmt" "$changes" "Clean" "$upstream_fmt"
|
||||
@@ -381,6 +387,41 @@ print_clean_repositories() {
|
||||
fi
|
||||
}
|
||||
|
||||
# === Interactive Functions ===
|
||||
|
||||
offer_gp_dirty_repos() {
|
||||
local temp_file="$1"
|
||||
local base_dir="$2"
|
||||
|
||||
# Collect dirty repo names
|
||||
local -a dirty_repos=()
|
||||
while IFS='|' read -r type _ _ repo _; do
|
||||
dirty_repos+=("$repo")
|
||||
done < <(grep "^D|" "$temp_file" 2>/dev/null | sort -t'|' -k3,3nr)
|
||||
|
||||
if [ ${#dirty_repos[@]} -eq 0 ]; then
|
||||
return
|
||||
fi
|
||||
|
||||
printf "\n"
|
||||
for repo in "${dirty_repos[@]}"; do
|
||||
local repo_path="${base_dir}/${repo}"
|
||||
printf "Run 'gp -y' in ${RED}%s${NC}? [y/N/q] " "$repo"
|
||||
read -r answer </dev/tty
|
||||
case "$answer" in
|
||||
y|Y)
|
||||
(cd "$repo_path" && gp -y)
|
||||
;;
|
||||
q|Q)
|
||||
break
|
||||
;;
|
||||
*)
|
||||
continue
|
||||
;;
|
||||
esac
|
||||
done
|
||||
}
|
||||
|
||||
# === Main Function ===
|
||||
|
||||
scan_repositories() {
|
||||
@@ -449,6 +490,9 @@ main() {
|
||||
print_repos_needing_pull "$TEMP_FILE"
|
||||
print_dirty_repositories "$TEMP_FILE"
|
||||
print_clean_repositories "$TEMP_FILE"
|
||||
|
||||
# Offer to run gp -y in dirty repos
|
||||
offer_gp_dirty_repos "$TEMP_FILE" "$DIR"
|
||||
}
|
||||
|
||||
# === Autocomplete Function ===
|
||||
|
||||
Reference in New Issue
Block a user