Repository navigation
gh pr create Add option to use first commit as PR title/description #7239
Description
Activity
- addeddiscussFeature changes that require discussion primarily among the GitHub CLI teamFeature changes that require discussion primarily among the GitHub CLI teamand removedneeds-triageneeds to be reviewedneeds to be reviewed
on Mar 28, 2023 Since
--fillis used from scripts, this would be a breaking change. marking for discussion in our next sync.Since
--fillis used from scripts, this would be a breaking change. marking for discussion in our next sync.What if the option accepted an arg, or if it were a new option, in order to avoid a breaking change?
We discussed this and we're open to
gh pr create --fill-first, a new flag. We definitely want to keep backwards compatibility with--fill, which was designed to emulate the web behavior of creating a PR.People who want to help us implement this can start here:
cli/pkg/cmd/pr/create/create.go
Lines 483 to 484 in 8460a70
if opts.Autofill || !opts.TitleProvided || !opts.BodyProvided { err := initDefaultTitleBody(ctx, state) If
gh pr create --fill-firstis finalized I can take this up.Expectation:
-
--fill-firstflag to be added
---filland--fill-firstboth cant be used together - If
--fill-firstis used then
- In case there's only one commit, title should be filled from commit message and body to be filled from commit description (same as current--fillbehaviour)
- In case there are multiple commits, First commit message should be used as title and all commit message should go in PR body
Please let me know if I am missing out anything.
-
@kousikmitra: that sounds almost correct, just a clarification: if
--fill-firstis used, there is no difference in behavior when a PR has 1 commit or more than 1 commit. In both cases, the subject of the first commit becomes PR title, and the description of the first commit becomes PR body.Got it. Will raise a PR soon.
It would be nice if you could specific a commit and have it default to HEAD
It would be nice if you could specific a commit and have it default to HEAD
It doesn't default to HEAD but the first commit of the difference
HEAD...{default branch}.
We can have an option to specify a commit to use but I personally don't see any reason to have that option.For example, I might do the main work first and then do some other refactoring work that I want to keep separate as additional work afterwards (spacing changes, rearranging lists, etc). I'd like to be able to specify the first commit I did for the
--fill. In different cases I might reverse the order.- addedhelp wantedContributions welcomeContributions welcomeand removeddiscussFeature changes that require discussion primarily among the GitHub CLI teamFeature changes that require discussion primarily among the GitHub CLI team
on Jun 19, 2023
Describe the feature or problem you’d like to solve
gh pr create --fillhas a good default if you only have a single commit: it creates a PR with the commit's details as title/description. However I generally write my first commit's message knowing that it will be used as the PR title/desc and will have follow-up commits that I expect will be squashed at some point. When usinggh pr create --fillwhen there are multiple commits, it uses the branch name as PR title and the list of git commit titles as the PR description.Proposed solution
Add a CLI option that will always fill the PR title/description using only the first commit's message. This won't disrupt the default and helps support a different and reasonable workflow.