Skip to content

Commit

Permalink
fix: Don't try to treat files as git repos
Browse files Browse the repository at this point in the history
  • Loading branch information
Wuestengecko committed Jul 31, 2024
1 parent 197cf05 commit b6a8db5
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions capella_diff_tools/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

import datetime
import logging
import os
import pathlib
import sys
import typing as t
Expand Down Expand Up @@ -65,7 +64,7 @@ def main(
logging.basicConfig(level="DEBUG")
if "revision" in model:
del model["revision"]
model["path"] = _ensure_git(model["path"])
_ensure_git(model)
old_model = capellambse.MelodyModel(**model, revision=old_version)
new_model = capellambse.MelodyModel(**model, revision=new_version)

Expand All @@ -92,18 +91,19 @@ def main(
report_file.write(report.generate_html(result))


def _ensure_git(path: str | os.PathLike) -> str:
proto, path = fh.split_protocol(path)
def _ensure_git(model: dict[str, t.Any]) -> None:
proto, path = fh.split_protocol(model["path"])
if proto == "file":
assert isinstance(path, pathlib.Path)
path = "git+" + path.resolve().as_uri()

proto, _ = fh.split_protocol(path)
if proto != "git":
path = path.resolve()
if "entrypoint" not in model and path.is_file():
model["entrypoint"] = path.name
path = path.parent
model["path"] = "git+" + path.as_uri()
elif proto != "git":
raise click.Abort("The 'model' must point to a git repository")

assert isinstance(path, str)
return path
assert isinstance(model["path"], str)


def _get_revision_info(
Expand Down

0 comments on commit b6a8db5

Please sign in to comment.