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
git: remote, fix default remote name #1009
base: master
Are you sure you want to change the base?
Conversation
remote.go
Outdated
@@ -101,7 +101,7 @@ func (r *Remote) Push(o *PushOptions) error { | |||
// operation is complete, an error is returned. The context only affects the | |||
// transport operations. | |||
func (r *Remote) PushContext(ctx context.Context, o *PushOptions) (err error) { | |||
if err := o.Validate(); err != nil { | |||
if err := o.Validate(r.c.Name); err != 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.
Instead of changing PushOptions.Validate why didn't you go for the simpler solution of doing:
if err := o.Validate(r.c.Name); err != nil { | |
// If the PushOptions don't have a remote name set - just default them to this remote for ease of use | |
if o.RemoteName == "" { | |
o.RemoteName = r.c.Name | |
} | |
if err := o.Validate(); err != nil { |
Then this PR would reduce considerably in size.
One issue with both of these approaches is that the PushOptions are passed in as a pointer so any changes here permanently change the object meaning that if the PushOptions are reused then the result will be different depending on who used them first.
This isn't ideal and perhaps indicates that the Valdate option shouldn't really be changing the struct or it should be returning a duplicate with the default values set, but given that it does it might be that this PR may be inadvisable.
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.
I've got you point. I will change.
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.
Another option: don't use RemoteName
from PushOptions at all. Or create RemotePushOption
struct without RemoteName
field.
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.
Can anyone help me with failed tests?
Hi!
I had used this package in my project and found this annoying issue. I have a
Remote
with specific name and have to provide it again inPushOptions
.