southwark.log

Python implementation of git log.

Classes:

Log([repo])

Python implementation of git log.

class Log(repo='.')[source]

Bases: object

Python implementation of git log.

Parameters

repo (Union[Repo, str, Path, PathLike]) – The git repository. Default '.'.

Attributes:

current_branch

The name of the current branch

local_branches

Mapping of local branches to the SHA of the latest commit in that branch.

refs

Mapping of git refs to commit SHAs.

remote_branches

Mapping of remote branches to the SHA of the latest commit in that branch.

repo

The git repository.

tags

Mapping of commit SHAs to tags.

Methods:

format_commit(commit)

Return a human-readable commit log entry.

log([max_entries, reverse, from_date, …])

Return the formatted commit log.

current_branch

Type:    str

The name of the current branch

format_commit(commit)[source]

Return a human-readable commit log entry.

Parameters

commit (Commit) – A Commit object

Return type

StringList

local_branches

Type:    Dict[str, str]

Mapping of local branches to the SHA of the latest commit in that branch.

log(max_entries=None, reverse=False, from_date=None, from_tag=None, colour=True)[source]

Return the formatted commit log.

Parameters
  • max_entries (Optional[int]) – Maximum number of entries to display. Default all entries.

  • reverse (bool) – Print entries in reverse order. Default False.

  • from_date (Optional[datetime]) – Show commits after the given date. Default None.

  • from_tag (Optional[str]) – Show commits after the given tag. Default None.

  • colour (bool) – Show coloured output. Default True.

Return type

str

refs

Type:    Dict[str, str]

Mapping of git refs to commit SHAs.

remote_branches

Type:    Dict[str, str]

Mapping of remote branches to the SHA of the latest commit in that branch.

repo

Type:    Repo

The git repository.

tags

Mapping of commit SHAs to tags.