Commit graph

72 commits

Author SHA1 Message Date
William Martin
a9dbda6913 Rework ref usage when finding and creating PRs 2025-04-15 13:38:10 -06:00
Andy Feller
644dbe6275
Apply suggestions from code review
Co-authored-by: Babak K. Shandiz <babak.k.shandiz@gmail.com>
2025-04-08 15:56:23 -04:00
Andy Feller
918cafc222 Deprecate ColorScheme.Gray for ColorScheme.Muted
This commit converts all of the places using ColorScheme.Gray and ColorScheme.Grayf to Muted and Mutedf.

There is a little extra tidying up with local variable names or converting code to use Mutedf format.
2025-04-06 10:18:48 -04:00
Azeem Sajid
c8a1f8c699
Update pkg/cmd/pr/status/status.go
Co-authored-by: Kynan Ware <47394200+BagToad@users.noreply.github.com>
2025-02-07 22:56:00 +05:00
Azeem Sajid
b2eec1cd5f Update language 2025-02-07 21:15:19 +05:00
Azeem Sajid
22bac00148 [gh pr status] Mention gh pr checks in the Long section 2025-02-07 21:13:17 +05:00
Tyler McGoffin
fa5325aec9 Add comment to status recognizing when we require a repo 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
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
d289ddd617 Use PushRemoteURL instead of RemoteURL in prSelectorForCurrentBranch 2025-01-15 16:21:06 -08:00
Tyler McGoffin
4a9fd9508f Add comments and a bit of code cleanup 2025-01-15 16:13:03 -08:00
Tyler McGoffin
018438088e Add missing git stubs to tests 2025-01-14 16:02:41 -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
74cbd50d3f Restore old error functionality of prSelectorForCurrentBranch
Before this refactor, the errors emitted by ghrepo.FromURL and
rem.FindName() were suppressed. It isn't clear whether this was
intentional or not, but we've made the decision here to maintain the
original error behavior while still refactoring the return values for more
clarity. I've left a comment at each error handling block to explain this
decision.

Additionally, I've added the necessary git command stubs to the other
tests in status_test.go so that the tests are now passing.
2025-01-10 10:52:01 -08:00
Tyler McGoffin
3d2748789e Rename test user in tests 2025-01-09 12:58:31 -08:00
Tyler McGoffin
100f9b473f Change pr number in test 2025-01-09 12:57:23 -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
d4f7576e8b Add test for empty BranchConfig in prSelectorForCurrentBranch 2025-01-09 09:01:14 -08:00
Tyler McGoffin
15ac566222 Remove shadowed errors from prSelectorForCurrentBranch and cover with tests 2025-01-08 15:21:05 -08:00
Tyler McGoffin
94b2d4ec3b Added tests to cover prSelectorForCurrentBranch for confidence in refactor 2025-01-08 15:00:38 -08:00
Tyler McGoffin
ec9eaef048 Refactor prSelectorForCurrentBranch and tests
Replace the git config argument in prSelectorForCurrentBranch with
the branchConfig it was used to fetch. The tests needed to be refactored
accordingly to support this change to the prSelectorForCurrentBranch API.
In addition, I've moved the test to a table test format so I can expand
the test coverage in the next commit.
2025-01-08 14:34:49 -08:00
Tyler McGoffin
c83cf32cff Remove named return values from prSelectorForCurrentBranch 2025-01-07 13:54:43 -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
Tyler McGoffin
e1a39d8e2b Add ghe.com to tests describing ghec data residency 2024-10-15 12:24:41 -07:00
Tyler McGoffin
81591a09b8 Use go-gh/auth package for IsEnterprise, IsTenancy, and NormalizeHostname 2024-10-15 11:56:43 -07:00
Tyler McGoffin
3a8417f6c7 Add test coverage to places where IsEnterprise incorrectly covers Tenancy
IsEnterprise currently returns `true` when `IsTenancy` returns true. We
prefer that this behavior is orthogonal. This commit adds failing tests to
the instances where IsEnterprise should not behave the same as IsTenancy.

These test cases are expected to pass with the inclusion of the coming
improvements to go-gh to handle the orthogonality of IsEnterprise and
IsTenancy.
2024-10-15 11:56:43 -07:00
Yukai Chou
d7b8ecf33d Unify use of tab indent in non-test source files
Found with
    rg '(^ | \t|\t )' -g '*.go' -g '!*_test.go'

Mixed indent exceptions:
- wrapped long list items with extra 2-space indent
- code snippets using space indent
- commented code lines having "\t*// \t+" prefix
2024-08-03 00:35:30 +08:00
Babak K. Shandiz
28c72eb5b7
Replace literals with consts for Mergeable field values
Signed-off-by: Babak K. Shandiz <babak.k.shandiz@gmail.com>
2024-07-16 15:29:11 +01:00
William Martin
1d38230675
Move config interfaces into gh package (#9060) 2024-05-10 10:39:36 +02:00
William Martin
5007c18f5f Fix unused params across project 2024-05-07 17:50:43 +02:00
William Martin
2717dc5758 Add cmd test for pr status with counts by state 2023-05-24 16:00:34 +02:00
William Martin
b73ad06f15 Avoid setting status check rollups when user supplies fields 2023-05-23 16:53:16 +02:00
William Martin
c90b87bdad Remove unused prInstrospection fixture 2023-05-22 18:46:28 +02:00
William Martin
42b61ad53e Inject fake detector into PR status tests 2023-05-22 18:44:51 +02:00
William Martin
cdd05a38c6 Move CheckRunAndStatusContextCounts feature detection up stack 2023-05-22 17:32:52 +02:00
William Martin
75e35e2dde Use pseudo field for statusCheckRollupWithCountByState 2023-05-22 17:28:15 +02:00
William Martin
ebb7d26f3a Implement initial spike for detecting and using counts by state 2023-05-17 19:59:03 +02:00
Martijn Pieters
83aaa76141
Include auto-merge information in gh pr status (#7386)
PRs that have auto-merge enabled are marked with a green "✓ Auto-merge enabled" label.
2023-05-10 08:32:05 +12:00
Tommy Petty
6d09500936 Fixes #455 - Hide "current branch" for pr status --repo 2023-03-15 16:52:14 -04:00
Sam Coe
4294ee14a1
revert revert 57fbe4f317 (#6474) 2022-10-20 12:17:20 +00:00
Sam Coe
2cefb9fa59
Fix pr create regression (#6472)
* Revert "Refactor to use new git client (#6447)"

This reverts commit 57fbe4f317.

* Fix pr create regression
2022-10-20 12:46:23 +03:00
Sam Coe
57fbe4f317
Refactor to use new git client (#6447) 2022-10-19 21:11:36 +03:00
Nate Smith
99e76a709f
Merge pull request #6292 from lpessoa/lp-checks
feat: adding checks at GH PR view
2022-10-06 14:27:38 -05:00
Ariel Deitcher
577d42280c
surface merge conflicts in pr status (#5999) 2022-10-03 09:32:48 +00:00
lpessoa
e8767b9706
feat: adding checks at GH PR view
Fixes #6117

Adding checks to PR view as a new line along with changes information.
Isolated 'status' display logic into a shared method in order to reuse it in 'view'.
Updated existing 'view' tests.

TODO: add new tests for PRs with checks.
2022-09-16 13:56:10 -03:00
Sam Coe
e7102f9d84
Migrate to go-gh text package (#6236) 2022-09-14 09:23:55 +04:00
Mislav Marohnić
04485144ea pr status: fix detecting PR for curent branch 2022-07-11 13:16:33 +02:00