Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gh pr create Add option to use first commit as PR title/description #7239

Closed
Tracked by #7575
billyvg opened this issue Mar 28, 2023 · 10 comments · Fixed by #7398
Closed
Tracked by #7575

gh pr create Add option to use first commit as PR title/description #7239

billyvg opened this issue Mar 28, 2023 · 10 comments · Fixed by #7398
Labels
enhancement a request to improve CLI help wanted Contributions welcome

Comments

@billyvg
Copy link

billyvg commented Mar 28, 2023

Describe the feature or problem you’d like to solve

gh pr create --fill has 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 using gh pr create --fill when 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.

@billyvg billyvg added the enhancement a request to improve CLI label Mar 28, 2023
@cliAutomation cliAutomation added the needs-triage needs to be reviewed label Mar 28, 2023
@vilmibm vilmibm added discuss Feature changes that require discussion primarily among the GitHub CLI team and removed needs-triage needs to be reviewed labels Mar 28, 2023
@vilmibm
Copy link
Contributor

vilmibm commented Mar 28, 2023

Since --fill is used from scripts, this would be a breaking change. marking for discussion in our next sync.

@billyvg
Copy link
Author

billyvg commented Mar 28, 2023

Since --fill is 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?

@mislav
Copy link
Contributor

mislav commented Apr 19, 2023

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:

if opts.Autofill || !opts.TitleProvided || !opts.BodyProvided {
err := initDefaultTitleBody(ctx, state)

@kousikmitra
Copy link
Contributor

If gh pr create --fill-first is finalized I can take this up.

Expectation:

  • --fill-first flag to be added
    - --fill and --fill-first both cant be used together
  • If --fill-first is 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 --fill behaviour)
    - 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.

@litzy29186

This comment was marked as spam.

@mislav
Copy link
Contributor

mislav commented Apr 23, 2023

@kousikmitra: that sounds almost correct, just a clarification: if --fill-first is 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.

@kousikmitra
Copy link
Contributor

Got it. Will raise a PR soon.

@natebrunette
Copy link

It would be nice if you could specific a commit and have it default to HEAD

@kousikmitra
Copy link
Contributor

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.

@natebrunette
Copy link

natebrunette commented May 31, 2023

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.

@williammartin williammartin added help wanted Contributions welcome and removed discuss Feature changes that require discussion primarily among the GitHub CLI team labels Jun 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement a request to improve CLI help wanted Contributions welcome
Projects
None yet
Development

Successfully merging a pull request may close this issue.

8 participants