File tree Expand file tree Collapse file tree 2 files changed +37
-3
lines changed
pkg/commands/git_commands Expand file tree Collapse file tree 2 files changed +37
-3
lines changed Original file line number Diff line number Diff line change @@ -283,7 +283,7 @@ func GenerateGithubPullRequestMap(
283283 prByKey := map [prKey ]models.GithubPullRequest {}
284284
285285 for _ , pr := range prs {
286- key := prKey {owner : pr .UserName (), branchName : pr .BranchName ()}
286+ key := prKey {owner : strings . ToLower ( pr .UserName () ), branchName : pr .BranchName ()}
287287 // PRs are returned newest-first from the API, so the first one we
288288 // see for each key is the most recent and therefore the most relevant.
289289 if _ , exists := prByKey [key ]; ! exists {
@@ -307,7 +307,7 @@ func GenerateGithubPullRequestMap(
307307 owner = repoInfo .Owner
308308 }
309309
310- pr , hasPr := prByKey [prKey {owner : owner , branchName : branch .UpstreamBranch }]
310+ pr , hasPr := prByKey [prKey {owner : strings . ToLower ( owner ) , branchName : branch .UpstreamBranch }]
311311
312312 if ! hasPr {
313313 continue
@@ -348,7 +348,7 @@ func (self *GitHubCommands) InGithubRepo(remotes []*models.Remote) bool {
348348 }
349349
350350 url := remote .Urls [0 ]
351- return strings .Contains (url , "github.com" )
351+ return strings .Contains (strings . ToLower ( url ) , "github.com" )
352352}
353353
354354func getMainRemote (remotes []* models.Remote ) * models.Remote {
Original file line number Diff line number Diff line change @@ -318,6 +318,40 @@ func TestGenerateGithubPullRequestMap(t *testing.T) {
318318 },
319319 },
320320 },
321+ {
322+ name : "matches when owner casing differs" ,
323+ prs : []* models.GithubPullRequest {
324+ {
325+ HeadRefName : "fix-case-insensitive" ,
326+ Number : 42 ,
327+ Title : "Fix case insensitive" ,
328+ State : "OPEN" ,
329+ HeadRepositoryOwner : models.GithubRepositoryOwner {Login : "Jesseduffield" }, // Uppercase J
330+ },
331+ },
332+ branches : []* models.Branch {
333+ {
334+ Name : "fix-case-insensitive" ,
335+ UpstreamRemote : "origin" ,
336+ UpstreamBranch : "fix-case-insensitive" ,
337+ },
338+ },
339+ remotes : []* models.Remote {
340+ {
341+ Name : "origin" ,
342+ Urls : []string {"git@github.com:jesseduffield/lazygit.git" }, // Lowercase j
343+ },
344+ },
345+ expected : map [string ]* models.GithubPullRequest {
346+ "fix-case-insensitive" : {
347+ HeadRefName : "fix-case-insensitive" ,
348+ Number : 42 ,
349+ Title : "Fix case insensitive" ,
350+ State : "OPEN" ,
351+ HeadRepositoryOwner : models.GithubRepositoryOwner {Login : "Jesseduffield" },
352+ },
353+ },
354+ },
321355 }
322356
323357 for _ , c := range cases {
You can’t perform that action at this time.
0 commit comments