Commit graph

66 commits

Author SHA1 Message Date
William Martin
8ff70e6e7a Remove numberFieldOnly API shortcut
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-05-01 17:23:01 +02:00
Kynan Ware
9de48154de Add missing TODO comments for featuredetection if-statements
Add greppable TODO identifiers above all if-statements that reference
featuredetection struct fields, as required by the featuredetection
linter. This ensures every feature detection branch is tagged for
future cleanup when GHES gains support.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-02-16 14:24:32 -07:00
Babak K. Shandiz
0d8a697c7c
fix(pr/shared): improve ParseFullReference error message
Signed-off-by: Babak K. Shandiz <babakks@github.com>
2026-01-21 23:30:43 +00:00
Mikel Olasagasti Uranga
bd0177b039 Fix fmt.Errorf format argument in ParseFullReference
The error path passed an int to fmt.Errorf with %q, which expects a
string. Use the original reference string to avoid a format mismatch.

Signed-off-by: Mikel Olasagasti Uranga <mikel@olasagasti.info>
2026-01-21 23:14:59 +01:00
Babak K. Shandiz
6f698407fb
docs(pr/shared): add a TODO on decoupling PR finder from IO
Signed-off-by: Babak K. Shandiz <babakks@github.com>
2025-09-18 10:25:49 +01:00
Babak K. Shandiz
5b9d6ae3fc
fix(pr/shared): add DisableProgress field to FindOptions
Signed-off-by: Babak K. Shandiz <babakks@github.com>
2025-09-17 11:47:18 +01:00
Babak K. Shandiz
10e4abc515
refactor(pr/shared): rename rest to tail
Signed-off-by: Babak K. Shandiz <babakks@github.com>
2025-09-11 09:04:17 +01:00
Babak K. Shandiz
2311a04688
fix(pr/shared): ensure ParseURL regexp is backward-compatible
Signed-off-by: Babak K. Shandiz <babakks@github.com>
2025-09-10 19:07:52 +01:00
Babak K. Shandiz
78b09e55e5
fix(pr/shared): add rest return value to ParseURL
Signed-off-by: Babak K. Shandiz <babakks@github.com>
2025-09-10 18:57:57 +01:00
Babak K. Shandiz
fd11b1e8de
fix(pr/shared): add ParseFullReference func
Signed-off-by: Babak K. Shandiz <babakks@github.com>
2025-09-05 16:57:21 +01:00
Babak K. Shandiz
12f4794151
fix: remove assignee-related intervention
Signed-off-by: Babak K. Shandiz <babakks@github.com>
2025-07-01 11:12:16 +01:00
Babak K. Shandiz
23c9ff6d89
fix: expose ParseURL as a public func
Signed-off-by: Babak K. Shandiz <babakks@github.com>
2025-07-01 10:49:18 +01:00
William Martin
793a7ff459 Fix pr edit when URL is provided 2025-06-02 15:07:55 +02:00
Kynan Ware
7b86830ade
Merge pull request #10729 from nopcoder/trunk
Fix panic on `gh pr view 0`
2025-05-02 09:47:48 -06:00
William Martin
c5d8e6f8f5
Merge pull request #10821 from cli/wm/projectsv1-deprecation-pr-view
Feature detect v1 projects on pr view
2025-05-02 15:07:40 +02:00
William Martin
64370ce73e Cleanup run command stubbed finders in tests 2025-05-02 14:48:52 +02:00
William Martin
3bcf9758ad Feature detect v1 projects on pr view 2025-05-01 15:31:36 +02:00
Barak Amar
a491578751
Merge branch 'trunk' into trunk 2025-04-29 14:33:21 +03:00
Barak Amar
692bdaf578 Apply code review changes 2025-04-29 14:32:51 +03:00
Azeem Sajid
9ed733fa5e
Add closingIssuesReferences JSON field to pr view (#10544)
* [gh pr view] Support `closingIssuesReferences` JSON field

* Support pagination

* Support pagination

* Fix typo

* Add more fields
2025-04-29 11:48:20 +01:00
Barak Amar
265139f268
Merge branch 'trunk' into trunk 2025-04-17 09:56:12 -04:00
William Martin
a9dbda6913 Rework ref usage when finding and creating PRs 2025-04-15 13:38:10 -06:00
Kynan Ware
041f02c980 docs(pr create): standard <user>:<branch> syntax
Standardize <user>:<branch> syntax wherever it is described in comments.
2025-04-15 13:38:10 -06:00
Kynan Ware
e999976b3d refactor(pr create): add PullRequestRefs HasHead 2025-04-15 13:38:10 -06:00
Kynan Ware
b61b2298d2 doc: fix PullRequestRefs comment 2025-04-15 13:38:10 -06:00
Barak Amar
06d22d96c0 handle find pr number 0 2025-04-04 11:14:02 +03:00
Tyler McGoffin
877871f1e0 Address PR comments 2025-01-31 14:55:24 -08:00
Tyler McGoffin
601cf88852 Handle error from ParsePRRefs when the selector is provided 2025-01-31 14:40:54 -08:00
Tyler McGoffin
058cb2c220 Refactor finder to work with URL selectors 2025-01-31 14:40:54 -08:00
Tyler McGoffin
e0f624ba24 Rename PRRefs to PullRequestRefs and PR comment cleanup 2025-01-29 11:56:31 -08:00
Tyler McGoffin
e31bfd0092 Cleaned up some naming and comments 2025-01-27 16:40:47 -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
Tyler McGoffin
d684834ad9 Refactor pr status to use the ParsePRRefs helper on the Finder
There was a lot of copy-pasta code between the finder and pr status. After
some investigation it was clear that the prSelectorForCurrentBranch code
was really just a duplicate of the finder's code without actually making
the API call for the PR. Since the ParsePRRefs helper had already
extracted much of the logic for determining a PR's head ref branch, I was
able to reuse it in gh pr status with a small refactor.
2025-01-24 11:51:49 -08:00
Tyler McGoffin
cdead50d57 Moved remote.pushDefault out of ReadBranchConfig and into finder 2025-01-24 11:05:15 -08:00
Tyler McGoffin
e4d8ed0e60 Remove @{push} from branch config 2025-01-24 10:20:04 -08:00
Tyler McGoffin
5a8dd35ba7 Add PushDefault method to git client 2025-01-24 09:40:02 -08:00
William Martin
6355ed7c08 WIP: push default defaults to simple 2025-01-24 17:25:38 +01:00
William Martin
a72bef9b42 Error if push revision doesn't match a remote 2025-01-24 17:07:24 +01:00
Tyler McGoffin
41729b004d Refactor finder.Find and replace parseCurrentBranch with parsePRRefs
I've been struggling horribly to reason through all of this code, and
after much mental gymnastics I identified the culprit as the overloaded
"branch" string returned by parseCurrentBranch.

This value was either the name of the branch that the PR we're looking for
is associated with, or that name prepended with the owner's name and a :
if we're on a branch, so:

PR branch: featureBranch
branch == "featureBranch"

If on Fork belonging to "ForkOwner"
branch == "ForkOwner:featureBranch"

Since this extra information was bundled up into this single string, it
complicated the responsibilities of parseCurrentBranch's "branch" return
value. Thus, I've teased out "branch" into the new PRRefs struct:

type PRRefs struct{
	BranchName string
	HeadRepo ghrepo.Interface
	BaseRepo ghrepo.Interface
}

This allows the new parsePRRefs function to move all the previous
"branch" string's information into structured data, and allows for a new
method on PRRefs, GetPRLabel(), to create the string that "branch"
previously held to pass into its downstream consumer, namely
findForBranch.

This also allowed for better test coverage, directly connecting the PRRefs
fields to the values contained in the git config. Overall, I am now
confident that this is doing what its supposed to do with respect to my
understanding of the various central and triangular git workflows we are
addressing.
2025-01-23 15:25:28 -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
e4f0b79173 Surface and handle error from ReadBranchConfig in parseCurrentBranch
I've only added the one test for parseCurrentBranch because the function
appears to be largely exercised by TestFind. There's definitely an
opportunity for a bigger refactor of the tests, here, but I want to avoid
scope creep as I propagate the ReadBranchConfig api changes throughout the
codebase
2025-01-09 12:46:55 -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
7fc35fd47d
Only find PRs w/ branch.<name>.merge if push.default = upstream/tracking
When push.default is not 'upstream' / 'tracking' (or 'nothing'), we can
expect local and remote branch names to be the same and solely rely on
@{push} or RemoteURL.

This fixes the wrong error message 'no pull requests found for branch
"<target branch>"' when the local branch is not pushed in the
push.default = simple / current and upstream = <target branch> setup.
2025-01-07 10:18:07 +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
d662226ae4 Name conditionals in PR finder 2024-12-13 14:33:33 +01:00
William Martin
96ac8d6a2f Support pr view for intra-org forks 2024-12-13 14:27:41 +01:00
William Martin
ebb7d26f3a Implement initial spike for detecting and using counts by state 2023-05-17 19:59:03 +02:00
Ilya Yatsishin
179e9c256d
Add projectsV2 support to issue create, issue edit, pr create, and pr edit (#6735)
Co-authored-by: pshevche <pavel.shevchenko.95@gmail.com>
Co-authored-by: Sam Coe <samcoe@users.noreply.github.com>
2023-01-19 22:13:09 +00:00
vilmibm
f5d19b831e error instead of prompt when no base repo + fixes 2022-12-15 11:44:37 -08:00