Commit graph

55 commits

Author SHA1 Message Date
Corey Johnson
326b678b24 Add delete branch
Co-Authored-By: Nate Smith <vilmibm@neongrid.space>
2020-05-12 08:51:22 -07:00
vilmibm
bec58ede98 respect ssh
this adds recognition of the git_protocol setting when:

- creating a repo
- cloning a repo
- forking a repo
- forking/pushing during pr create
- checking out a PR

additionally, it:

- consolidates remote adding to use AddRemote; this introduces a fetch
where there previously hadn't been one
- changes repo clone to accept an ssh url
- changes repo fork to accept an ssh url

i just added basic unit tests; adding new test cases for all of the
above scenarios seemed like diminishing returns.
2020-04-22 14:21:01 -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ć
da2116f8ee Merge remote-tracking branch 'origin/master' into pr-create-push-default 2020-03-30 13:32:37 +02:00
vilmibm
eb403a3b1e more nuanced error typing 2020-03-27 11:35:39 -05:00
vilmibm
ca99096ca8 use CmdError in StubError and fix git_test 2020-03-26 15:32:31 -05:00
vilmibm
0af232444c consolidate into one symbolic-ref call 2020-03-26 15:00:58 -05: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
Mislav Marohnić
3907914225 Guard against filesystem paths in git.ReadBranchConfig
A valid remote specificication read from `branch.<name>.remote` git
config can be a URL, a `.`, a filesystem path, and a remote name. When
detecting the remote name, be sure not to take filesystem paths instead.
2020-03-26 19:23:17 +01:00
Mislav Marohnić
c36b84e550 Convert git.VerifyRef into a more versatile ShowRefs
This is so we can pass a list of full qualified refs and have them
resolved for both existence and their commit hashes.
2020-03-26 19:21:40 +01:00
vilmibm
897d5c3dca fall back to symbolic-ref in CurrentBranch 2020-03-25 11:57:53 -05:00
vilmibm
4632ab1a1e test for CurrentBranch on an empty repo 2020-03-24 14:19:35 -05:00
vilmibm
dd1e2a2dfc add StubError to CmdStubber 2020-03-24 14:19:35 -05:00
vilmibm
5187ad4431 move preparecmd and Runnable to its own package 2020-03-23 16:32:29 -05:00
vilmibm
121173c330 better error reporting + catch for empty repo 2020-03-23 15:21:58 -05:00
Mislav Marohnić
e3653672a8 Simplify git.AddRemote implementation
The 2nd argument now unused since we've determined that, in practice, we
can safely fetch git objects from a freshly created fork on GitHub and
that we don't need the remote URL-swapping workaround.
2020-03-20 13:08:33 +01: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
ed8aaa83e3 add CmdStubber 2020-03-13 15:12:09 -05:00
vilmibm
8769299731 titlebody prepopulation 2020-03-13 15:12:03 -05: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ć
53532d6f28 Make sure git push output shows up during pr create 2020-02-24 19:33:18 +01:00
Odin Ugedal
12887db9c8
Fix wrong repo url being used for pushing
afaik this should be finalURL (the fork) and not initURL (the upstream),
otherwise a bit of the code above can be removed.
2020-02-13 17:30:54 +01:00
Mislav Marohnić
a710893fc1 Rename to cli/cli 2020-01-24 16:08:52 +01:00
Mislav Marohnić
e2a825effb Auto-fork on pr create if no pushable target found 2020-01-22 18:32:06 +01:00
Mislav Marohnić
d8474d5990 Read current git branch in a way that is compatible with older git 2020-01-10 14:08:54 +01:00
Mislav Marohnić
fb0472a868 Merge pull request #176 from github/issue-pr-templates
Add template support to `issue create`, `pr create`
2019-12-23 13:41:15 +01:00
Mislav Marohnić
d5ba3de751 Add template support to issue create, pr create
If multiple templates are found, the user is prompted to select one.

The templates are searched for, in order of preference:

- issues:
  1. `.github/ISSUE_TEMPLATE/*.md`
  2. `.github/ISSUE_TEMPLATE.md`
  3. `ISSUE_TEMPLATE/*.md`
  4. `ISSUE_TEMPLATE.md`
  5. `docs/ISSUE_TEMPLATE/*.md`
  6. `docs/ISSUE_TEMPLATE.md`

- pull requests:
  1. `.github/PULL_REQUEST_TEMPLATE/*.md`
  2. `.github/PULL_REQUEST_TEMPLATE.md`
  3. `PULL_REQUEST_TEMPLATE/*.md`
  4. `PULL_REQUEST_TEMPLATE.md`
  5. `docs/PULL_REQUEST_TEMPLATE/*.md`
  6. `docs/PULL_REQUEST_TEMPLATE.md`

The filename matches are case-insensitive.
2019-12-18 22:15:20 +01:00
Mislav Marohnić
f0801b2deb Simplify reading current branch from git 2019-12-17 14:45:24 +01:00
Mislav Marohnić
d7513ef3f6 Fix test assertion when running on Windows 2019-12-16 14:56:44 +01:00
Mislav Marohnić
5d644d2468 Silence stderr in git push during pr create but show it on failures 2019-12-04 16:16:10 +01:00
Mislav Marohnić
db8c2d4e01 Merge remote-tracking branch 'origin/master' into pr-current-branch 2019-12-02 18:56:11 +01:00
Mislav Marohnić
62bbcb266e 🔥 more unused git functions 2019-11-26 16:23:03 +01:00
Mislav Marohnić
eff8847513 Improve detecting PR for the current branch
Now reads git branch configuration and handles these cases:

    branch ["foo"]
      remote origin
      merge  refs/heads/bar

    branch ["foo"]
      remote other-remote
      merge  refs/heads/foo

    branch ["foo"]
      remote https://github.com/OWNER/REPO.git
      merge  refs/heads/bar

    branch ["foo"]
      remote origin
      merge  refs/pull/123/head
2019-11-20 15:20:36 +01:00
Mislav Marohnić
1fc9c8f9d6 Test the scenario where the target branch already exists 2019-11-14 20:29:24 +01:00
Mislav Marohnić
2616da04c4 Only capture stderr of commands that don't have configured Stderr 2019-11-14 20:02:42 +01:00
Mislav Marohnić
6aa0c071d6 Simplify tests that use StubExecCommand 2019-11-11 17:04:26 +01:00
Mislav Marohnić
a275398dac Merge remote-tracking branch 'origin/master' into pr-create 2019-11-11 12:24:09 +01:00
nate smith
18f104ad38 oops 2019-11-02 12:53:33 -05:00
nate smith
c12bdc2731 WIP resuming pr create test work 2019-11-01 17:19:01 -05:00
Mislav Marohnić
d881a2e52e Ensure git operations preserve their stderr in error output
This also provides a SetPrepareCmd hook for tests to be able to define stubs for commands that are supposed to be run
2019-11-01 22:16:23 +01:00
nate smith
7555aa9be3 first pass at generalizing process stubbing 2019-10-31 11:29:39 -05:00
nate smith
ee0fe61b04 test nonzero exit code 2019-10-30 17:46:34 -05:00
nate smith
ab115efd89 add cases to test for 2019-10-30 17:06:49 -05:00
nate smith
fdbf85e9ab sigh worthy mechanism for selecting arbitrary git outputs 2019-10-30 16:45:11 -05:00
nate smith
f6afe1b576 use testing hack to mock git call 2019-10-30 16:34:23 -05:00
nate smith
5087ec5c15 restore pr create with new context/client 2019-10-30 12:00:16 -05:00
Mislav Marohnić
641de86427 Eliminate package-level state in git remote parsing 2019-10-25 21:48:25 +02:00