Coverage for foran/status.py: 100.00%

15 statements  

« prev     ^ index     » next       coverage.py v7.4.1, created at 2024-02-04 18:05:08 +00:00

1"""In front or behind (Foran eller bagved)? status structure.""" 

2 

3import datetime as dti 

4 

5from git.repo import Repo 

6 

7STATUS_DTI_FORMAT = '%Y-%m-%d %H:%M:%S UTC' 

8 

9 

10class Status: 

11 """Status structure.""" 

12 

13 def __init__(self, repo: Repo, timestamp_format: str = STATUS_DTI_FORMAT): 

14 """Seed the status structure with the git status info and some defaults.""" 

15 self._repo = repo 

16 branch_is_up_to_date = 'Your branch is up to date' in self._repo.git.status() 

17 self.when = dti.datetime.now(dti.timezone.utc).strftime(timestamp_format) 

18 self.branch = self._repo.active_branch.name 

19 self.foran = branch_is_up_to_date 

20 self.foran_disp = 'UP TO DATE' if branch_is_up_to_date else 'CUSTOM' 

21 self.commit = self._repo.head.commit 

22 self.local_commits: list[str] = [] 

23 self.local_staged: list[str] = [] 

24 self.local_files: list[str] = []