Commit graph

90 commits

Author SHA1 Message Date
Mislav Marohnić
f93261a6f9 Revert to ignoring non-github.com git remotes
This fixes a regression where extra git remotes pointing to
non-github.com hostnames could result in gh trying to parse repository
information from them.
2020-07-16 18:54:35 +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ć
ab903bdfc0
Merge pull request #1155 from metalogical/FIX-detached-head
fix regression in support for detached HEAD state
2020-06-24 17:01:22 +02:00
Mislav Marohnić
3ea71e6eb6 Add ability to parse non-GitHub.com git remotes 2020-06-23 19:51:26 +02:00
naman
fffa393683 fix lint 2020-06-11 17:08:18 -07:00
naman
fb7b01b40c resolve PR review 2020-06-11 17:05:25 -07:00
gedenata
8ffd0d59f6 redundant type composite literal 2020-06-12 04:23:51 +08:00
naman
3bb6983b35 fix regression in support for detached HEAD state
for gh pr status
2020-06-10 11:41:44 -07:00
Mislav Marohnić
77227a6c50 Trigger OAuth flow only when requesting auth token
Previously we would trigger OAuth flow when the config file did not
exist. Now we will let an empty Config object be initialized in that
case, but trigger OAuth flow when the Context caller requests an
AuthToken.
2020-06-02 13:24:39 +02:00
Mislav Marohnić
f42c9d4b2d Allow stubbing multiple config files 2020-06-02 13:19:21 +02:00
Mislav Marohnić
d9e39226ca Clean up unused struct field
https://github.com/cli/cli/pull/976/checks?check_run_id=693382299
2020-05-20 17:41:33 +02:00
Mislav Marohnić
767521c055 Stop providing AuthLogin from context
The login name of the authenticated user will be readily available only
if authentication info comes from the config file. With other upcoming
authentication modes (for example, the GITHUB_TOKEN environment
variable), the token is the only piece of information we got, so we
would need to additionally query for the login name.

Since `issue status` and `pr status` are the only commands that need the
name of the authenticated user right now, have those commands explicitly
query for the login name. This results in an additional API query, but
simplifies Context implementation and future authentication approaches.
2020-05-20 17:09:13 +02:00
Kevin Bluer
d440a95aed
Improved error message when "owner/repo" format not provided (#919)
Fixes #882
2020-05-18 11:13:48 +02:00
Mislav Marohnić
0a4d4ee007 Replace FakeHTTP with httpmock which is now compatible 2020-05-07 15:19:14 +02:00
vilmibm
db9f4c36aa oops 2020-04-20 16:51:23 -05:00
vilmibm
c4693077aa move config stuff to its own package 2020-04-20 13:57:16 -05:00
vilmibm
815f461e8b more strict erroring around missing user/token 2020-04-20 12:49:46 -05:00
vilmibm
b1d5264524 do not import testing outside of a _test file 2020-04-20 12:37:52 -05:00
vilmibm
bd907ec74d favor %w over %s for error wrapping 2020-04-20 12:22:12 -05:00
vilmibm
e823ad0c6c staunch some type bleeding 2020-04-17 15:27:52 -05:00
vilmibm
a0b7f37935 clean up Config interface 2020-04-17 15:21:44 -05:00
vilmibm
a325db3051 new config infrastructure
- adds config get and config set commands
- supports arbitrary k/v strings set at top and host level
- supports writing an updated config, preserving comments
- supports mostly lazy evaluation of yaml
2020-04-17 15:17:44 -05:00
Mislav Marohnić
734497a8d8
Code fixes informed by golangci-lint failures (#738) 2020-04-03 16:33:34 +02:00
vilmibm
44acdd4ec3 Merge branch 'master' into pr-status-no-commits 2020-03-30 12:04:02 -05:00
Mislav Marohnić
5726376ab1 Guard against faulty affiliations GraphQL filter
This API was just fixed in github.com, but it will take a while for the
change to propagate to GitHub Enterprise installs, so guard ourselves
from false positives when querying forks.
2020-03-25 08:26:06 +01:00
vilmibm
121173c330 better error reporting + catch for empty repo 2020-03-23 15:21:58 -05:00
Mislav Marohnić
d75faab85a Creating a PR now always prioritizes an existing fork as a push target
Before: the default push target for the current branch in `pr create`
was the first repository found among git remotes that has write access.

Now: the default push target is the fork the base repo, if said fork
exists and has write access, falling back to old behavior otherwise.

This change in the default is to facilitate contributions to projects
that have a hard requirement that all pull requests (even those opened
by people with write access to that project) come from forks.
2020-03-19 16:04:23 +01:00
Mike Rogers
caf12adef1 unusally > unusually 2020-03-07 20:44:14 +00:00
Nate Smith
3d7733870e
Merge branch 'master' into repo-fork 2020-03-03 15:40:54 -06:00
vilmibm
ded870714f add SetAuthLogin helper to blank context 2020-02-25 16:26:51 -06:00
Dasio
9289ab99f2 Use var syntax when empty struct is initialized 2020-02-24 22:33:22 +01:00
Dasio
8aa46c236e Init slice with provided capacity if it's known in advance 2020-02-24 22:16:41 +01:00
Mislav Marohnić
4727fc4659 Ensure descriptive error when no github.com remotes found 2020-02-20 22:30:25 +01:00
Yash Ladha
4ee995dafd
fix(486): Getting issue list on no remotes specified
Fixes: #486
2020-02-21 02:14:20 +05:30
Mislav Marohnić
72bde685b0 Add back comments explaining OAuth app credentials 2020-02-18 19:31:18 +01:00
Colin Arnott
213f4a5333 context: use the real oauth credentials
It is trivial to extract this information from the released artefacts,
thus there is no security benefit to the safe/development credentials.
This approach also prevents users from using go-get to install.

As proof of concept, and to enable go-get, this change embeds
the GitHub CLI credentials, instead of GitHub CLI (dev).
2020-02-18 19:31:01 +01:00
vilmibm
c8a4ac66d8 start on fixing tests 2020-02-11 21:56:20 -06:00
vilmibm
f653dbb6b5 wrap and reuse the resolveToRemotes code from PR commands 2020-02-11 19:33:04 -06:00
vilmibm
22be13d8d5 move resolveRemotesToRepos to context 2020-02-11 19:33:04 -06:00
Borna Butkovic
f0d8c65194 pr view, status, list parent repo instead of fork 2020-02-11 19:33:04 -06:00
Mislav Marohnić
8453bf679c Fix parsing non-GitHub remotes
Otherwise, the remote URL translation mechanism had crashed when
encountering a non-Github.com git remote.
2020-01-28 19:51:44 +01:00
Mislav Marohnić
a710893fc1 Rename to cli/cli 2020-01-24 16:08:52 +01:00
Mislav Marohnić
22fe0839fa Merge remote-tracking branch 'origin/master' into ghrepo-interface 2020-01-23 14:19:10 +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
Amanda Pinsker
ea09883b07 Restyle auth page 2020-01-22 14:45:31 -08:00
Mislav Marohnić
1f90579d2a Extract common interface for a GitHub Repository
Also define a handful of utility methods:
- `New(owner, repo)`
- `FullName`: the name slash owner pair
- `FromFullName`: parse the name slash owner pair
- `FromURL`: parse a GitHub.com URL
- `IsSame(r1, r2)`: compare two repositories
2020-01-22 22:44:46 +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
Nate Smith
bf209d88a6 Merge pull request #222 from github/oauth-debug
Improve OAuth flow
2020-01-13 18:03:32 -06:00
Mislav Marohnić
853fda13e9 Add more OAuth flow debugging to stderr with DEBUG=oauth 2020-01-13 20:31:31 +01:00