-
Notifications
You must be signed in to change notification settings - Fork 373
Standardize repository slug retrieval on single cached implementation #3658
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -104,3 +104,12 @@ func GetCurrentRepoSlug() (string, error) { | |
| repoLog.Printf("Using cached repository slug: %s", currentRepoSlugResult) | ||
| return currentRepoSlugResult, nil | ||
| } | ||
|
|
||
| // SplitRepoSlug splits "owner/repo" into owner and repo | ||
| func SplitRepoSlug(slug string) (owner, repo string, err error) { | ||
| parts := strings.Split(slug, "/") | ||
| if len(parts) != 2 { | ||
| return "", "", fmt.Errorf("invalid repo format: %s", slug) | ||
| } | ||
| return parts[0], parts[1], nil | ||
| } | ||
|
Comment on lines
+109
to
+115
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Variable shadowing issue: the
errvariable from line 600 is shadowed by the:=assignment on line 602. This means ifSplitRepoSlugreturns an error, the outer error check on line 603 will evaluate the wrong error (fromGetCurrentRepoSlug). Usevar currentOwner, currentRepoName stringbefore line 602 and thencurrentOwner, currentRepoName, err = SplitRepoSlug(slug)with=instead of:=.