2022-12-03 23:42:23 +01:00
|
|
|
import os
|
2022-05-25 16:43:28 +02:00
|
|
|
|
|
|
|
from cpl_core.environment import ApplicationEnvironmentABC
|
2022-12-03 23:42:23 +01:00
|
|
|
from git import Repo
|
2022-05-25 16:43:28 +02:00
|
|
|
|
|
|
|
|
|
|
|
class GitService:
|
|
|
|
def __init__(self, env: ApplicationEnvironmentABC):
|
|
|
|
self._env = env
|
2022-05-26 16:25:15 +02:00
|
|
|
self._repo = Repo(env.working_directory)
|
2022-05-25 16:43:28 +02:00
|
|
|
|
|
|
|
def get_active_branch_name(self) -> str:
|
2022-05-26 16:25:15 +02:00
|
|
|
branch = self._repo.active_branch
|
|
|
|
return branch.name
|
2022-05-25 16:43:28 +02:00
|
|
|
|
2022-05-26 16:25:15 +02:00
|
|
|
def get_diff_files(self) -> list[str]:
|
|
|
|
return [item.a_path for item in self._repo.index.diff(None)]
|