Skip to content
Snippets Groups Projects
Commit 8a5e08e5 authored by AxelCarayon's avatar AxelCarayon
Browse files

ajout vérif si changements à l'initialisation

parent 6e420166
No related branches found
No related tags found
1 merge request!14Verifi changements
...@@ -33,6 +33,14 @@ def isGitRepo(path) -> bool: ...@@ -33,6 +33,14 @@ def isGitRepo(path) -> bool:
except git.exc.InvalidGitRepositoryError: except git.exc.InvalidGitRepositoryError:
return False return False
def checkForChanges() -> None:
changesNotAdded = [ item.a_path for item in repository.index.diff(None) ]
changesAdded = [ item.a_path for item in repository.index.diff(repository.head.name) ]
untrackedFiles = repository.untracked_files
if ((len(changesNotAdded) + len(changesAdded) + len(untrackedFiles)) > 0):
raise Exception("There are changes in the repository since the last commit, you can only register an experiment from a clean repository.")
def init(pathInput) -> None : def init(pathInput) -> None :
global repository,path,experimentName,tags, currentTag global repository,path,experimentName,tags, currentTag
if isGitRepo(pathInput): if isGitRepo(pathInput):
...@@ -44,6 +52,7 @@ def init(pathInput) -> None : ...@@ -44,6 +52,7 @@ def init(pathInput) -> None :
os.chdir(path) os.chdir(path)
else : else :
raise Exception(f"{pathInput} is not a git repository") raise Exception(f"{pathInput} is not a git repository")
checkForChanges()
tags = repository.tags tags = repository.tags
currentTag = repository.git.describe('--tags') currentTag = repository.git.describe('--tags')
if not(currentVersionIsTagged()): if not(currentVersionIsTagged()):
...@@ -174,6 +183,8 @@ def genChecksums() -> list[dict]: ...@@ -174,6 +183,8 @@ def genChecksums() -> list[dict]:
checksums.append({file : genChecksum(outputFolder+file)}) checksums.append({file : genChecksum(outputFolder+file)})
return checksums return checksums
def run(folder) -> None : def run(folder) -> None :
init(folder) init(folder)
repository.active_branch.checkout() repository.active_branch.checkout()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment