Commit graph

49 commits

Author SHA1 Message Date
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
vilmibm
35f18b6c02 gh auth login 2020-08-06 12:43:35 -05: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ć
288d01318b Respect the hostname of current repository in queries 2020-07-23 22:31:08 +02:00
Mislav Marohnić
e373195817 WIP migrate gist create to separate package 2020-07-21 18:13:16 +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ć
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ć
f4c4ce0b0a Add names to GraphQL queries made over shurcooL adapter 2020-07-07 17:53:40 +02:00
Mislav Marohnić
1ca3d171e6 Tweak HTTP 422 handling when deleting branches 2020-06-30 19:21:39 +02: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
Mislav Marohnić
b099bb3037 api command: accept full URLs as path input
This is to allow file uploads to `https://uploads.github.com`
2020-06-10 16:26:23 +02:00
Mislav Marohnić
1595d3b950 Handle HTTP errors in HasScopes 2020-06-02 13:24:46 +02:00
Mislav Marohnić
2e93a065b1 Merge remote-tracking branch 'origin/master' into api-command 2020-05-27 12:56:06 +02:00
Mislav Marohnić
90fa193eaf Promote api command to a pkg/cmd/api package 2020-05-20 15:21:31 +02:00
Mislav Marohnić
fa3e25bb4d Serialize GraphQL parameters under variables 2020-05-20 15:21:31 +02:00
Mislav Marohnić
1609afe993 Add api command 2020-05-20 15:21:31 +02:00
vilmibm
96ba1eacef undo initial thing 2020-05-15 16:44:51 -05:00
vilmibm
7decae71fc untested first pass on ensureScopes 2020-05-15 16:40:13 -05:00
vilmibm
cc1ffb0aea pass apiClient to determineBaseRepo
Our code had an unspoken assumption that only one apiClient is created
during the course of a command. Violating this assumption is fine in
almost all cases, but not when we need to do a re-auth to add a new
oauth scope to a user's token.

There is likely a more elegant solution to the problem but until then
this changes determineBaseRepo to use an existing apiClient.
2020-05-13 14:55:49 -05:00
vilmibm
3a7f56456e tweak reauth code and request a new scope 2020-05-13 14:24:29 -05:00
Mislav Marohnić
3aaa231cc5 Guide user through re-authorization flow if read:org scope is missing
How this works for people with existing OAuth tokens:

    $ gh issue list -L1
    Notice: additional authorization required
    Press Enter to open github.com in your browser...
    [auth flow in the browser...]
    Authentication complete. Press Enter to continue...

    Showing 1 of 132 issues in cli/cli
    ...

Users of Personal Access Tokens get a different notice:

    Warning: gh now requires the `read:org` OAuth scope.
    Visit https://github.com/settings/tokens and edit your token to enable `read:org`
    or generate a new token and paste it via `gh config set -h github.com oauth_token MYTOKEN`
2020-04-23 18:20:21 +02:00
Mislav Marohnić
3d566dc5a6 Detect and warn about read:org OAuth scope being missing 2020-04-15 17:25:15 +02:00
gertd
203525c031 pr bug/rest-204 review feedback 2020-04-10 16:48:11 -07:00
gertd
b9f1b5dac1 fix api.REST(DELETE, ...) json.Unmarshal failure 2020-04-09 22:19:28 -07:00
Mislav Marohnić
9c00ac0224 Tweak verbose HTTP logging
- log headers only in DEBUG=api mode
- enable color output on stderr
- hide little-useful TLS debbuging info
- ensure all request headers are logged
2020-02-21 12:57:00 +01:00
Henrique Vicente
e7c88d0fb1
impr(verbose): using package httpretty to log requests on DEBUG. 2020-02-21 02:46:18 +01:00
Mislav Marohnić
4f6dfee965 Merge remote-tracking branch 'origin/master' into pr-create-just-works-TM 2020-01-23 14:08:07 +01:00
Mislav Marohnić
0b0fd42ef3 Dump HTTP request/response bodies when DEBUG=api 2020-01-22 19:35:39 +01:00
Mislav Marohnić
7a614ce697 Support triangular git workflows in pr create
- The local git remotes are scanned and resolved to GitHub repositories
- The "base" repo is the first result resolved to its parent repo (if a fork)
- The name of the default branch is read from the base repo
- The "head" repo is the first repo that has push access
2020-01-21 18:26:08 +01:00
Corey Johnson
f8f0aa829e Only run in prod 2019-12-02 15:57:34 -08:00
Corey Johnson
dc91781214 Works with POST 2019-12-02 15:46:57 -08:00
Corey Johnson
1231ddd01c Add test 2019-12-02 15:08:36 -08:00
Mislav Marohnić
f786802e9e Customizable API client 2019-10-29 21:07:03 +01:00
Mislav Marohnić
8016d80884 Create overridable Context interface 2019-10-17 02:25:59 +02:00
Mislav Marohnić
12e295e46b Merge remote-tracking branch 'origin/master' into ghr-context 2019-10-17 02:23:00 +02:00
Corey Johnson
bb2876cf37 Merge branch 'master' into test 2019-10-15 14:21:34 -07:00
Corey Johnson
59ddb5607d Use func var to override GraphQL calls 2019-10-15 14:19:56 -07:00
nate smith
0600c8c68c switch to context struct 2019-10-15 13:36:38 -05:00
Corey Johnson
ed4f59fe30 rename v to data 2019-10-11 14:37:28 -07:00
Corey Johnson
2dc521d589 A non-successful response returns early 2019-10-11 14:23:46 -07:00
nate smith
df074046ac add context.go and move over getToken 2019-10-10 15:39:39 -05:00
Corey Johnson
0f6daa0310 Don't panic 2019-10-09 15:32:41 -07:00
Corey Johnson
3a931ea83e spacing 2019-10-09 13:15:08 -07:00
Corey Johnson
a35441cb69 Add version 2019-10-09 13:15:03 -07:00
Corey Johnson
b7dda5ef25 tweaks 2019-10-09 11:39:26 -07:00
Corey Johnson
8b69ca3919 Rename package to api 2019-10-09 11:34:35 -07:00
Renamed from graphql/client.go (Browse further)