Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions pkg/github/repositories.go
Original file line number Diff line number Diff line change
Expand Up @@ -402,6 +402,8 @@ func CreateOrUpdateFile(getClient GetClientFn, t translations.TranslationHelperF
if err != nil {
return nil, nil, fmt.Errorf("failed to get GitHub client: %w", err)
}

path = strings.TrimPrefix(path, "/")
Copy link

Copilot AI Dec 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The GetFileContents function also accepts a path parameter that is passed directly to client.Repositories.GetContents() and rawClient.GetRawContent() at lines 619 and 639. For consistency and to prevent similar failures, consider adding path = strings.TrimPrefix(path, "/") after the path parameter is extracted (around line 600).

Copilot uses AI. Check for mistakes.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • [ ]

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • [ ]

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • [ ]

Copy link

Copilot AI Dec 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The DeleteFile function also accepts a path parameter that is used in a TreeEntry at line 950. For consistency and to prevent similar failures, consider adding path = strings.TrimPrefix(path, "/") after the path parameter is extracted (around line 920).

Copilot uses AI. Check for mistakes.
Copy link

Copilot AI Dec 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider adding a test case in Test_CreateOrUpdateFile that verifies a path with a leading slash is handled correctly. This would document the auto-correction behavior and prevent regressions.

Copilot uses AI. Check for mistakes.
fileContent, resp, err := client.Repositories.CreateFile(ctx, owner, repo, path, opts)
if err != nil {
return ghErrors.NewGitHubAPIErrorResponse(ctx,
Expand Down