Commit graph

56 commits

Author SHA1 Message Date
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
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
Sam Coe
539b150833
Extract feature detection package (#5494) 2022-05-17 19:07:44 +00:00
Håvard Anda Estensen
58cb773e09
Replace ioutil with io and os (#5498) 2022-04-26 13:07:44 +02:00
Sam Coe
8a0c1f903c
Change issue close color from red to purple (#5436) 2022-04-11 11:50:55 +02:00
Des Preston
2e07d0f32c
pr status: show number of approvals (#4240)
If the base branch has no minimum approval requirements, show "N Approved"
reviews. Otherwise, show "N/X Approved".

Co-authored-by: Mislav Marohnić <mislav@github.com>
2022-01-21 15:58:15 +00:00
Mislav Marohnić
11fbb60ae7 Rename the module to "github.com/cli/cli/v2" 2021-08-25 12:41:30 +02:00
Heath Stewart
e2973453b5
Add helper template functions for rendering tables (#3519)
Co-authored-by: Mislav Marohnić <mislav@github.com>
2021-08-23 21:00:25 +02:00
Mislav Marohnić
0208620a6f Remove unnecessary commits stubs from fixtures 2021-05-21 17:37:21 +02:00
Mislav Marohnić
e758f30073 Fix preloading of pr reviews, checks, and issue/pr comments 2021-05-18 17:13:27 +02:00
Mislav Marohnić
5f0301c990 Have Exporter.Write automatically call ExportData on given data structure 2021-05-12 17:05:15 +02:00
Mislav Marohnić
3ad41e3e65 Change JSON Exporter to an interface 2021-04-14 18:15:52 +02:00
Mislav Marohnić
3f22e3b353 Add pr status --json support 2021-04-13 21:12:30 +02:00
Mislav Marohnić
e158fac1a9 Restructure PullRequestStatus function 2021-04-13 20:54:09 +02:00
Nate Smith
126b498e9f
Actions Support Phase 1 (#2923)
* Implement first round of support for GitHub Actions

This commit adds:

gh actions
gh run list
gh run view
gh job view

as part of our first round of actions support. These commands are
unlisted and considered in beta.

* review feedback

* tests for exit status on job view

* spinner tracks io itself

* review feedback

* fix PR matching

* enable pager for job log viewing

* add more colorf functions

* add AnnotationSymbol

* hide job, run

* do not add method to api.Client

* remove useless cargo coded copypasta
2021-03-16 13:59:34 -07:00
Mislav Marohnić
05421db404 pr status: fix checking branch protection rules on the base branch
Instead of checking branch protection rules on the main branch of the
repository, branch protection rules for a specific PR should be checked
on its base branch, since not all PRs are based on the main branch.

Additionally, do not display "Up to date" if the actual merge status
reported from the server was "UNKNOWN" or "DIRTY", since in those cases
"Up to date" could be false information.
2021-02-17 18:04:49 +01:00
Michael Neeley
9be9229a48 adds strict status checks 2021-02-12 08:51:47 -05:00
Michael Neeley
0d55f8648c adds merge state status 2021-02-11 16:27:23 -05:00