ge.batch¶
File a batch of related issues: dependency order, cross-references, blocked_by edges.
A batch is a list of records, each with a key local to the batch:
[
{"key": "A", "title": "Parser", "body": "First piece."},
{"key": "B", "title": "Printer", "body": "Uses the parser of {#A}.",
"labels": ["enhancement"], "depends_on": ["A", "#12"]}
]
file_issues() validates the whole batch before filing anything (field
types, unique keys, known references, no dependency cycle), then:
creates the issues in dependency order, replacing each
{#KEY}in a body with the#numberthat issue became (write{{#x}}for a literal{#x});updates every body whose final text differs from what was last sent: the ones that referred to a key filed later, and any record edited since. A body someone has edited on GitHub since is never overwritten: it is listed in
body_conflictsinstead (force=Trueoverwrites);creates a GitHub
blocked_bydependency edge for everydepends_onthat the blocked issue does not already have. GitHub only accepts issues as blockers: adepends_onthat names a pull request is skipped and reported inpr_dependencies(it is not an error).
depends_on takes batch keys and existing issues (12, "#12",
"owner/repo#12"). Progress is written to a map file after every step, so
an interrupted run is resumed by running it again. Each body carries a hidden
marker for its record (its key and the batch name), so an issue created just
before a crash (or after a lost map) is found among the repository’s recent
issues and adopted, not filed twice.
The map’s shape is stable, for writing the links back into a source document:
{"repo": "owner/repo",
"issues": {"A": {"number": 7, "url": "...", "id": 123, "body_sha": "..."}},
"edges": [{"blocked": "B", "blocker": "A"}],
"edge_errors": [{"blocked": "B", "blocker": "#12", "error": "..."}],
"pr_dependencies": [{"blocked": "B", "blocker": "#13", "url": "..."}],
"body_conflicts": ["C"]}
The batch knows nothing about any document format: produce the records however you like.
Module Attributes
|
|
|
|
Seconds after each write to GitHub; it throttles bursts of content creation. |
|
Pages of 100 of the repository's most recent issues searched for an unrecorded one. |
Functions
|
File records as issues in repo ( |
|
Records from a |
|
Hidden line identifying the record an issue was filed from. |
|
Replace |
|
Check a batch and return its keys in filing order; raise ValueError on any problem. |
- ge.batch.ADOPT_PAGES = 3¶
Pages of 100 of the repository’s most recent issues searched for an unrecorded one.
- ge.batch.DEFAULT_PAUSE = 1.0¶
Seconds after each write to GitHub; it throttles bursts of content creation.
- ge.batch.EXISTING_ISSUE = re.compile('^(?:(?P<repo>[\\w.-]+/[\\w.-]+))?#?(?P<number>\\d+)$')¶
12,#12,owner/repo#12.- Type:
An existing issue named in
depends_on
- ge.batch.REF_PATTERN = re.compile('(?<!\\{)\\{#([^{}\\s]+)\\}(?!\\})')¶
{#KEY}in a body becomes#numberonce KEY is filed;{{#KEY}}stays literal.
- ge.batch.file_issues(records, repo, *, map_path=None, batch=None, force=False, api=None, pause=1.0, adopt_pages=3, sleep=<built-in function sleep>, log=<built-in function print>)[source]¶
File records as issues in repo (
owner/nameor URL); return the map (see module doc).api defaults to
ge.util.gh_api(); pass a fake to test.- Return type:
- ge.batch.load_records(path)[source]¶
Records from a
.jsonfile (a list), or.yaml/.ymlwhen PyYAML is installed.
- ge.batch.marker(record, batch=None)[source]¶
Hidden line identifying the record an issue was filed from.
It hashes the key and the batch name, so two batches using the same keys in one repository never adopt each other’s issues; without a batch name the title stands in for it.
- Return type: