Commit graph

99 commits

Author SHA1 Message Date
Mislav Marohnić
492f45422e Add a note about the style of git tests 2021-02-26 13:07:38 +01:00
Mislav Marohnić
d97e8fe172 Add live tests for some methods in the git package
We relied too much on stubs for these methods. These new tests actually
invoke `git` commands in the context of a test repository.
2021-02-24 15:05:56 +01:00
Mislav Marohnić
0f85304e3e Avoid crash in pr merge when verifying whether a PR had diverged
A PR is not guaranteed to have commits, it seems, so add a guard against
assuming that there is always a head commit.
2021-02-24 14:37:29 +01:00
Sam Coe
3f172ad991
Add contional and tests 2021-01-25 13:27:32 -08:00
zamasu
e4b9f7cb8c
Alert unpushed commits when merging a pull request 2021-01-25 12:04:32 -08:00
Mislav Marohnić
64fda21116 Avoid ever invoking go-homedir when config was found in a new location 2021-01-22 20:22:32 +01:00
Matthew Gleich
7d9461b819 ♻️ Refactor to use os.UserHomeDir() 2021-01-22 18:51:28 +01:00
Mislav Marohnić
06cf2c9f81 Merge remote-tracking branch 'origin' into cmd-stub-new 2021-01-22 16:31:29 +01:00
Nate Smith
29805a4003
Merge pull request #2588 from cdce8p/gh-clone-fetch
Only fetch default branch when adding upstream remote
2021-01-21 12:57:10 -08:00
vilmibm
dcedd32249 use newer command stubbing in tests 2021-01-21 12:32:40 -08:00
Cristian Dominguez
45f4a1f087 Equal: flip arguments position 2021-01-18 21:00:59 -03:00
Mislav Marohnić
1717c8d083 Migrate to new cmd stubber in git tests 2021-01-18 22:39:59 +01:00
Cristian Dominguez
3afb1d0b1a Use Testify assertions in test 2021-01-16 19:19:30 -03:00
Mislav Marohnić
935f6444ae Refactor ssh parser for format compatibility & testability
- Per ssh_config(5), keywords and arguments may be separated by an `=`
  sign as well as whitespace.
- When following the `Include` directive, skip directories that were
  returned as the result of globbing.
- Respect the `Host` context when recursing into `Include`s
- Avoid having tests read from the actual filesystem.
- Avoid repeatedly looking up the home directory.
2020-12-15 15:59:18 +01:00
Alisson Santos
dc8698ee46 Make ssh parser to parse included config files 2020-12-15 15:37:17 +01:00
cdce8p
f536901bc1 Only fetch DefaultBranchRef when adding upstream remote during gh repo clone 2020-12-09 20:15:21 +01:00
Josh Soref
c8b9486fd3 spelling: nonexistent 2020-11-21 21:43:51 -05:00
Mislav Marohnić
38f68d849f Improve error message when git isn't found 2020-11-11 16:33:13 +01:00
Mislav Marohnić
5b4a08dcb9 Ensure that only PATH is searched when shelling out to external commands
Works around https://github.com/golang/go/issues/38736 for Windows.
2020-11-11 16:33:13 +01:00
Sam Coe
28b3b2c9e7
Address PR comments 2020-11-03 09:59:09 +03:00
Sam Coe
97504f4f1f
Filter out unwanted stderr output during git push commands 2020-11-03 09:58:29 +03:00
Mislav Marohnić
2eab4a940f
Merge pull request #2025 from mmontes11/pr-create-use-git-branch-show-current
Avoding --short option in git symbolic-ref for getting the current branch
2020-10-06 14:31:34 +02:00
Dimitris Apostolou
6f550b5d12
Fix typos 2020-10-04 22:16:30 +03:00
Martín Montes
2a166d1dd7 Using TrimPrefix for getting current branch and improved tests 2020-09-30 18:26:22 +02:00
Martín Montes
3ef1693881 Using symbolic-ref for getting branch and parsing its output 2020-09-30 13:44:16 +02:00
Martín Montes
0e2e97af68 Using git branch --show-current for getting the current branch. Fallback to symbolic-ref 2020-09-29 22:45:32 +02:00
Mislav Marohnić
d534a94d1b Change how base repository is resolved
On first run in a git repository, `BaseRepo()` will now prompt the user
which repository should be queried as base repository if there are
multiple git remotes or when we are in the context of a fork.

In non-interactive mode, the prompt is skipped and we default to the
first git remote instead.

After the base repo is resolved, the result is cached in the local
repository using `git config` so that RepositoryNetwork API lookups can
be avoided in the future.
2020-09-15 21:27:12 +02:00
Mislav Marohnić
3e7a2585c5 Tighten git remote URL parsing
We now only support git URLs that have one of the explicitly supported protocols.
2020-09-04 16:18:26 +02:00
Mislav Marohnić
4315c09501 Ignore non-pre-authenticated hosts when parsing git remotes
This ensures that while having git remotes to point to either
`github.com` or authenticated GHE instances, adding another git remote
pointing to an unrelated host won't change the remote resolution in any
way, even if the unrelated remote is called `upstream` or `github` (and
thus normally took precedence).
2020-08-12 18:13:05 +02:00
Mislav Marohnić
c095a4bead Allow explicitly specifying the hostname for gh operations
Accept the "HOST/OWNER/REPO" syntax or passing a full URL for both the
`--repo` flag and the GH_REPO environment variable and allow setting
GH_HOST environment variable to override just the hostname for
operations that assume "github.com" by default.

Examples:

    $ gh repo clone example.org/owner/repo
    $ GH_HOST=example.org gh repo clone repo

    $ GH_HOST=example.org gh api user
    $ GH_HOST=example.org gh gist create myfile.txt

    $ gh issue list -R example.org/owner/repo
    $ gh issue list -R https://example.org/owner/repo.git
    $ GH_REPO=example.org/owner/repo gh issue list
2020-08-12 16:16:34 +02: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
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
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
Corey Johnson
9113092f5c Delete via api 2020-05-22 15:19:39 -07:00
Corey Johnson
e643765027 Merge remote-tracking branch 'origin/merge-interactive-merge' into remote-delete 2020-05-22 15:09:29 -07:00
Corey Johnson
858cd705ab Update name 2020-05-22 15:07:39 -07:00
Corey Johnson
368aacbff6 Fully qualify that ref 2020-05-22 14:55:32 -07:00
Corey Johnson
d7c933bc40 branchCmd 2020-05-22 14:52:29 -07:00
Corey Johnson
28d8a9e781 Use big D 2020-05-22 14:40:38 -07:00
Corey Johnson
ae70a814bd Update tests 2020-05-20 14:53:52 -07:00
Corey Johnson
904c541d2d Only delete local branch if it exists 2020-05-20 14:19:44 -07:00
Corey Johnson
a303dabc5d Add remote deletion 2020-05-20 13:47:29 -07:00
Corey Johnson
f0cd830170 Fix merge flag
Co-Authored-By: Nate Smith <vilmibm@neongrid.space>
2020-05-12 09:22:37 -07:00
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