Skip to content

Commit 051821e

Browse files
GitHub usernames are case-insensitive but case preserving. This fixes the issue where setting GITHUB_USER to the same characters in a different case, causes the spurious error: "the specified owner <username> doesn't match the identity associated with the given token"
Signed-off-by: Tony Worthit <[email protected]>
1 parent 1d532ae commit 051821e

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

github/client_repositories_user.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import (
2020
"context"
2121
"errors"
2222
"fmt"
23+
"strings"
2324

2425
"github.com/fluxcd/go-git-providers/gitprovider"
2526
)
@@ -108,7 +109,8 @@ func (c *UserRepositoriesClient) Create(ctx context.Context,
108109
return nil, fmt.Errorf("unable to get owner from API")
109110
}
110111

111-
if ref.GetIdentity() != idRef.GetIdentity() {
112+
// GitHub usernames are case insensitive, so compare them with https://pkg.go.dev/strings#EqualFold
113+
if strings.EqualFold(ref.GetIdentity(), idRef.GetIdentity()) {
112114
return nil, gitprovider.NewErrIncorrectUser(ref.GetIdentity())
113115
}
114116

0 commit comments

Comments
 (0)