adds git update checks
This commit is contained in:
@@ -132,7 +132,41 @@ def check_scripts() -> Dict[str, List[Tuple[bool, str|None]]]:
|
|||||||
}
|
}
|
||||||
return checks
|
return checks
|
||||||
|
|
||||||
|
def check_git_updates() -> Tuple[bool, str|None]:
|
||||||
|
try:
|
||||||
|
script_dir = Path(__file__).parent.parent
|
||||||
|
if not (script_dir / '.git').exists():
|
||||||
|
return (False, "Not a git repository")
|
||||||
|
original_dir = os.getcwd()
|
||||||
|
os.chdir(script_dir)
|
||||||
|
|
||||||
|
try:
|
||||||
|
# git fetch
|
||||||
|
subprocess.run(['git', 'fetch'], check=True, capture_output=True)
|
||||||
|
|
||||||
|
# git status
|
||||||
|
result = subprocess.run(['git', 'status'], check=True, capture_output=True, text=True)
|
||||||
|
|
||||||
|
if "Your branch is up to date" in result.stdout:
|
||||||
|
return (True, None)
|
||||||
|
else:
|
||||||
|
return (False, result.stdout)
|
||||||
|
finally:
|
||||||
|
os.chdir(original_dir)
|
||||||
|
except subprocess.CalledProcessError as e:
|
||||||
|
return (False, f"Git command failed: {e}")
|
||||||
|
except Exception as e:
|
||||||
|
return (False, f"Error checking git status: {e}")
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
|
# First check git status
|
||||||
|
git_status, git_message = check_git_updates()
|
||||||
|
status = CHECK if git_status else CROSS
|
||||||
|
print(f"{status} Repository status")
|
||||||
|
if git_message:
|
||||||
|
print(f"\t{status} {git_message}")
|
||||||
|
print() # Empty line for separation
|
||||||
|
|
||||||
results = check_scripts()
|
results = check_scripts()
|
||||||
|
|
||||||
for script, checks in results.items():
|
for script, checks in results.items():
|
||||||
|
|||||||
Reference in New Issue
Block a user