Skip to content

Commit 319ca04

Browse files
committed
Show github pull request status against branch
1 parent b856877 commit 319ca04

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

82 files changed

+2807
-452
lines changed

docs/Config.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -336,6 +336,9 @@ git:
336336
# length. Set to 40 to disable truncation.
337337
truncateCopiedCommitHashesTo: 12
338338

339+
# If true and if if `gh` is installed and on version >=2, we will use `gh` to display pull requests against branches.
340+
enableGithubCli: true
341+
339342
# Periodic update checks
340343
update:
341344
# One of: 'prompt' (default) | 'background' | 'never'

go.mod

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ require (
66
github.com/adrg/xdg v0.4.0
77
github.com/atotto/clipboard v0.1.4
88
github.com/aybabtme/humanlog v0.4.1
9+
github.com/cli/go-gh/v2 v2.9.0
910
github.com/cloudfoundry/jibber_jabber v0.0.0-20151120183258-bcc4c8345a21
1011
github.com/creack/pty v1.1.11
1112
github.com/gdamore/tcell/v2 v2.7.4
@@ -46,6 +47,7 @@ require (
4647
require (
4748
github.com/bahlo/generic-list-go v0.2.0 // indirect
4849
github.com/buger/jsonparser v1.1.1 // indirect
50+
github.com/cli/safeexec v1.0.0 // indirect
4951
github.com/davecgh/go-spew v1.1.1 // indirect
5052
github.com/emirpasic/gods v1.12.0 // indirect
5153
github.com/fatih/color v1.9.0 // indirect
@@ -62,8 +64,8 @@ require (
6264
github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515 // indirect
6365
github.com/kylelemons/godebug v1.1.0 // indirect
6466
github.com/mailru/easyjson v0.7.7 // indirect
65-
github.com/mattn/go-colorable v0.1.11 // indirect
66-
github.com/mattn/go-isatty v0.0.14 // indirect
67+
github.com/mattn/go-colorable v0.1.13 // indirect
68+
github.com/mattn/go-isatty v0.0.20 // indirect
6769
github.com/mitchellh/go-homedir v1.1.0 // indirect
6870
github.com/onsi/ginkgo v1.10.3 // indirect
6971
github.com/onsi/gomega v1.7.1 // indirect
@@ -73,8 +75,8 @@ require (
7375
github.com/sergi/go-diff v1.1.0 // indirect
7476
github.com/wk8/go-ordered-map/v2 v2.1.8 // indirect
7577
github.com/xanzy/ssh-agent v0.2.1 // indirect
76-
golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa // indirect
77-
golang.org/x/net v0.7.0 // indirect
78+
golang.org/x/crypto v0.14.0 // indirect
79+
golang.org/x/net v0.17.0 // indirect
7880
golang.org/x/sys v0.19.0 // indirect
7981
golang.org/x/term v0.19.0 // indirect
8082
golang.org/x/text v0.14.0 // indirect

go.sum

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,10 @@ github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA
5959
github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI=
6060
github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI=
6161
github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU=
62+
github.com/cli/go-gh/v2 v2.9.0 h1:D3lTjEneMYl54M+WjZ+kRPrR5CEJ5BHS05isBPOV3LI=
63+
github.com/cli/go-gh/v2 v2.9.0/go.mod h1:MeRoKzXff3ygHu7zP+NVTT+imcHW6p3tpuxHAzRM2xE=
64+
github.com/cli/safeexec v1.0.0 h1:0VngyaIyqACHdcMNWfo6+KdUYnqEr2Sg+bSP1pdF+dI=
65+
github.com/cli/safeexec v1.0.0/go.mod h1:Z/D4tTN8Vs5gXYHDCbaM1S/anmEDnJb1iW0+EJ5zx3Q=
6266
github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw=
6367
github.com/cloudfoundry/jibber_jabber v0.0.0-20151120183258-bcc4c8345a21 h1:tuijfIjZyjZaHq9xDUh0tNitwXshJpbLkqMOJv4H3do=
6468
github.com/cloudfoundry/jibber_jabber v0.0.0-20151120183258-bcc4c8345a21/go.mod h1:po7NpZ/QiTKzBKyrsEAxwnTamCoh8uDk/egRpQ7siIc=
@@ -228,13 +232,14 @@ github.com/mailru/easyjson v0.7.7 h1:UGYAvKxe3sBsEDzO8ZeWOSlIQfWFlxbzLZe7hwFURr0
228232
github.com/mailru/easyjson v0.7.7/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJJLY9Nlc=
229233
github.com/mattn/go-colorable v0.1.0/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU=
230234
github.com/mattn/go-colorable v0.1.4/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE=
231-
github.com/mattn/go-colorable v0.1.11 h1:nQ+aFkoE2TMGc0b68U2OKSexC+eq46+XwZzWXHRmPYs=
232-
github.com/mattn/go-colorable v0.1.11/go.mod h1:u5H1YNBxpqRaxsYJYSkiCWKzEfiAb1Gb520KVy5xxl4=
235+
github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA=
236+
github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg=
233237
github.com/mattn/go-isatty v0.0.4/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4=
234238
github.com/mattn/go-isatty v0.0.8/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s=
235239
github.com/mattn/go-isatty v0.0.11/go.mod h1:PhnuNfih5lzO57/f3n+odYbM4JtupLOxQOAqxQCu2WE=
236-
github.com/mattn/go-isatty v0.0.14 h1:yVuAays6BHfxijgZPzw+3Zlu5yQgKGP2/hcQbHb7S9Y=
237-
github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94=
240+
github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM=
241+
github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY=
242+
github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
238243
github.com/mattn/go-runewidth v0.0.15 h1:UNAjwbU9l54TA3KzvqLGxwWjHmMgBUVhBiTjelZgg3U=
239244
github.com/mattn/go-runewidth v0.0.15/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w=
240245
github.com/mgutz/str v1.2.0 h1:4IzWSdIz9qPQWLfKZ0rJcV0jcUDpxvP4JVZ4GXQyvSw=
@@ -326,8 +331,9 @@ golang.org/x/crypto v0.0.0-20200302210943-78000ba7a073/go.mod h1:LzIPMQfyMNhhGPh
326331
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
327332
golang.org/x/crypto v0.0.0-20210421170649-83a5a9bb288b/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4=
328333
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
329-
golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa h1:zuSxTR4o9y82ebqCUJYNGJbGPo6sKVl54f/TVDObg1c=
330334
golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
335+
golang.org/x/crypto v0.14.0 h1:wBqGXzWJW6m1XrIKlAH0Hs1JJ7+9KBwnIO8v66Q9cHc=
336+
golang.org/x/crypto v0.14.0/go.mod h1:MVFd36DqK4CsrnJYDkBA3VC4m2GkXAM0PvzMCn4JQf4=
331337
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
332338
golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
333339
golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8=
@@ -400,8 +406,8 @@ golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v
400406
golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
401407
golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
402408
golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs=
403-
golang.org/x/net v0.7.0 h1:rJrUqqhjsgNp7KqAIc25s9pZnjU7TUcSY7HcVZjdn1g=
404-
golang.org/x/net v0.7.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs=
409+
golang.org/x/net v0.17.0 h1:pVaXccu2ozPjCXewfr1S7xza/zcXTity9cCdXQYSjIM=
410+
golang.org/x/net v0.17.0/go.mod h1:NxSsAGuq816PNPmqtQdLE42eU2Fs7NoRIZrHJAlaCOE=
405411
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
406412
golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
407413
golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
@@ -467,12 +473,12 @@ golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7w
467473
golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
468474
golang.org/x/sys v0.0.0-20210423185535-09eb48e85fd7/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
469475
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
470-
golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
471-
golang.org/x/sys v0.0.0-20210927094055-39ccf1dd6fa6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
472476
golang.org/x/sys v0.0.0-20211025201205-69cdffdb9359/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
473477
golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
474478
golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
479+
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
475480
golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
481+
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
476482
golang.org/x/sys v0.17.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
477483
golang.org/x/sys v0.19.0 h1:q5f1RH2jigJ1MoAWp2KTp3gm5zAGFUTarQZ5U386+4o=
478484
golang.org/x/sys v0.19.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=

pkg/app/app_test.go

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
package app
2+
3+
import (
4+
"testing"
5+
6+
"github.com/stretchr/testify/assert"
7+
)
8+
9+
func TestIsValidGhVersion(t *testing.T) {
10+
type scenario struct {
11+
versionStr string
12+
expectedResult bool
13+
}
14+
15+
scenarios := []scenario{
16+
{
17+
"",
18+
false,
19+
},
20+
{
21+
`gh version 1.0.0 (2020-08-23)
22+
https://github.com/cli/cli/releases/tag/v1.0.0`,
23+
false,
24+
},
25+
{
26+
`gh version 2.0.0 (2021-08-23)
27+
https://github.com/cli/cli/releases/tag/v2.0.0`,
28+
true,
29+
},
30+
{
31+
`gh version 1.1.0 (2021-10-14)
32+
https://github.com/cli/cli/releases/tag/v1.1.0
33+
34+
A new release of gh is available: 1.1.0 → v2.2.0
35+
To upgrade, run: brew update && brew upgrade gh
36+
https://github.com/cli/cli/releases/tag/v2.2.0`,
37+
false,
38+
},
39+
}
40+
41+
for _, s := range scenarios {
42+
t.Run(s.versionStr, func(t *testing.T) {
43+
result := isGhVersionValid(s.versionStr)
44+
assert.Equal(t, result, s.expectedResult)
45+
})
46+
}
47+
}

pkg/commands/git.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ type GitCommand struct {
3838
Worktree *git_commands.WorktreeCommands
3939
Version *git_commands.GitVersion
4040
RepoPaths *git_commands.RepoPaths
41+
GitHub *git_commands.GitHubCommands
42+
HostingService *git_commands.HostingService
4143

4244
Loaders Loaders
4345
}
@@ -133,6 +135,8 @@ func NewGitCommandAux(
133135
bisectCommands := git_commands.NewBisectCommands(gitCommon)
134136
worktreeCommands := git_commands.NewWorktreeCommands(gitCommon)
135137
blameCommands := git_commands.NewBlameCommands(gitCommon)
138+
gitHubCommands := git_commands.NewGitHubCommand(gitCommon)
139+
hostingServiceCommands := git_commands.NewHostingServiceCommand(gitCommon)
136140

137141
branchLoader := git_commands.NewBranchLoader(cmn, gitCommon, cmd, branchCommands.CurrentBranchInfo, configCommands)
138142
commitFileLoader := git_commands.NewCommitFileLoader(cmn, cmd)
@@ -164,6 +168,8 @@ func NewGitCommandAux(
164168
WorkingTree: workingTreeCommands,
165169
Worktree: worktreeCommands,
166170
Version: version,
171+
GitHub: gitHubCommands,
172+
HostingService: hostingServiceCommands,
167173
Loaders: Loaders{
168174
BranchLoader: branchLoader,
169175
CommitFileLoader: commitFileLoader,

0 commit comments

Comments
 (0)