#!/usr/bin/env python3 """ Simple Git Status Command Alternative implementation that avoids Unicode issues """ import os import subprocess import sys import json from datetime import datetime def get_current_branch(): """Get current git branch""" try: result = subprocess.run( ["git", "branch", "--show-current"], cwd="K:\\Projects\\uniswap_auto_clp", capture_output=True, text=True, check=False ) return result.stdout.strip() if result.returncode == 0 else "unknown" except Exception: return "unknown" def get_backup_branches(): """Get list of backup branches""" try: result = subprocess.run( ["git", "branch", "-a"], cwd="K:\\Projects\\uniswap_auto_clp", capture_output=True, text=True, check=False ) if result.returncode == 0: branches = [] for line in result.stdout.strip().split('\n'): branch = line.strip().replace('* ', '').replace('remotes/origin/', '') if branch.startswith('backup-'): branches.append(branch) branches.sort(key=lambda x: x.replace('backup-', ''), reverse=True) return branches return [] except Exception: return [] def has_changes(): """Check if there are uncommitted changes""" try: result = subprocess.run( ["git", "status", "--porcelain"], cwd="K:\\Projects\\uniswap_auto_clp", capture_output=True, text=True, check=False ) return bool(result.stdout.strip()) if result.returncode == 0 else False except Exception: return False def get_changed_files(): """Count changed files""" try: result = subprocess.run( ["git", "status", "--porcelain"], cwd="K:\\Projects\\uniswap_auto_clp", capture_output=True, text=True, check=False ) if result.returncode == 0: files = [] for line in result.stdout.strip().split('\n'): if line.strip(): files.append(line.strip()) return len(files) return 0 except Exception: return 0 def get_remote_status(): """Check remote connection status""" try: result = subprocess.run( ["git", "remote", "get-url", "origin"], cwd="K:\\Projects\\uniswap_auto_clp", capture_output=True, text=True, check=False ) return result.returncode == 0 except Exception: return False def main(): """Execute git status command""" try: current_branch = get_current_branch() backup_branches = get_backup_branches() backup_count = len(backup_branches) has_uncommitted_changes = has_changes() changed_files = get_changed_files() remote_connected = get_remote_status() last_backup = backup_branches[-1] if backup_branches else None print("Git Agent Status") print("================") print(f"Current Branch: {current_branch}") print(f"Backup Count: {backup_count}") print(f"Has Changes: {has_uncommitted_changes}") print(f"Changed Files: {changed_files}") print(f"Remote Connected: {remote_connected}") if last_backup: print(f"Last Backup: {last_backup}") if backup_branches: print("\nRecent Backups:") for branch in backup_branches[-5:]: print(f" - {branch}") except Exception as e: print(f"Status check failed: {str(e)}") if __name__ == "__main__": main()