Skip to content

Commit

Permalink
feat: Add full Git commit metadata to generated YAML
Browse files Browse the repository at this point in the history
  • Loading branch information
Wuestengecko committed Oct 5, 2023
1 parent f8d50a5 commit 3efcbfc
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion model_diffsummary/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"""Main entry point into model_diffsummary."""
from __future__ import annotations

import datetime
import logging
import typing as t

Expand All @@ -11,6 +12,7 @@
import markupsafe
import yaml
from capellambse import model as m
from capellambse.filehandler import git as gitfh
from capellambse.model import common as c

import model_diffsummary
Expand Down Expand Up @@ -69,10 +71,21 @@ def _get_revision_info(
) -> types.RevisionInfo:
"""Return the revision info of the given model."""
info = model.info
fh = model._loader.resources["\x00"]
assert isinstance(fh, gitfh.GitFileHandler)
author, date_str, description = fh._git(
"log",
"-1",
"--format=%aN%x00%aI%x00%B",
info.rev_hash,
encoding="utf-8",
).split("\x00")
return {
"hash": info.rev_hash,
"revision": revision,
# TODO add author, date, description from commit
"author": author,
"date": datetime.datetime.fromisoformat(date_str),
"description": description.rstrip(),
}


Expand Down

0 comments on commit 3efcbfc

Please sign in to comment.