Commit graph

56 commits

Author SHA1 Message Date
vilmibm
f84365ce08 use heredocs 2020-07-27 10:02:18 -05:00
vilmibm
4c57566cdc sigh 2020-07-24 15:40:59 -05:00
vilmibm
2dc8cad7c5 remove stray debugs 2020-07-24 15:26:25 -05: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
vilmibm
1831d95433 isolated clone command
This commit hacks the existing repo clone tests into something usable by
the new isolated command. It went ok and was less effort than trying to
introduce the same kind of test format as repo view and gist create.
2020-07-23 16:40:31 -05:00
vilmibm
b9ce1a1daf pass resolving baserepo into newcmdview 2020-07-23 15:13:23 -05:00
vilmibm
d92c80b560 just swap BaseRepo implementation 2020-07-23 11:58:22 -05:00
vilmibm
086fb48d31 move displayURL 2020-07-23 11:25:31 -05:00
vilmibm
70c948a751 move isURL 2020-07-23 11:23:45 -05:00
vilmibm
dc02366128 move generateRepoURL to ghrepo 2020-07-23 11:16:47 -05:00
vilmibm
895af993a5 static not found error 2020-07-23 11:12:33 -05:00
vilmibm
12e88da400 w h i t e s p a c e 2020-07-23 11:10:25 -05:00
vilmibm
2a99ed9afb add ResolvedBaseRepo 2020-07-23 11:01:29 -05:00
vilmibm
7b8d226e0f remove redundant statement 2020-07-22 15:54:11 -05:00
vilmibm
a27c8a9c21 isolate repo view cmd 2020-07-22 15:54:11 -05:00
vilmibm
05419e46f0 put gist fixture file into gist package 2020-07-22 10:36:12 -05:00
Mislav Marohnić
16739c3044 Whoops, gist create stderr is not empty 2020-07-22 14:59:35 +02:00
Mislav Marohnić
b195075644 Tweak approach to iostreams in tests
- avoid typecast to `*bytes.Buffer`
- assert that stderr is empty
2020-07-22 14:50:23 +02:00
vilmibm
496ed477c5 linter appeasement 2020-07-21 17:47:44 -05:00
vilmibm
d12ff4b9e5 oauth scope check test 2020-07-21 17:39:49 -05:00
vilmibm
ba46362a7f add createRun tests 2020-07-21 17:19:59 -05:00
vilmibm
5085a5eda2 WIP test works with mock 2020-07-21 15:17:30 -05:00
Mislav Marohnić
e373195817 WIP migrate gist create to separate package 2020-07-21 18:13:16 +02:00
Mislav Marohnić
75086f0b80 💅 Improve readability of api example code
Tab indentation is replaced with two spaces to curb deep indentation.
2020-07-16 17:46:25 +02:00
Mislav Marohnić
9e4af479da Add command line docs for supported environment variables 2020-07-16 17:46:09 +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
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ć
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
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ć
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
Mislav Marohnić
ea3a55c3d6 Ensure that cobra command tests don't write to system stdout/stderr 2020-05-20 16:28:35 +02:00