-
Notifications
You must be signed in to change notification settings - Fork 326
Adding usage of git_create_remote_detached #755
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: main
Are you sure you want to change the base?
Conversation
f61dc59 to
db7fcff
Compare
lhchavez
left a comment
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.
thanks for the change!
| } | ||
|
|
||
| func TestRemoteDetached_LsDetached(t *testing.T) { | ||
| r, _ := NewRemoteDetached(TestGitRepoUri) |
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.
| r, _ := NewRemoteDetached(TestGitRepoUri) | |
| remote, err := NewRemoteDetached(TestGitRepoUri) | |
| checkFatal(t, err) | |
| defer remote.Free() |
for consistency with other tests that create remotes (and to avoid memory leaks)
| return nil, MakeGitError(ret) | ||
| } | ||
|
|
||
| return &RemoteDetached{r: Remote{ptr: ptr}}, nil |
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.
would it be possible for this to return the *Remote directly? That way the RemoteDetached and the LsDetached shouldn't be needed, since callers can interact with the remote using the normal API, which will avoid having to implement more APIs on RemoteDetached that would only forward arguments to the underlying Remote. It's totally fine if the repo property is nil: it's just there to avoid the GC from deleting the Repository when the Remote is still around, but here it will be nil.
also, the finalizer for the Remote object must be set prior to returning to avoid memory leaks:
Lines 586 to 587 in 75708ee
| runtime.SetFinalizer(remote, (*Remote).Free) | |
| return remote, nil |
This creates a
RemoteDetachedtype that is instantiable with a remote uri string. It has only one method,LsDetachedfor emulatinggit ls-remote <remote-uri>.The reason for this is that it looks like there is no other way to simply do a
git ls-remotetype request without creating a repository reference locally.Thank you for your time in reviewing this.