Commit graph

50 commits

Author SHA1 Message Date
Mislav Marohnić
734497a8d8
Code fixes informed by golangci-lint failures (#738) 2020-04-03 16:33:34 +02:00
Mislav Marohnić
f0e6c98bf0 Fix auto-forking scenario in pr create
When an existing `headRepo` couldn't be detected, it's time to auto-fork
one. Unfortunately, an obscure Go behavior made it seem like `headRepo`
was a non-nil value, where in fact it did contain a nil pointer which
would crash the process.

This avoids ever assigning nil pointers to `var headRepo ghrepo.Interface`.
2020-04-01 19:37:56 +02:00
Mislav Marohnić
e0ba3fd614
Merge pull request #717 from cli/improve-finding-commits
Use remote tracking branch for base when detecting commits for `pr create`
2020-03-31 17:08:10 +02:00
Mislav Marohnić
219e3ecc5b Stop querying base branch commit hash from API
This code was put in place in preparation for a feature that never
shipped. Namely, we wanted to use the commit hash for the base branch so
we can get an accurate `git log` involving the changes in a pull
request. However, getting the commit hash from API is not the way to go
because the latest commit might not be available in the person's local
repository, and using a local tracking branch for base such as
`origin/master` works quite well in most cases without dereferencing it.
2020-03-31 13:36:48 +02:00
Mislav Marohnić
24a332bb1b Use remote tracking branch for base when detecting commits for pr create
This is to avoid errors when a local base branch is missing or out of
date.
2020-03-31 13:32:44 +02:00
vilmibm
c966f0dca5 test fallout 2020-03-30 12:04:45 -05:00
vilmibm
44acdd4ec3 Merge branch 'master' into pr-status-no-commits 2020-03-30 12:04:02 -05:00
Mislav Marohnić
da2116f8ee Merge remote-tracking branch 'origin/master' into pr-create-push-default 2020-03-30 13:32:37 +02:00
Mislav Marohnić
cba8331d55 Avoid auto-forking/pushing an already pushed branch in pr create
A branch is considered already pushed if its HEAD commit hash matches
the commit hash of one of the remote tracking branches:
`refs/remotes/<remote>/<branch>`

This mechanism allows the user to:

- Choose a remote as push target for their branch different than the one
  that would automatically get chosen for them by `pr create`;

- Avoid a `git push` operation (and its associated git hooks) if a push
  was not necessary in the first place.
2020-03-26 20:35:42 +01:00
vilmibm
dd877b6a34 merge fallout 2020-03-25 12:01:44 -05:00
vilmibm
f4b8851011 Merge remote-tracking branch 'origin/master' into pr-status-no-commits 2020-03-25 12:00:58 -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
Mislav Marohnić
5b2e1847b7 Merge remote-tracking branch 'origin/master' into pr-create-push-default 2020-03-25 08:16:04 +01:00
vilmibm
88cf6ce16e consolidate CmdStubber into test package 2020-03-23 16:36:24 -05:00
vilmibm
2895252e3b respect -B when checking for existing pull requests 2020-03-23 14:26:31 -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
Mislav Marohnić
5b76881624 Improve detecting existing PR on pr create
- Only check for existing PRs if `--web` wasn't given
- Fix detecting PRs from forks
- Improve order of error handling: local validation errors are handled
  earlier than the ones that have to consult the API
2020-03-18 13:09:02 +01:00
vilmibm
0344e9543a humanize branch name for title 2020-03-17 16:18:32 -05:00
vilmibm
98a2281f45 more nuanced error handling 2020-03-17 16:09:40 -05:00
vilmibm
af46fcb1ff --fill for pr create 2020-03-16 15:32:47 -05:00
vilmibm
2d90c09f48 review feedback 2020-03-16 15:32:35 -05:00
vilmibm
a23549001e cleanup 2020-03-13 15:14:32 -05:00
vilmibm
1b7840326c actually add tests for computing defaults 2020-03-13 15:14:03 -05:00
vilmibm
fba4f4d19e InitCmdStubber 2020-03-13 15:12:23 -05:00
vilmibm
c4c967fa0f add AskStubber 2020-03-13 15:12:17 -05:00
vilmibm
ed8aaa83e3 add CmdStubber 2020-03-13 15:12:09 -05:00
vilmibm
8769299731 titlebody prepopulation 2020-03-13 15:12:03 -05:00
Mislav Marohnić
96ba2d27d8 Respect overriden base branch in pr create --web 2020-02-17 14:14:37 +01:00
vilmibm
212dc1da1d properly specify head ref for cross-repo/same-branch 2020-02-12 16:11:04 -06:00
vilmibm
2ff31909cd use new helper 2020-02-12 11:33:24 -06:00
vilmibm
c8a4ac66d8 start on fixing tests 2020-02-11 21:56:20 -06:00
Mislav Marohnić
a710893fc1 Rename to cli/cli 2020-01-24 16:08:52 +01:00
Mislav Marohnić
30b4eab8e0 Use ghrepo.FullName in tests 2020-01-23 14:24:22 +01:00
Mislav Marohnić
f10b8d8095 Add unit tests for remotes-to-repos resolver 2020-01-23 14:05:15 +01:00
Mislav Marohnić
6c49614db7 Fix tests 2020-01-21 22:56:15 +01:00
Corey Johnson
f2afbbce74 Fix test output 2019-12-20 12:07:53 -08:00
Corey Johnson
58761a8dfc Fix tests 2019-12-20 12:04:23 -08:00
Corey Johnson
bcf1f98702 Do a better job of reverting test changes 2019-12-20 11:32:27 -08:00
Corey Johnson
d025d2d4f3 Revert test changes 2019-12-20 11:24:03 -08:00
Mislav Marohnić
2c1fc56967 Update output expectations 2019-12-17 13:01:45 +01:00
Mislav Marohnić
7b7c985e79 Merge remote-tracking branch 'origin/master' into appropriate-context-and-feedback 2019-12-17 13:00:10 +01:00
Corey Johnson
91267a65fa Fix tests 2019-12-16 13:18:16 -08:00
Mislav Marohnić
48aeff1ca7 Assert stdout separarely from stderr in command tests
This stubs stderr separately from stdout in command tests (before those
streams were combined) and improves test assertions around output.

Additionally, no longer use the `cmd.Print*()` family of Cobra functions
because their name sounds like the text will go to stdout, but they
write to stderr instead. Use the more explicit `cmd.ErrOrStderr()` as
output destination instead.
2019-12-16 15:46:42 +01:00
Mislav Marohnić
5ac4b1e6d6 Implement pr create --web 2019-12-04 16:26:40 +01:00
Mislav Marohnić
2621bccc44 Use RunCommand in tests to ensure flags reset between runs 2019-12-03 17:26:28 +01:00
Mislav Marohnić
bb87f4a2fb Add pr create test for git clean state 2019-11-13 19:25:02 +01:00
Mislav Marohnić
6aa0c071d6 Simplify tests that use StubExecCommand 2019-11-11 17:04:26 +01:00
Mislav Marohnić
65054fdc6e Complete pr create test 2019-11-11 15:01:41 +01:00
nate smith
df3e3bb4af minor fix 2019-11-02 12:55:17 -05:00
nate smith
c12bdc2731 WIP resuming pr create test work 2019-11-01 17:19:01 -05:00