mirror of
https://github.com/jesseduffield/lazygit.git
synced 2026-09-10 23:56:24 -04:00
Normalize repository owner casing to fix GitHub PR integration (#5495)
### PR Description Close #5494 Normalizes the repository owner to lowercase during the PR mapping. This ensures that PR icons and integration features work correctly even when the local git remote URL casing differs from the official repository casing on GitHub.
This commit is contained in:
commit
38dd035e28
|
|
@ -283,7 +283,7 @@ func GenerateGithubPullRequestMap(
|
|||
prByKey := map[prKey]models.GithubPullRequest{}
|
||||
|
||||
for _, pr := range prs {
|
||||
key := prKey{owner: pr.UserName(), branchName: pr.BranchName()}
|
||||
key := prKey{owner: strings.ToLower(pr.UserName()), branchName: pr.BranchName()}
|
||||
// PRs are returned newest-first from the API, so the first one we
|
||||
// see for each key is the most recent and therefore the most relevant.
|
||||
if _, exists := prByKey[key]; !exists {
|
||||
|
|
@ -307,7 +307,7 @@ func GenerateGithubPullRequestMap(
|
|||
owner = repoInfo.Owner
|
||||
}
|
||||
|
||||
pr, hasPr := prByKey[prKey{owner: owner, branchName: branch.UpstreamBranch}]
|
||||
pr, hasPr := prByKey[prKey{owner: strings.ToLower(owner), branchName: branch.UpstreamBranch}]
|
||||
|
||||
if !hasPr {
|
||||
continue
|
||||
|
|
@ -348,7 +348,7 @@ func (self *GitHubCommands) InGithubRepo(remotes []*models.Remote) bool {
|
|||
}
|
||||
|
||||
url := remote.Urls[0]
|
||||
return strings.Contains(url, "github.com")
|
||||
return strings.Contains(strings.ToLower(url), "github.com")
|
||||
}
|
||||
|
||||
func getMainRemote(remotes []*models.Remote) *models.Remote {
|
||||
|
|
|
|||
|
|
@ -318,6 +318,40 @@ func TestGenerateGithubPullRequestMap(t *testing.T) {
|
|||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "matches when owner casing differs",
|
||||
prs: []*models.GithubPullRequest{
|
||||
{
|
||||
HeadRefName: "fix-case-insensitive",
|
||||
Number: 42,
|
||||
Title: "Fix case insensitive",
|
||||
State: "OPEN",
|
||||
HeadRepositoryOwner: models.GithubRepositoryOwner{Login: "Jesseduffield"}, // Uppercase J
|
||||
},
|
||||
},
|
||||
branches: []*models.Branch{
|
||||
{
|
||||
Name: "fix-case-insensitive",
|
||||
UpstreamRemote: "origin",
|
||||
UpstreamBranch: "fix-case-insensitive",
|
||||
},
|
||||
},
|
||||
remotes: []*models.Remote{
|
||||
{
|
||||
Name: "origin",
|
||||
Urls: []string{"git@github.com:jesseduffield/lazygit.git"}, // Lowercase j
|
||||
},
|
||||
},
|
||||
expected: map[string]*models.GithubPullRequest{
|
||||
"fix-case-insensitive": {
|
||||
HeadRefName: "fix-case-insensitive",
|
||||
Number: 42,
|
||||
Title: "Fix case insensitive",
|
||||
State: "OPEN",
|
||||
HeadRepositoryOwner: models.GithubRepositoryOwner{Login: "Jesseduffield"},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
for _, c := range cases {
|
||||
|
|
|
|||
Loading…
Reference in a new issue