repomatic.github.issue module¶
GitHub issue lifecycle management.
Lists, creates, updates, closes and reopens the issues CI jobs maintain, used
by repomatic.broken_links and the setup guide. The writes that issues
share with pull requests (labels, locks) live in
threads.
The life-cycle of issues created in CI jobs is managed here by hand because the
create-issue-from-file action blindly creates issues ad-nauseam.
See: - https://github.com/peter-evans/create-issue-from-file/issues/298 - https://github.com/lycheeverse/lychee-action/issues/74#issuecomment-1587089689
- repomatic.github.issue.ISSUE_LIST_LIMIT = 100¶
Issues
list_issues()reads at most.gh issue liststops at 30 unless told otherwise. A title search matches a handful of issues, since a recurring condition reopens its one issue instead of filing a new one, so this bound is never reached in practice.
- class repomatic.github.issue.Triage(keep, keep_state, close)[source]¶
Bases:
NamedTupleWhat
triage_issues()decided for the issues sharing one title.Create new instance of Triage(keep, keep_state, close)
- repomatic.github.issue.list_issues(title='', *, repository=None)[source]¶
List all issues (open and closed), optionally filtered by title.
Note
No
--authorfilter is applied. WhenREPOMATIC_PATis configured,ghauthenticates as the token owner (notgithub-actions[bot]), so issues may be authored by either identity. Filtering by author would miss issues created under the other identity, breaking deduplication.
- repomatic.github.issue.close_issue(number, comment, *, repository=None)[source]¶
Close an issue with a comment.
- repomatic.github.issue.reopen_issue(number, comment='', *, repository=None)[source]¶
Reopen a previously closed issue.
A closed issue old enough to reopen is old enough to have been autolocked, so the write goes through
run_unlocking().
- repomatic.github.issue.create_issue(body_file, labels, title, *, repository=None, assignees=())[source]¶
Create a new issue.
- Parameters:
body_file (
Path) – Path to the file containing the issue body, already trimmed to GitHub’s size limit (seefit_github_body()).title (
str) – Issue title.repository (
str|None) – Repository inowner/nameform, orNoneto letghresolve it.
- Return type:
- Returns:
The created issue number.
- Raises:
RuntimeError – When the output carries no parsable issue URL.
- repomatic.github.issue.update_issue(number, body_file, *, repository=None)[source]¶
Update an existing issue body.
- repomatic.github.issue.triage_issues(issues, needed)[source]¶
Triage the issues sharing one title, for deduplication.
If needed, the most recent issue is kept (with its state) and every older open one is closed. If not, every open issue is closed. An issue already closed is never closed again.
- Parameters:
- Return type:
- Returns:
The issue to keep, its state, and the issues to close.
- repomatic.github.issue.manage_issue_lifecycle(has_issues, body, labels, title, no_issues_comment='No more issues.', *, repository=None, assignees=())[source]¶
Manage the full issue lifecycle: list, triage, close, create/update.
This function handles:
Listing all issues (open and closed) via
gh issue list.Triaging matching issues (keep newest if needed, close duplicates).
Closing duplicate open issues via
gh issue close.Creating, updating, or reopening the main issue via
gh issue create,gh issue edit, orgh issue reopen.
When
has_issuesisTrueand the most recent matching issue is closed, it is reopened and updated rather than creating a duplicate. A conversation lock standing in the way of that reopen is cleared first, so a recurring issue survives the autolock workflow that closes over it; seerun_unlocking().- Parameters:
has_issues (
bool) – Whether issues were found that warrant an open issue.body (
str) – The rendered markdown issue body. Written to a temporary file only when a create or update actually happens, since a run that just closes issues never needs one.labels (
Sequence[str]) – Labels to apply when creating a new issue.title (
str) – Issue title to match and create.no_issues_comment (
str) – Comment to add when closing issues because the condition no longer applies.repository (
str|None) – Repository inowner/nameform, orNoneto letghresolve it.assignees (
Sequence[str]) – Logins to assign a newly created issue to. An issue that already exists keeps its assignees.
- Return type:
- Returns:
The number of the issue created, updated or reopened, or
Nonewhen has_issues is false.
