Commit graph

338 commits

Author SHA1 Message Date
Nate Smith
734959c39d
Merge pull request #1603 from cli/create-pr-metadata-failure
Be transparent about which part of `pr create` flow failed
2020-09-01 10:51:55 -05:00
Mislav Marohnić
766e4950d9 Be transparent about which part of pr create flow failed
When applying metadata to the new PR such as assignees or reviewers, if
the operation fails, an error message would get printed:

    failed to create pull request: <API error text>

This was misleading, because the PR did get created; it's just that
updating it failed. The new error message is:

    https://github.com/OWNER/REPO/pull/123
    pull request update failed: <API error text>

The PR URL is printed on stdout and the error message is printed on
stderr. In case of any errors, the exit code is still non-zero.
2020-08-31 16:46:22 +02:00
Colin Shum
58f62a4a15 [Feature] Create repository from template
Co-authored-by: Mislav Marohnić <mislav@github.com>
2020-08-27 14:46:16 -04:00
vilmibm
2753f6fa48 Merge remote-tracking branch 'origin/trunk' into fix-milestone 2020-08-19 12:31:32 -05:00
Roy Ling
006426331c Fix gh pr diff with hostname override
Removed hardcoded url prefix in PR diff
2020-08-15 22:03:42 +08:00
vilmibm
6c64cb8d23 remove vestigial return from HasMinimumScopes 2020-08-11 16:33:13 -05:00
vilmibm
ec25b735ab gh auth status 2020-08-11 15:58:00 -05:00
Mislav Marohnić
e12c35cc17 Add ability to pass milestone by number 2020-08-11 19:27:26 +02:00
Mislav Marohnić
20ffa49d69 Merge remote-tracking branch 'origin' into fix-milestone 2020-08-11 19:01:58 +02:00
vilmibm
35f18b6c02 gh auth login 2020-08-06 12:43:35 -05:00
Francisco Miamoto
bbce1ba755 add check for milestone not found 2020-08-05 20:49:01 -03:00
Mislav Marohnić
a73584db72 Merge remote-tracking branch 'origin' into pr-commands-isolate 2020-08-04 15:01:30 +02:00
Francisco Miamoto
3caa7cc537 improve comments 2020-08-01 23:54:22 -03:00
Francisco Miamoto
9a5e69a8a4 use graphql for repo milestones on issue list
Since we can obtain the necessary ID for the query on
node ID from the GraphQL API, it makes sense to remove
the REST version.
2020-08-01 23:43:36 -03:00
Francisco Miamoto
75e8cb8f9c register mocks for the new request 2020-07-30 22:15:15 -03:00
Francisco Miamoto
3ce1de62a2 fix searching issues by the milestone name
This fix involves using the REST API since the GraphQL one doesn't
seem to return the necessary ID for the subsequent issues query.
2020-07-30 22:11:19 -03:00
Mislav Marohnić
487dd06bf3 Isolate pr checkout command 2020-07-29 22:50:34 +02:00
Mislav Marohnić
af68a749f0 Isolate pr diff command 2020-07-29 22:49:50 +02:00
Mislav Marohnić
c0b116b511 Merge remote-tracking branch 'origin' into ghe-api 2020-07-28 18:12:47 +02:00
Kumar Saurabh
78124a9716
API improvement : Drain response Body inside func HasScopes (#1428)
Ensure the response body is fully read and closed to reuse the same TCPconnection.

Co-authored-by: Kumar Saurabh <kumarsaurabh@Kumars-MacBook-Air.local>
2020-07-28 14:56:17 +02:00
Mislav Marohnić
dd0d236629 Merge remote-tracking branch 'origin' into ghe-api 2020-07-27 20:13:54 +02:00
Mislav Marohnić
c1c836a657 Remove hardcoded "github.com" 2020-07-27 16:31:05 +02:00
Mislav Marohnić
0cbcf8a7fa Merge remote-tracking branch 'origin' into ghe-api 2020-07-27 16:30:20 +02:00
vilmibm
551c3661cb linter appeasement 2020-07-24 12:29:06 -05:00
vilmibm
c34054bdc8 isolate repo create command 2020-07-24 12:26:27 -05:00
Mislav Marohnić
288d01318b Respect the hostname of current repository in queries 2020-07-23 22:31:08 +02:00
vilmibm
895af993a5 static not found error 2020-07-23 11:12:33 -05:00
vilmibm
a27c8a9c21 isolate repo view cmd 2020-07-22 15:54:11 -05:00
Mislav Marohnić
97350e87a1 Merge remote-tracking branch 'origin' into migrate-gist 2020-07-22 16:17:30 +02:00
Mislav Marohnić
e373195817 WIP migrate gist create to separate package 2020-07-21 18:13:16 +02:00
Mislav Marohnić
86eacc3789 Enable unwrapping api.NotFoundError 2020-07-21 13:59:05 +02:00
Mislav Marohnić
71b13a81d0 Correctly report HTTP and Markdown errors in repo view
Any errors from fetching and rendering the README were silenced and
ignored in `repo view`. This change:

- Tolerates HTTP 404, but will raise exceptions for any other error;
- Moves markdown rendering from `api` package to command implementation;
- Ensures markdown rendering errors are correctly reported.
2020-07-21 13:47:27 +02:00
Mislav Marohnić
2086ecb3d1 Fix printing network error in case for failed HTTP requests
The CheckScopes middleware tried to read from `res.Headers` before it
verified that `res` is available.
2020-07-17 18:24:13 +02:00
Mislav Marohnić
305cd290ee Fix pr checkout <owner>:<branch> when it matches the default branch
First, consolidate the functionality between `pr merge` and `pr
checkout` that resolves the default branch name of the base repo. With
an added bonus, the new approach avoids an API request when one isn't
necessary.

Then, ensure that checking out 3rd-party PRs will result in local branch
name such as `<owner>/<branch>` when the head branch of the repository
matches the default branch of the base repository. We already have had
code in place to take care of this, but it only took effect in the `pr
checkout <number>`-style invocation.
2020-07-15 15:35:42 +02:00
Mislav Marohnić
c8cf54c10c
Merge pull request #1258 from cli/ghe-remotes
Parse and respect non-github.com git remotes
2020-07-15 13:07:30 +02:00
Mislav Marohnić
28cd348176 Only check OAuth scopes when X-Oauth-Scopes header is present 2020-07-13 15:53:53 +02:00
Mislav Marohnić
55d31303ea Have admin:org scope satisfy read:org requirement
`admin:org` is inclusive of `read:org`, so if we find the former listed
in response headers, we can conclude that the token has necessary scopes
instead of letting a warning notice be shown.
2020-07-13 15:35:14 +02:00
Mislav Marohnić
87a9dc8d4b Merge remote-tracking branch 'origin' into ghe-remotes 2020-07-13 13:39:14 +02:00
Mislav Marohnić
7a289861d2 Name more queries in test stubs 2020-07-10 20:20:33 +02:00
Mislav Marohnić
13b9c98b2b Match named queries in test stubs 2020-07-10 20:04:54 +02:00
Mislav Marohnić
d96e88c223 Rename IssueCreate mutation
This follows the "NounVerb" convention we got going on
2020-07-10 18:08:16 +02:00
Mislav Marohnić
f4c4ce0b0a Add names to GraphQL queries made over shurcooL adapter 2020-07-07 17:53:40 +02:00
Mislav Marohnić
a7806a3e78 Add names to queries made over our homegrown GraphQL adapter 2020-07-07 17:53:40 +02:00
Mislav Marohnić
a68cefadd9 Merge remote-tracking branch 'origin' into ghe-remotes 2020-07-02 20:37:33 +02:00
Mislav Marohnić
446a4111f7 Respect hostnames when resolving git remotes and URL args to repos 2020-07-02 20:36:10 +02:00
Mislav Marohnić
ed781103c7
Merge pull request #644 from eddumelendez/add_filters_issues
Add filters issues
2020-07-02 12:24:30 +02:00
Mislav Marohnić
1ca3d171e6 Tweak HTTP 422 handling when deleting branches 2020-06-30 19:21:39 +02:00
Mislav Marohnić
6ac61e90b7 Merge remote-tracking branch 'origin' into add_filters_issues 2020-06-30 14:24:30 +02:00
Pavel Borzenkov
3afec6f90a api: gracefully handle already deleted remote refs
If a GitHub repo is configured to automatically delete branches after PR
is merged, `gh pr merge` fails with error like:

failed to delete remote branch: ... (422): 'Reference does not exist'

Gracefully handle such case and don't report the error.

Signed-off-by: Pavel Borzenkov <pavel.borzenkov@gmail.com>
2020-06-27 19:10:42 +03:00
Pavel Borzenkov
c66eebc6fb api: return structured error for failed API calls
`fmt.Errorf` hides information and makes it hard to test for specific
conditions in returned error. Return a structured error instead.

Signed-off-by: Pavel Borzenkov <pavel.borzenkov@gmail.com>
2020-06-27 18:47:34 +03:00