Skip to content

Allow to pass on a template file to gh in issue pr create. Add default to config. - #266

Merged
schpetbot merged 1 commit into
schpet:mainfrom
maparent:pr-template
Sep 1, 2026
Merged

Allow to pass on a template file to gh in issue pr create. Add default to config.#266
schpetbot merged 1 commit into
schpet:mainfrom
maparent:pr-template

Conversation

@maparent

Copy link
Copy Markdown
Contributor

Note: You can use -T "" to override config default.

@maparent maparent changed the title Allow to pass on a template file to gh in pr issue create. Add default to config. Allow to pass on a template file to gh in issue pr create. Add default to config. Aug 28, 2026
@schpetbot
schpetbot merged commit 10cfda8 into schpet:main Sep 1, 2026
11 checks passed
schpetbot pushed a commit that referenced this pull request Sep 1, 2026
#266 adds `-T/--template` and a `pr_template` config option, which are the right
surface -- the names and the precedence are kept exactly as the contributor
designed them. The mechanism cannot work, though, and I could not find a variant
of it that does.

The command already passes `--body <issue url>`, and #266 appends `--template`
next to it. `gh` refuses that pair outright:

    `--template` is not supported when using `--body` or `--body-file`

So every use of the new flag fails, and setting `pr_template` in config breaks
`issue pr` on every invocation rather than only when the flag is passed.

Dropping `--body` to make room for `--template` -- the obvious repair -- is
worse. `gh` only consults a template when it is running interactively; without a
body a non-TTY caller gets

    must provide `--title` and `--body` (or `--fill` ...) when not running interactively

and no pull request at all. That would trade a broken flag for a command broken
in CI, scripts, and agents. Handing `gh` a temporary file that already contains
the template fails the same way, because the problem is the missing `--body`,
not the file's contents.

So the template is read here and folded into the body we already send, with the
issue URL appended after it. The URL is what Linear matches on to attach the pull
request to its issue, so it has to survive; putting it last leaves the template's
prose as the first thing a reviewer reads. Every existing flag keeps working,
because the argv shape is unchanged.

Reading the file ourselves means we own its failures, and per CLAUDE.md an
explicitly requested template that cannot be used is an error rather than a
silent fallback to a URL-only body -- otherwise the user gets a pull request
quietly missing the content they asked for. Missing paths, directories,
non-regular files and unreadable files all produce a message naming the path.
NUL bytes are rejected too: `Deno.readTextFile` does not refuse binary input, it
substitutes U+FFFD and keeps the NULs, which `Deno.Command` then rejects with a
bare TypeError that never mentions the file.

One deliberate surface change: #266's description suggests `-T ""` to override a
configured default. That worked only because an empty string happened to be
falsy. It is now an explicit `--no-template` flag, and `-T ""` errors with a
suggestion pointing at it.

The generated skill docs under skills/ are left alone; they are produced from an
installed binary out of band and are already stale on trunk.
schpetbot pushed a commit that referenced this pull request Sep 1, 2026
#266 adds `-T/--template` and a `pr_template` config option, which are the right
surface -- the names and the precedence are kept exactly as the contributor
designed them. The mechanism cannot work, though, and I could not find a variant
of it that does.

The command already passes `--body <issue url>`, and #266 appends `--template`
next to it. `gh` refuses that pair outright:

    `--template` is not supported when using `--body` or `--body-file`

So every use of the new flag fails, and setting `pr_template` in config breaks
`issue pr` on every invocation rather than only when the flag is passed.

Dropping `--body` to make room for `--template` -- the obvious repair -- is
worse. `gh` only consults a template when it is running interactively; without a
body a non-TTY caller gets

    must provide `--title` and `--body` (or `--fill` ...) when not running interactively

and no pull request at all. That would trade a broken flag for a command broken
in CI, scripts, and agents. Handing `gh` a temporary file that already contains
the template fails the same way, because the problem is the missing `--body`,
not the file's contents.

So the template is read here and folded into the body we already send, with the
issue URL appended after it. The URL is what Linear matches on to attach the pull
request to its issue, so it has to survive; putting it last leaves the template's
prose as the first thing a reviewer reads. Every existing flag keeps working,
because the argv shape is unchanged.

Reading the file ourselves means we own its failures, and per CLAUDE.md an
explicitly requested template that cannot be used is an error rather than a
silent fallback to a URL-only body -- otherwise the user gets a pull request
quietly missing the content they asked for. Missing paths, directories,
non-regular files and unreadable files all produce a message naming the path.
NUL bytes are rejected too: `Deno.readTextFile` does not refuse binary input, it
substitutes U+FFFD and keeps the NULs, which `Deno.Command` then rejects with a
bare TypeError that never mentions the file.

One deliberate surface change: #266's description suggests `-T ""` to override a
configured default. That worked only because an empty string happened to be
falsy. It is now an explicit `--no-template` flag, and `-T ""` errors with a
suggestion pointing at it.

The generated skill docs under skills/ are left alone; they are produced from an
installed binary out of band and are already stale on trunk.
@schpetbot

Copy link
Copy Markdown
Collaborator

Shipped in v2.6.0.

Thanks for this — -T/--template and the pr_template config option shipped exactly as you designed them.

  • issue pr --template/-T <file> starts the pull request body from a template file.
  • pr_template (env: LINEAR_PR_TEMPLATE) sets a per-project default, and --no-template skips that default for one invocation.
  • The Linear issue URL is appended after the template, so the pull request stays linked to its issue.

#272 was a follow-up that fixed the mechanism so the template actually reaches GitHub — same flag letter, same config key, same precedence.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants