- Writing custom git flow scripts - a start
This commit is contained in:
30
scripts/git/commands/status.py
Normal file
30
scripts/git/commands/status.py
Normal file
@@ -0,0 +1,30 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from ..core import config, git_api, output
|
||||
|
||||
|
||||
def handle_status(args) -> int: # noqa: ARG001 - argparse API
|
||||
"""Toon huidige branch en eenvoudige status-info."""
|
||||
|
||||
try:
|
||||
branch = git_api.get_current_branch()
|
||||
except git_api.GitError as exc:
|
||||
output.error(str(exc))
|
||||
return 1
|
||||
|
||||
clean = git_api.is_clean_working_tree()
|
||||
|
||||
output.heading("Repo status")
|
||||
output.plain(f"Huidige branch : {branch}")
|
||||
output.plain(f"Working tree : {'clean' if clean else 'NIET clean'}")
|
||||
|
||||
# Optionele remote-checks
|
||||
cfg = config.CONFIG
|
||||
for important_branch in {cfg.main_branch, cfg.develop_branch, branch}:
|
||||
try:
|
||||
git_api.ensure_not_behind_remote(important_branch, cfg.remote_name)
|
||||
except git_api.GitError as exc:
|
||||
output.warning(str(exc))
|
||||
|
||||
return 0
|
||||
|
||||
Reference in New Issue
Block a user