Commit graph

63 commits

Author SHA1 Message Date
Mislav Marohnić
13b9c98b2b Match named queries in test stubs 2020-07-10 20:04:54 +02:00
Mislav Marohnić
ac04c878c0
Merge pull request #1279 from pborzenkov/delete-branch-422
Gracefully handle "422: Reference does not exist" when deleting remote branch
2020-07-02 12:11:12 +02:00
Mislav Marohnić
1ca3d171e6 Tweak HTTP 422 handling when deleting branches 2020-06-30 19:21:39 +02:00
AliabbasMerchant
7a04bf1672 api --silent Changes:
Show Response Headers (if requested) even with `--silent` flag
Shift silent tests to `Test_apiRun`
Changed usage string of `--silent` flag
2020-06-30 19:18:28 +05:30
AliabbasMerchant
aa43c55f60 Skip printing headers when --silent in api 2020-06-29 07:13:06 +05:30
AliabbasMerchant
5e56e31384 Added Test for --silent flag in api 2020-06-29 00:30:24 +05:30
AliabbasMerchant
cb2308c077 --silent flag in api 2020-06-29 00:15:34 +05:30
Pavel Borzenkov
aa8f8e8904 httpmock: propagate original HTTP request to HTTP response
So that it's possible to access it in mocked HTTP tests.

Signed-off-by: Pavel Borzenkov <pavel.borzenkov@gmail.com>
2020-06-27 18:47:06 +03:00
Mislav Marohnić
c945fb4336 Automatically add per_page=100 to paginated REST requests
Most endpoints respect this parameter by default. Those that don't will
just ignore it. The `per_page=100` parameter is not added if there is
already a `per_page` parameter specified in the request.
2020-06-23 18:42:57 +02:00
Mislav Marohnić
f4ecd365a6 api command: add GraphQL support for --paginate 2020-06-17 18:02:20 +02:00
Mislav Marohnić
3f940c98f1 Add assertion for 1st api request before pagination 2020-06-16 18:19:39 +02:00
Mislav Marohnić
7907def880 api command: add support for REST pagination 2020-06-16 18:16:49 +02:00
Mislav Marohnić
b838ac4014 Improve no args error handler and extend it to other commands 2020-06-15 21:01:32 +02:00
Mislav Marohnić
3f6d0bff45 Switch to :owner/:repo syntax for placeholders 2020-06-11 21:46:27 +02:00
Mislav Marohnić
acf0046718 api command: support {owner} and {repo} placeholders
When `{owner}` and `{repo}` strings are found in request path (for REST
requests) or `query` (for GraphQL), they are replaced with values from
the repository of the current working directory.
2020-06-11 15:00:29 +02:00
Mislav Marohnić
74a39f3ed1 Turns out we do need explicit Content-Length for file uploads
This reverts commit 141388fd23.
2020-06-10 18:18:49 +02:00
vilmibm
8263cd238b linter appeasement 2020-06-10 11:05:21 -05:00
Nate Smith
bd7e6bf00c
Merge branch 'trunk' into api-raw-body 2020-06-10 11:00:59 -05:00
Nate Smith
446486fec1
Merge pull request #1114 from cli/pretty-json
Pretty-print JSON in `api` command output
2020-06-10 10:53:10 -05:00
Nate Smith
096bf6bb79
Merge pull request #1115 from cli/api-errors
Print HTTP errors on stderr in `api` command
2020-06-10 10:35:04 -05:00
Mislav Marohnić
141388fd23 Turns out, Go will automatically set Content-Length 2020-06-10 16:29:50 +02: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ć
b329919b19 api command: support raw body passed in via --input <file>
This is to support file uploads or to pass in JSON bodies constructed
elsewhere.
2020-06-10 15:53:06 +02:00
Mislav Marohnić
e19ea12265 Merge remote-tracking branch 'origin' into blank-issue 2020-06-10 12:35:33 +02:00
Mislav Marohnić
771cd5991c Add tests for jsoncolor 2020-06-08 16:05:00 +02:00
Mislav Marohnić
4165793fae Extract printing response headers, include status line 2020-06-08 15:39:35 +02:00
Mislav Marohnić
fd1e87beeb Print response header keys in color too 2020-06-08 15:18:06 +02:00
Mislav Marohnić
5d5bd04102 💅 Extract parsing error response into its own function 2020-06-08 15:12:13 +02:00
Mislav Marohnić
d57b5171cf Print HTTP errors on stderr in api command
Most API errors are present in the response body itself, which will be
sent to stdout normally, but if stdout is redirected somewhere (as it's
common with scripts), failed HTTP requests will likely sabotage the rest
of the script, but no useful info will be shown on stderr.

This makes it so all REST and GraphQL errors are always shown on stderr.
Additionally, this makes sure that the command exits with a nonzero
status on any GraphQL errors.
2020-06-05 18:24:24 +02:00
Mislav Marohnić
62549465a0 Display JSON in indented, colored format in api output 2020-06-05 17:43:07 +02:00
Mislav Marohnić
7033021637 gh api: fix passing file/stdin contents via field arguments
Reading from file via `-F foo=@myfile.txt` syntax would result in
`[]byte` Go type, which by default gets serialized to JSON in base64
format, which we don't want here.

Traverse all parameters and convert any `[]byte` into `string` before
JSON serialization.
2020-06-03 16:00:52 +02:00
AliabbasMerchant
864d74d0b1 Categorize Templates as Legacy and NonLegacy 2020-05-23 00:03:38 +05:30
Mislav Marohnić
ea3a55c3d6 Ensure that cobra command tests don't write to system stdout/stderr 2020-05-20 16:28:35 +02:00
Mislav Marohnić
292b428465 Add test for showing response headers 2020-05-20 16:28:27 +02:00
Mislav Marohnić
bef62faaea Make NewCmdApi testable 2020-05-20 15:21:35 +02:00
Mislav Marohnić
f58e0bf710 Add api tests 2020-05-20 15:21:32 +02:00
Mislav Marohnić
d8146cd16e Extract cmdutil package 2020-05-20 15:21:31 +02:00
Mislav Marohnić
4c762d5bd7 Add iostreams package 2020-05-20 15:21:31 +02:00
Mislav Marohnić
a7100b1fdd Extract parseFields to a func 2020-05-20 15:21:31 +02:00
Mislav Marohnić
7ffbde3e12 Allow setting multiple values for a request header 2020-05-20 15:21:31 +02:00
Mislav Marohnić
90fa193eaf Promote api command to a pkg/cmd/api package 2020-05-20 15:21:31 +02:00
Mislav Marohnić
57e60ab8a1 Merge remote-tracking branch 'origin/master' into issue-metadata-resolve-ids 2020-05-13 17:20:37 +02:00
Mislav Marohnić
6d57f2a91e Faster resolve GraphQL node IDs for assignees, reviewers, and labels 2020-05-12 15:33:51 +02:00
vilmibm
7009321314 review feedback 2020-05-11 17:06:18 -05:00
Mislav Marohnić
3000847bb2
Merge pull request #874 from cli/httpmock
Parallelism-safe mechanism for stubbing HTTP responses
2020-05-08 17:34:57 +02:00
Mislav Marohnić
8b9e7df705 Fix parsing some issue template names
YAML parsing sometimes gets sabotaged by asterisks that follow the end
of frontmatter (`---`). We now scope YAML parsing to only frontmatter
and we don't pass any contents that follow.
2020-05-07 15:50:01 +02:00
Mislav Marohnić
0a4d4ee007 Replace FakeHTTP with httpmock which is now compatible 2020-05-07 15:19:14 +02:00
Mislav Marohnić
1d4065e4c4 Add a HTTP mocking interface that matches incoming requests
This adds a thread-safe RoundTripper that can be used for mocking HTTP
requests in tests. Incoming requests are matched based on their
contents, not the order the stubs were registered in.
2020-05-06 22:03:32 +02:00
vilmibm
9641eee38a use more clear name 2020-04-22 14:31:09 -05:00
vilmibm
3c8b87c9c6 respect configured editor 2020-04-22 11:23:14 -05:00