Read the status line's branch through git_repo.git, and state the comprehension-floor rule as it holds
This commit is contained in:
+5
-6
@@ -4,9 +4,11 @@ import datetime
|
||||
import json
|
||||
import math
|
||||
import os
|
||||
import subprocess
|
||||
import sys
|
||||
|
||||
from failure import Failure
|
||||
import git_repo
|
||||
|
||||
CYAN = "\033[36m"
|
||||
DIM = "\033[2m"
|
||||
GREEN = "\033[32m"
|
||||
@@ -141,11 +143,8 @@ def render(status: Status, branch: str, home: str, now: datetime.datetime) -> st
|
||||
def current_branch(where: str) -> str:
|
||||
if not where:
|
||||
return ""
|
||||
try:
|
||||
found = subprocess.run(["git", "-C", where, "branch", "--show-current"], errors="replace", stderr=subprocess.DEVNULL, stdout=subprocess.PIPE, text=True)
|
||||
except OSError:
|
||||
return ""
|
||||
return found.stdout.strip() if found.returncode == 0 else ""
|
||||
found = git_repo.git("branch", "--show-current", cwd=where)
|
||||
return "" if isinstance(found, Failure) else found.strip()
|
||||
|
||||
|
||||
def main() -> str:
|
||||
|
||||
Reference in New Issue
Block a user