Skip to content

Commit

Permalink
add versions func to output module commits
Browse files Browse the repository at this point in the history
  • Loading branch information
ggmarshall committed Jan 14, 2025
1 parent 0481750 commit 8f05dcb
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions src/legendmeta/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,32 @@ def checkout(self, git_ref: str) -> None:
self.__repo__.git.checkout(git_ref)
self.__repo__.git.submodule("update", "--init")

def _log_versions(self, modu, verbosity=0) -> None:
if modu.head.is_detached is False:
commit = modu.head.commit
msg = f'{next(modu.remote().urls).split("/")[-1]}'
msg += f'\nlocated at : {modu.working_dir}, \nlatest commit is: {commit.hexsha[:7]}, on: {commit.committed_datetime.strftime("%Y/%m/%d")}'
if verbosity >= 1:
msg += f"\n{commit.message}\n"
msg += "\n----------------\n"
log.info(msg)

else:
gitlog = modu.head.log()[0]
tstamp = datetime.fromtimestamp(gitlog.time[0])
msg = f'located at : {modu.working_dir}, \nlatest commit is: {gitlog.newhexsha[:7]}, on: {tstamp.strftime("%Y/%m/%d")}'
log.info(msg)

def versions(self, verbosity=0) -> None:
"""
Logs commit and time of the latest commit for the legend-metadata repository and all its submodules.
"""
self._log_versions(self.__repo__, verbosity)

for s in self.__repo__.submodules:
mod = s.module()
self._log_versions(mod, verbosity)

def channelmap(
self, on: str | datetime | None = None, system: str = "all"
) -> AttrsDict:
Expand Down

0 comments on commit 8f05dcb

Please sign in to comment.