Commit graph

201 commits

Author SHA1 Message Date
Tyler McGoffin
de9971d718
Merge pull request #9208 from Frederick888/find-pr-by-rev-parse-push
Find PRs using `@{push}`
2025-01-29 12:11:32 -08:00
Tyler McGoffin
e0f624ba24 Rename PRRefs to PullRequestRefs and PR comment cleanup 2025-01-29 11:56:31 -08:00
Tyler McGoffin
4382bdf072 Fix pr create tests
Due to the refactor of BranchConfig, the tests for `pr create` no longer
require a handful of stubbed git commands.

Additionally, I noticed some overlap between `pr create`'s existing logic
with the new finder code. I suspect that the finder's new ParsePRRefs
helper could be leveraged here as well, which would allow us to respect
non-centralized workflows pr create in the same way we are respecting them
in `gh pr view` and `gh pr status`
2025-01-24 14:01:44 -08:00
Otto Kekäläinen
b19e682455
Update test to be compatible with latest Glamour v0.8.0
Latest Glamour has slightly changed logic in line length / wrapping,
resulting test failures due to string mismatch. Update tests and bump
dependency to v0.8.0, and others to the bare minimal level as generated
by `go mod tidy`.

This was detected then building the GitHub cli package `gh` in Debian
started to fail with src:golang-github-charmbracelet-glamour 0.8.0-1.

Closes: #10179
2025-01-22 20:13:40 -08:00
Tyler McGoffin
48e2681017 Merge branch 'trunk' into find-pr-by-rev-parse-push
A recent refactor caused the API for ReadBranchConfig to change, resulting
in changes for its consumers. Additionally, there was a large refactor of
the tests associated with ReadBranchConfig and its consumers to gain
confidence in this refactor. This commit attempts to resolve the
conflicts between the refactor and this effort as well as massage the
changes introduced here to reflect the refactor.

The refactor PR can be found here: https://github.com/cli/cli/pull/10197

I'll note that there are still a few failing tests in status_test.go. I
haven't had a chance to fully grok while they are failing, yet, and
suspect that some insights from the original PR author may be helpful
here.

Full disclaimer: I haven't verified any of this is working locally yet.
My primary motivation is to get these new changes working together in a
manner that unblocks further iteration on this effort.

* trunk: (79 commits)
  Enhance help docs on ext upgrade notices
  chore: fix some function names in comment
  Expand docs on cleaning extension update dir
  Simplifying cleanExtensionUpdateDir logic
  Separate logic for checking updates
  Capture greater detail on updaterEnabled
  Restore old error functionality of prSelectorForCurrentBranch
  Change error handling on ReadBranchConfig to respect git Exit Codes
  fix: add back colon that I removed
  fix: actually read how MaxFunc work and simplify the code
  fix: padded display
  Collapse dryrun checks in ext bin upgrade
  Bump github.com/mattn/go-colorable from 0.1.13 to 0.1.14
  Rename test user in tests
  Change pr number in test
  Surface and handle error from ReadBranchConfig in parseCurrentBranch
  Directly stub headBranchConfig in Test_tryDetermineTrackingRef
  Refactor error handling in ReadBranchConfig to avoid panic
  Refine error handling of ReadBranchConfig
  Add test for empty BranchConfig in prSelectorForCurrentBranch
  ...
2025-01-13 20:38:00 -08:00
Tyler McGoffin
e4320ccc4b Directly stub headBranchConfig in Test_tryDetermineTrackingRef 2025-01-09 11:58:33 -08:00
Tyler McGoffin
e1423cdbbf Refine error handling of ReadBranchConfig
cmd.Output() will return an error when the git command ran successfully
but had no output. To handle this, we can check Stderr, as we expect it to
be populated for any ExitErrors or otherwise when there is a command
failure.

This allows for propagation of this error handling up the call chain, so
we are now returning errors if the call to git fails instead of just
handing off an empty BranchConfig and suppressing the errors.

Additionally, I've removed some more naked returns that I found in
pkg/cmd/pr/create.go createRun
2025-01-09 11:45:15 -08:00
Tyler McGoffin
fea46c0011 Change ReadBranchConfig error message in gh pr create 2025-01-08 11:40:42 -08:00
Tyler McGoffin
bf6fdbdfd2 Remove named returns from ReadBranchConfig and surface errors 2025-01-07 13:54:43 -08:00
Frederick Zhang
4254818dbd
Find push remote using branch.<name>.pushRemote and remote.pushDefault
When using a push.default = current triangular workflow, apart from
using @{push} to determine the remote branch name, we should also follow
the

1. branch.<name>.pushRemote
2. remote.pushDefault
3. branch.<name>.remote

...list to determine which remote Git pushes to.
2025-01-07 10:22:39 +11:00
Frederick Zhang
0179381efd
Find PRs using @{push}
When using a push.default = current central workflow [1], we should use
@{push} instead to locate the remote branch.

In fact, @{push} covers most cases in push.default = upstream too. The
branch.<name>.merge is probably only needed when using RemoteURL and
different remote / local branch names.

[1] https://github.com/tpope/vim-fugitive/issues/1172#issuecomment-522301607
2025-01-07 10:18:01 +11:00
William Martin
c3b41e87b8 Panic mustParseTrackingRef if format is incorrect 2025-01-06 10:33:28 -06:00
William Martin
8b5073d617 Move trackingRef into pr create package 2025-01-06 10:33:28 -06:00
William Martin
62ecb1c84d Make tryDetermineTrackingRef tests more respective of reality
Though it doesn't really matter, in practice upstream is always going to come before origin.
2025-01-06 10:33:28 -06:00
William Martin
57ba5e5608 Rework tryDetermineTrackingRef tests 2025-01-06 10:33:28 -06:00
William Martin
b8c167970b Avoid pointer return from determineTrackingBranch 2025-01-06 10:33:28 -06:00
William Martin
27bd4b2aec Doc determineTrackingBranch 2025-01-06 10:33:28 -06:00
William Martin
05764b8114 Don't use pointer for determineTrackingBranch branchConfig 2025-01-06 10:33:28 -06:00
William Martin
dc077dc09b Panic if tracking ref can't be reconstructed 2025-01-06 10:33:28 -06:00
William Martin
3ae4e5da20 Document and rework pr create tracking branch lookup 2025-01-06 10:33:28 -06:00
Caleb Brose
67749480d5
Fix test 2025-01-03 20:45:20 +00:00
Caleb Brose
9d490547b8
Alternative: remove LocalBranch from BranchConfig 2025-01-03 20:39:12 +00:00
Heath Stewart
78836097c3
Document how to set gh-merge-base
Follow-up to PR #9712
2024-12-20 10:49:38 -08:00
William Martin
54a7f4de70 Revert "Confirm auto-detected base branch"
This reverts commit e021a07285.
2024-12-09 13:01:00 +01:00
Heath Stewart
e021a07285
Confirm auto-detected base branch
If interactive, confirm the automatically configured gh-merge-branch or, if not configured, the default branch.

Based on PR feedback.
2024-12-08 22:27:00 -08:00
Heath Stewart
5da86e07e7
Merge changes from #10004
Merges changes from @williammartin including acceptance tests and word changes.

Co-authored-by: William Martin <williammartin@github.com>
2024-12-08 20:34:21 -08:00
Heath Stewart
3d139019f8
Open PR against gh-merge-base
Partly resolves issue #8979 by checking for a `gh-merge-base` branch tag and using that as though it were passed to `gh pr create --base`.
2024-12-08 17:40:00 -08:00
nilvng
874fa7ad4d feat: add test 2024-11-07 10:20:23 +11:00
nilvng
a780b488a3 fix: ignore template flag 2024-11-07 10:20:23 +11:00
Tyler McGoffin
da945314fd Fix failing test for pr and issue create 2024-10-08 16:11:05 -07:00
Tyler McGoffin
be3b6cbd8d Make the X in the error message red and print with io writer 2024-10-08 16:03:14 -07:00
Heath Stewart
81f3526740
Fix tests 2024-08-16 10:11:52 -07:00
Andy Feller
a863dfdb30
Merge pull request #9433 from benebsiny/cli-9310
Add `pr create --editor`
2024-08-12 10:10:18 -04:00
Andy Feller
369a105c45 Minor grammatical fix 2024-08-12 10:00:37 -04:00
Tyler McGoffin
18d58b8d84
Replace --project.* flags' name with title in docs (#9443)
With the upcoming migration from v1 project to v2 projects, we'd like the
language in our documentation to align with v2 project language. In v2,
projects are referred to by `title` and not `name`, though they are
functionally equivalent under the hood for the CLI
2024-08-09 13:55:14 -07:00
benebsiny
e18c002283 Deduplicate the initialization of editor mode 2024-08-08 18:07:52 +08:00
benebsiny
e2275d7ef6 Add pr create --editor 2024-08-07 23:14:15 +08:00
William Martin
32e499e090 Add examples for template usage in PR and issue creation 2024-07-23 13:14:27 +02:00
William Martin
07e0ff7127 Fix repo fork to use remote protocol if none configured 2024-05-10 10:48:36 +02:00
William Martin
1d38230675
Move config interfaces into gh package (#9060) 2024-05-10 10:39:36 +02:00
Victor Martinez
c0658b7ab4
feat: support dry-run in gh pr create (#8376) 2024-03-14 16:28:53 +01:00
William Martin
2ee6737053 Use regex to split apart the git client Commit logs
Theoretically this should be clearer and more robust than the previous
version which had some custom loop logic while trying to parse newlines
and determine whether it had reached a new commit entry by trying to parse
a git sha. This would not have worked correctly if a commit body contained
a sha on a new line.
2024-02-27 20:49:00 +01:00
William Martin
2b0484f5aa Use null byte separators when fetching comments from git 2024-02-27 18:00:40 +01:00
William Martin
658e7ac889 Ensure PRs with one commit have title and body prefilled 2024-02-16 16:30:44 +01:00
William Martin
14617e59e9 Update test to run against trunk 2024-02-16 16:30:00 +01:00
William Martin
237f6e3435 Test PR create uses commit title and body when only one commit 2024-02-16 16:19:02 +01:00
Zack Sloane
f70bcba779 switch to [] characters for default info in usage strings 2024-02-01 21:35:31 +00:00
Zack Sloane
15166f485a
Merge branch 'cli:trunk' into trunk 2024-02-01 16:27:12 -05:00
Federico Guerinoni
3409d068d4 Make commit title in bold 2024-02-01 09:12:06 +01:00
Federico Guerinoni
42613172bd pr: Add flag fillverbose
This is used to fill the body of PR with all commits msg + body
of every commits because there can be lot of useful information.

Signed-off-by: Federico Guerinoni <guerinoni.federico@gmail.com>
2024-02-01 09:12:04 +01:00