Added logic to change version only for projects with changes

This commit is contained in:
2022-05-26 16:25:15 +02:00
parent ddff9dec11
commit def92c78c8
13 changed files with 34 additions and 26 deletions

View File

@@ -1,4 +1,4 @@
import os
from git import Repo, DiffIndex
from cpl_core.environment import ApplicationEnvironmentABC
@@ -7,12 +7,11 @@ class GitService:
def __init__(self, env: ApplicationEnvironmentABC):
self._env = env
self._repo = Repo(env.working_directory)
def get_active_branch_name(self) -> str:
head_dir = os.path.join(self._env.working_directory, '.git/HEAD')
with open(head_dir, 'r') as f:
content = f.read().splitlines()
branch = self._repo.active_branch
return branch.name
for line in content:
if line[0:4] == "ref:":
return line.partition("refs/heads/")[2]
def get_diff_files(self) -> list[str]:
return [item.a_path for item in self._repo.index.diff(None)]