Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
v3: replace go-git direct dependency with system git CLI #5520
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
base: master
Are you sure you want to change the base?
Uh oh!
There was an error while loading. Please reload this page.
v3: replace go-git direct dependency with system git CLI #5520
Changes from all commits
16adc58File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
There are no files selected for viewing
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.
Redact git arguments before embedding them in errors.
strings.Join(args, " ")can expose credentials/tokens whenurlcontains embedded auth (e.g.,https://token@host/...) inClone/RemoteAddfailures. Return a sanitized command string instead.Suggested fix
Also applies to: 36-37
🤖 Prompt for AI Agents
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.
Guard short hash output before slicing.
hash[:8]can panic if output is unexpectedly shorter than 8 chars. Add a length check and return an error instead.Suggested fix
func HeadHash(dir string) (string, error) { hash, err := output("-C", dir, "rev-parse", "HEAD") if err != nil { return "", err } + if len(hash) < 8 { + return "", fmt.Errorf("git rev-parse returned short hash %q", hash) + } return hash[:8], nil }🤖 Prompt for AI Agents
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.
Use an OS-agnostic missing path in
TestInit_Error."/nonexistent_wails_test_path_xyz"is platform-specific and can be flaky. Build a guaranteed-missing path undert.TempDir()instead.Suggested fix
func TestInit_Error(t *testing.T) { // git -C on a non-existent path fails - if err := Init("/nonexistent_wails_test_path_xyz"); err == nil { + missing := filepath.Join(t.TempDir(), "does-not-exist") + if err := Init(missing); err == nil { t.Fatal("expected error for nonexistent path") } }📝 Committable suggestion
🤖 Prompt for AI Agents
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.
🧩 Analysis chain
🏁 Script executed:
Repository: wailsapp/wails
Length of output: 407
🏁 Script executed:
Repository: wailsapp/wails
Length of output: 50459
🏁 Script executed:
Repository: wailsapp/wails
Length of output: 50371
🏁 Script executed:
Repository: wailsapp/wails
Length of output: 8285
Fix remote template
@refparsing for SCP-like SSH URLs.v3/internal/templates/templates.gousesstrings.SplitN(uri, "@", 2)and treats the suffix as the git ref passed togit clone --branch. For an SSH/SCP-style template likegit@github.com:user/repo.git@v1.0.0, this incorrectly setsurl="git"andtag="github.com:user/repo.git@v1.0.0".Use “split on the last
@” and only accept the suffix as a ref when it’s actually a ref (e.g., the suffix shouldn’t still look like SCP host/path by containing:), rather than blindly splitting on the first@.🤖 Prompt for AI Agents
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.
Temp directory not cleaned up when clone fails.
If
git.Clonefails,gitclonereturns the temp directory path along with the error. The caller'scleanupfunction is defined only aftergitclonesucceeds, so failed clones leave orphaned temp directories.🛠️ Proposed fix
func gitclone(uri string) (string, error) { dirname, err := os.MkdirTemp("", "wails-template-*") if err != nil { return "", err } parts := strings.SplitN(uri, "@", 2) url, tag := parts[0], "" if len(parts) > 1 { tag = parts[1] } - return dirname, git.Clone(url, dirname, tag) + if err := git.Clone(url, dirname, tag); err != nil { + os.RemoveAll(dirname) + return "", err + } + return dirname, nil }📝 Committable suggestion
🤖 Prompt for AI Agents
Uh oh!
There was an error while loading. Please reload this page.