FIX: branchExists function and minor improvements

This commit is contained in:
Jean-Claude 2022-11-04 18:51:58 +01:00
parent c0079e7adb
commit c9d77ca119
Signed by: jeanclaude
GPG Key ID: 8A300F57CBB9F63E
2 changed files with 7 additions and 6 deletions

View File

@ -17,6 +17,7 @@ _log = logging.getLogger(__name__)
def main() -> int:
args = doSetup(sys.argv[1:])
_log.debug("Running main program")
match args.command:
case Subparser.Import:
_log.debug("Start import handler")
@ -85,7 +86,7 @@ def verifyRepository() -> None:
mainBranch = api.settings.getValue(api.settings.General.mainBranch)
if not api.repository.repo.branchExists(mainBranch):
# TODO: create main branch
raise NotImplementedError()
raise NotImplementedError("Create main branch")
# Check if initialCommit exists
commit = api.settings.getValue(api.settings.General.initialCommit)
@ -106,7 +107,7 @@ if __name__ == "__main__":
_log.exception("Mia terminated with a general error")
case customTypes.Exit.errConfig:
_log.warn(
_log.warning(
"There is an issue with your config. Running mia is not possible."
)

View File

@ -45,17 +45,17 @@ class Repository:
def __init__(self, repoPath: Path) -> None:
if not repoPath.is_dir():
# TODO: create dir if not existing
raise NotImplementedError()
raise NotImplementedError("Create repo dir")
try:
self._repo = Repo(repoPath)
except git.InvalidGitRepositoryError:
# TODO: init repo
raise NotImplementedError()
raise NotImplementedError("Init git repo")
if not repoPath / ".git/annex":
# TODO: git-annex init
raise NotImplementedError()
raise NotImplementedError("Annex verify")
def branchExists(self, branch: str) -> bool:
"""Verifies the existence of a branch.
@ -66,7 +66,7 @@ class Repository:
Returns:
True iff branch `branch` exists.
"""
return branch in [b for b in self._repo.branches]
return branch in [b.name for b in self._repo.branches]
def treeIshExists(self, treeIsh: str) -> bool:
"""Verifies the existence of a treeish.