mirror of
https://github.com/jesseduffield/lazygit.git
synced 2026-09-13 00:56:25 -04:00
split logic into functions
This commit is contained in:
parent
aed7c29509
commit
153970fb08
|
|
@ -2,7 +2,6 @@ package commands
|
|||
|
||||
import (
|
||||
"encoding/json"
|
||||
"strings"
|
||||
|
||||
"github.com/jesseduffield/lazygit/pkg/commands/models"
|
||||
)
|
||||
|
|
@ -47,13 +46,12 @@ func (c *GitCommand) GenerateGithubPullRequestMap(prs []*models.GithubPullReques
|
|||
continue
|
||||
}
|
||||
|
||||
remoteAndName := strings.SplitN(branch.UpstreamName, "/", 2)
|
||||
owner, foundRemoteOwner := remotesToOwnersMap[remoteAndName[0]]
|
||||
if len(remoteAndName) != 2 || !foundRemoteOwner {
|
||||
owner, foundRemoteOwner := remotesToOwnersMap[branch.RemoteName()]
|
||||
if branch.BranchName() == "" || !foundRemoteOwner {
|
||||
continue
|
||||
}
|
||||
|
||||
pr, hasPr := prWithStringKey[owner+":"+remoteAndName[1]]
|
||||
pr, hasPr := prWithStringKey[owner+":"+branch.BranchName()]
|
||||
if !hasPr {
|
||||
continue
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
package models
|
||||
|
||||
import "strings"
|
||||
|
||||
// Branch : A git branch
|
||||
// duplicating this for now
|
||||
type Branch struct {
|
||||
|
|
@ -47,3 +49,15 @@ func (b *Branch) HasCommitsToPull() bool {
|
|||
func (b *Branch) IsRealBranch() bool {
|
||||
return b.Pushables != "" && b.Pullables != ""
|
||||
}
|
||||
func (b *Branch) RemoteName() string {
|
||||
return strings.SplitN(b.UpstreamName, "/", 2)[0]
|
||||
}
|
||||
|
||||
func (b *Branch) BranchName() string {
|
||||
remoteAndBranch := strings.SplitN(b.UpstreamName, "/", 2)
|
||||
if len(remoteAndBranch) != 2 {
|
||||
return ""
|
||||
}
|
||||
|
||||
return strings.SplitN(b.UpstreamName, "/", 2)[1]
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue