Detail Package¶
detail¶
- class detail.Commit(data, tag_match=None)[source]¶
A commit object, parsed from a dictionary of formatted commit data. Allows one to easily see the tag.
- class detail.Note(data, *, path, schema, commit=None)[source]¶
A note object with an optional associated commit
- property is_valid¶
True
if the note was successfully validated against the schema. IfFalse
, some attributes in the schema may be missing.
- property validation_errors¶
Returns the schema
formaldict.Errors
that occurred during validation
- class detail.NoteRange(range='', tag_match=None, before=None, after=None, reverse=False)[source]¶
Represents a range of notes. The range can be filtered and grouped using all of the methods in
Notes
.When doing
git log
, the user can provide a range (e.g. “origin/develop..”). Any range used in “git log” can be used as a range to the NoteRange object.If the special
:github/pr
value is used as a range, the Github API is used to figure out the range based on a pull request opened from the current branch (if found).
- class detail.Notes(notes)[source]¶
A filterable and groupable collection of notes
When a list of Note objects is organized in this sequence, the “group”, “filter”, and “exclude” chainable methods can be used for various access patterns. These access patterns are typically used when writing log templates.
- group(attr, ascending_keys=False, descending_keys=False, none_key_first=False, none_key_last=False)[source]¶
Group notes by an attribute
- Parameters
attr (str) – The attribute to group by.
ascending_keys (bool, default=False) – Sort the keys in ascending order.
descending_keys (bool, default=False) – Sort the keys in descending order.
none_key_first (bool, default=False) – Make the “None” key be first.
none_key_last (bool, default=False) – Make the “None” key be last.
- Returns
A dictionary of
Notes
keyed on groups.- Return type
- class detail.Tag(tag)[source]¶
A git tag.
- property date¶
Parse the date of the tag
- Returns
The tag parsed as a datetime object.
- Return type
datetime
- detail.detail(path=None)[source]¶
Creates or updates a note
- Parameters
path (str, default=None) – A path to an existing note. If provided, the note will be updated.
- Returns
The result from running git commit. Returns the git pre-commit hook results if failing during hook execution.
- Return type
- detail.lint(range='')[source]¶
Lint notes against a range (branch, sha, etc).
Linting passes when either succeed:
No commits are in the range.
Commits are found, and all notes pass linting. At least one note must be in the commit range.
- Parameters
range (str, default='') – The git revision range against which linting happens. The special value of “:github/pr” can be used to lint against the remote branch of the pull request that is opened from the local branch. No range means linting will happen against all commits.
- Raises
NoGithubPullRequestFoundError – When using
:github/pr
as the range and no pull requests are found.MultipleGithubPullRequestsFoundError – When using
:github/pr
as the range and multiple pull requests are found.
- Returns
A tuple of the lint result (True/False) and the associated
NoteRange
- Return type
- detail.log(range='', style='default', template=None, tag_match=None, before=None, after=None, reverse=False, output=None)[source]¶
Renders notes.
- Parameters
range (str, default='') – The git revision range over which logs are output. Using “:github/pr” as the range will use the base branch of an open github pull request as the range. No range will result in all commits being logged.
style (str, default="default") – The template file nickname to use when rendering. Defaults to “default”, which means
.detail/log.tpl
will be used to render. When used, the.detail/log_{{style}}.tpl
file will be rendered.template (str, default=None) – A template string to use when rendering. Supercedes any style provided.
tag_match (str, default=None) – A glob(7) pattern for matching tags when associating a tag with a commit in the log. Passed through to
git describe --contains --matches
when finding a tag.before (str, default=None) – Only return commits before a specific date. Passed directly to
git log --before
.after (str, default=None) – Only return commits after a specific date. Passed directly to
git log --after
.reverse (bool, default=False) – Reverse ordering of results. Passed directly to
git log --reverse
.output (str|file) – Path or file-like object to which the template is written. Using the special “:github/pr” output path will post the log as a comment on the pull request.
- Raises
NoGithubPullRequestFoundError – When using
:github/pr
as the range and no pull requests are found.MultipleGithubPullRequestsFoundError – When using
:github/pr
as the range and multiple pull requests are found.
- Returns
The rendered log.
- Return type
detail.exceptions¶
- exception detail.exceptions.GithubConfigurationError[source]¶
When not correctly set up for Github access
- exception detail.exceptions.GithubPullRequestAPIError[source]¶
When an unexpected error happens with the Github pull request API
- exception detail.exceptions.MultipleGithubPullRequestsFoundError[source]¶
When multiple Github pull requests have been opened