Commit graph

501 commits

Author SHA1 Message Date
Mislav Marohnić
619333adb6 Avoid using error values to pass information about the search cap 2021-09-06 16:09:18 +02:00
Des Preston
e8b015b80d show warning when limit exceeds search api max
Fixes #3839
2021-09-06 16:05:11 +02:00
Mislav Marohnić
11fbb60ae7 Rename the module to "github.com/cli/cli/v2" 2021-08-25 12:41:30 +02:00
Mislav Marohnić
3e23dcab15 Fix HTTP 502 error reporting from GraphQL request
Now it makes sure that the message portion will be printed to stderr
when the user encounters the error.
2021-08-18 22:17:32 +02:00
Mislav Marohnić
90b7886142 Fix unmarshalling GraphQL error type
The "path" field of a GraphQL error object contains a mix of strings and
numbers and cannot be deserialized into `[]string`. Fortunately, we
don't need to rely on the "path" field and instead have the final error
message be constructed by aggregating human-readable "message" fields.
2021-08-04 15:34:53 +02:00
Sam Coe
e5b099b1dd
Fix bug where branchProtectionRule doesn't exist in enterprise 2.22 2021-06-30 09:47:30 -07:00
Gowtham Munukutla
a44a3c8fd0 remove redundant logs 2021-06-17 10:41:24 +05:30
Gowtham Munukutla
9b05254285 gofmt 2021-06-17 10:28:24 +05:30
Gowtham Munukutla
acaaeb5567 remove unnecessary assignment of id 2021-06-17 10:27:40 +05:30
Gowtham Munukutla
26105dec29 fix lint 2021-06-17 10:25:54 +05:30
Gowtham Munukutla
137053399e tweak tests and add extra validations 2021-06-17 10:17:26 +05:30
Gowtham Munukutla
3c8e163e8b resolve PR comments. Tests WIP 2021-06-16 12:50:05 +05:30
Gowtham Munukutla
7c8b6867f4 Merge branch 'trunk' of https://github.com/cli/cli into feature/repo-with-gitignore-license 2021-06-16 09:27:53 +05:30
Mislav Marohnić
a4d1ce7709 Fix fetching information about the PR potentially being behind base branch 2021-06-10 15:51:27 +02:00
Mislav Marohnić
885e94786a Shorten GraphQL query for pr status --json 2021-06-10 15:37:58 +02:00
Mislav Marohnić
f5cd33b4bf Fix showing Checks in pr status
This was a regression in how `statusCheckRollup` is queried and stored.
As a result, `gh pr status` did not include rendered information about
checks related to each pull request. This switches the query builder to
`PullRequestGraphQL()` to eliminate the outdated query.
2021-06-08 20:22:33 +02:00
Gowtham Munukutla
c4beed8276 complete tests 2021-05-30 13:42:39 +05:30
Gowtham Munukutla
9b87b13b80 add test cases WIP 2021-05-29 19:27:30 +05:30
Mislav Marohnić
1a980e768c Fix how teams are displayed in requested reviewers
1. The `--json` export now only renders the `login` field for User types
   and `name` and `slug` fields for Team types.
2. The `pr view` command now renders team reviewers in the format of
   `ORG/SLUG` instead of the team name. This is so that the same value
    can be used in the `pr create -r` flag.
2021-05-28 14:32:31 +02:00
Sam Coe
761fa94831
Small nitpicky polish 2021-05-27 08:47:41 -04:00
mercimat
a612f06dee fix pr review requests for teams 2021-05-24 17:00:25 +02:00
Mislav Marohnić
6bec7a956a Fix pr merge on GHE < 3.0
This avoids loading authorship information for git commits, since it
relies on a GraphQL API that wasn't available before GHE v3.0. The
authorship information wasn't necessary for the merge operation anyway;
just loading the last commit OID was.
2021-05-21 17:35:41 +02:00
Mislav Marohnić
1440fd81a1 Fix broken GraphQL queries due to editing Author struct 2021-05-18 18:35:34 +02:00
Mislav Marohnić
42155c7d2d Export more IDs in issue/pr JSON payload 2021-05-18 18:19:28 +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ć
51f7cbdfde 💅 cleanup and tests for PR finder 2021-05-18 09:59:05 +02:00
Mislav Marohnić
bc3bb97c43 Merge remote-tracking branch 'origin' into pr-lookup-refactor 2021-05-17 17:41:38 +02:00
Mislav Marohnić
4b0b422eb5
Add --json export functionality to repo commands (#3627) 2021-05-17 16:53:20 +02:00
Mislav Marohnić
301a35eedc
Merge pull request #3621 from cli/export-data
Push data serialization concern into Exporter
2021-05-17 13:43:00 +02:00
Mislav Marohnić
02a2ed2f73 Add repo view --json export functionality 2021-05-12 17:05:15 +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ć
3cbd5b4934
Add repo fork --org functionality (#3611)
Co-authored-by: Gowtham Munukutla <gowtham.m81197@gmail.com>
2021-05-10 17:09:03 +02:00
Mislav Marohnić
c50d390cf5 Fix tests 2021-05-07 22:09:58 +02:00
Mislav Marohnić
25d79c4e16
Merge pull request #3525 from cristiand391/improve-issue-status-detection
Improve issue status detection
2021-05-03 21:04:35 +02:00
Cristian Dominguez
796d2e24ef Bring back Closed field 2021-04-30 17:32:16 -03:00
Mislav Marohnić
9bdc63c4ca Eliminate API overfetching in pr commands
This completely rewrites the PR lookup mechanism so that the caller
must specify the GraphQL fields to query for each PR. Additionally, this
fixes some export problems with `pr view --json`.

Features:

- Each pr command now gets assigned a concept of a Finder. This makes it
  easier to stub the PR in tests without having to stub the underlying
  HTTP calls or git invocations.

- `pr view --web` is much faster since it only fetches the "url" field.

- `pr diff 123` now skips a whole API call where a whole PR was
  unnecessarily preloaded just to access its diff in a subsequent call.

- PullRequestGraphQL query builder is now used to construct queries.

- A bunch of individual commands are now freed of having to know about
  concepts such as BaseRepo, Branch, Config, or Remotes.
2021-04-30 20:34:36 +02:00
Mislav Marohnić
a8e025291f Fix exporting milestone for issues and PRs
There was a weird pointer bug which would cause a null milestone to
erase "milestone" fields for previous entries in the list.
2021-04-28 18:28:18 +02:00
Cristian Dominguez
6b49e21295 Improve issue status detection 2021-04-28 00:30:21 -03:00
Mislav Marohnić
47b7987772
Merge pull request #3402 from cristiand391/remove-unused-embedded-struct
Remove unused embedded struct
2021-04-20 18:48:19 +02:00
Nate Smith
d09896468d
Merge pull request #3351 from cristiand391/fix-pr-reopen
Fix detecting PR status when passing branch as arg
2021-04-20 11:41:16 -05:00
Mislav Marohnić
ac348b0dec Fix requesting REST sub-resources on GHE
GitHub REST resources typically return full URLs to fetch related
resources at. We used to parse those URLs to find just the path portion
and pass that in to the `REST()` function, which only accepted paths. By
doing so, we are essential de-constructing a URL just to re-assemble it
again. While re-assembling it for Enterprise, though, we would
accidentally inject an extra `api/v3/` prefix where one was not needed.

The solution is just to use raw URLs as reported by the REST API with
no modifications. This extends the `REST()` function to accept full URLs
in addition to just paths to resources.
2021-04-19 12:41:09 +02:00
Mislav Marohnić
78e48e2dfd Tests for GraphQL query builder and JSON exporter 2021-04-14 18:52:02 +02:00
Mislav Marohnić
e63904bacd Expose more fields for PR JSON export 2021-04-14 17:28:27 +02:00
Mislav Marohnić
a516ee6833 Add issue status --json support 2021-04-13 21:26:26 +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
Mislav Marohnić
abe452bb19 Add --json export flag for issues and pull requests
The `--json` flag accepts a list of GraphQL fields to query for and
output in JSON format. To get the list of available flags, run the
command with a blank value for `--json`. Additional `--jq` and
`--template` flags are available just like in `gh api`.
2021-04-13 20:29:31 +02:00
Mislav Marohnić
19ea49b5a9 Move issue list queries to under the issue/list package 2021-04-13 19:25:19 +02:00
Cristian Dominguez
b656b56061 Remove unused embedded struct 2021-04-12 12:40:00 -03:00
Cristian Dominguez
9c471fe7a5 Improve PR status detection 2021-04-08 00:23:22 -03:00