diff --git a/capella_diff_tools/__main__.py b/capella_diff_tools/__main__.py index c5ebfb7..1674b21 100644 --- a/capella_diff_tools/__main__.py +++ b/capella_diff_tools/__main__.py @@ -72,6 +72,7 @@ def main( "model": model, "old_revision": _get_revision_info(old_model, old_version), "new_revision": _get_revision_info(new_model, new_version), + "commit_log": _get_commit_log(new_model, old_version, new_version), } objects = compare.compare_all_objects(old_model, new_model) diagrams = compare.compare_all_diagrams(old_model, new_model) @@ -132,6 +133,36 @@ def _get_revision_info( } +def _get_commit_log( + model: capellambse.MelodyModel, + old_version: str, + new_version: str, +) -> list[types.RevisionInfo]: + res = model._loader.resources["\x00"] + assert isinstance(res, fh.git.GitFileHandler) + commits: list[types.RevisionInfo] = [] + rawlog = res._git( + "log", + "-z", + "--reverse", + "--format=format:%H%x00%aN%x00%aI%x00%B", + f"{old_version}..{new_version}", + encoding="utf-8", + ).split("\x00") + log = capellambse.helpers.ntuples(4, rawlog) + for hash, author, date_str, description in log: + commits.append( + { + "hash": hash, + "revision": hash, + "author": author, + "date": datetime.datetime.fromisoformat(date_str), + "description": description.rstrip(), + } + ) + return commits + + class CustomYAMLDumper(yaml.SafeDumper): """A custom YAML dumper that can serialize markupsafe.Markup.""" diff --git a/capella_diff_tools/report.html.jinja b/capella_diff_tools/report.html.jinja index e621356..90a8ca1 100644 --- a/capella_diff_tools/report.html.jinja +++ b/capella_diff_tools/report.html.jinja @@ -58,7 +58,7 @@ Repository: {{ data["metadata"]["model"]["path"] | e }}
Entry point: {{ data["metadata"]["model"]["entrypoint"] | e }}

-

The review of changes covers the following commits:

+

The review of changes covers the following range of commits:

@@ -84,9 +84,9 @@ - - - + + + @@ -96,6 +96,48 @@
{{ data["metadata"]["new_revision"]["date"] | e }}
Commit message{{ data["metadata"]["old_revision"]["description"] | e }}{{ data["metadata"]["new_revision"]["description"] | e }}Summary{{ data["metadata"]["old_revision"]["description"].split("\n") | first | e }}{{ data["metadata"]["new_revision"]["description"].split("\n") | first | e }}
Commit ID (hash)
+

Detailed information about the contained commits:

+ + + + {% for commit in data.metadata.commit_log -%} + + + + + + + {% else -%} + + + + + + + + + + + + + + + + {% endfor -%} + + + + + + + + + +
{{ commit.hash | e }}{{ commit.date | e }}{{ commit.author | e }}{{ commit.description | e }}
{{ data.metadata.old_revision.hash }}{{ data.metadata.old_revision.date }}{{ data.metadata.old_revision.author }}{{ data.metadata.old_revision.description }}
+ Error: The supplied report does not contain the commit log. + Detailed information is only available for the first and last commit. +
{{ data.metadata.new_revision.hash }}{{ data.metadata.new_revision.date }}{{ data.metadata.new_revision.author }}{{ data.metadata.new_revision.description }}
Commit ID (hash)Date & timeAuthorCommit message
+ {% macro pretty_stats(stats) %} ( {% if stats.created %}+{{stats["created"]}} / {% endif %} diff --git a/capella_diff_tools/types.py b/capella_diff_tools/types.py index 357736b..ee99667 100644 --- a/capella_diff_tools/types.py +++ b/capella_diff_tools/types.py @@ -20,6 +20,7 @@ class Metadata(te.TypedDict): """The 'modelinfo' used to load the models, sans the revision key.""" new_revision: RevisionInfo old_revision: RevisionInfo + commit_log: list[RevisionInfo] class RevisionInfo(te.TypedDict, total=False):