Coverage for foran/status.py: 100.00%
15 statements
« prev ^ index » next coverage.py v7.0.1, created at 2023-01-02 19:51 +0100
« prev ^ index » next coverage.py v7.0.1, created at 2023-01-02 19:51 +0100
1"""In front or behind (Foran eller bagved)? status structure."""
2import datetime as dti
4from git.repo import Repo
6STATUS_DTI_FORMAT = '%Y-%m-%d %H:%M:%S UTC'
9class Status:
10 """Status structure."""
12 def __init__(self, repo: Repo, timestamp_format: str = STATUS_DTI_FORMAT):
13 """Seed the status structure with the git status info and some defaults."""
14 self._repo = repo
15 branch_is_up_to_date = 'Your branch is up to date' in self._repo.git.status()
16 self.when = dti.datetime.now(dti.timezone.utc).strftime(timestamp_format)
17 self.branch = self._repo.active_branch.name
18 self.foran = branch_is_up_to_date
19 self.foran_disp = 'UP TO DATE' if branch_is_up_to_date else 'CUSTOM'
20 self.commit = self._repo.head.commit
21 self.local_commits: list[str] = []
22 self.local_staged: list[str] = []
23 self.local_files: list[str] = []