aboutsummaryrefslogtreecommitdiffstats
path: root/options.go
diff options
context:
space:
mode:
Diffstat (limited to 'options.go')
-rw-r--r--options.go30
1 files changed, 30 insertions, 0 deletions
diff --git a/options.go b/options.go
index 31ff6e8..95584c2 100644
--- a/options.go
+++ b/options.go
@@ -100,3 +100,33 @@ func (o *FetchOptions) Validate() error {
return nil
}
+
+// PushOptions describe how a push should be performed.
+type PushOptions struct {
+ // RemoteName is the name of the remote to be pushed to.
+ RemoteName string
+ // RefSpecs specify what destination ref to update with what source
+ // object. A refspec with empty src can be used to delete a reference.
+ RefSpecs []config.RefSpec
+}
+
+// Validate validate the fields and set the default values
+func (o *PushOptions) Validate() error {
+ if o.RemoteName == "" {
+ o.RemoteName = DefaultRemoteName
+ }
+
+ if len(o.RefSpecs) == 0 {
+ o.RefSpecs = []config.RefSpec{
+ config.RefSpec(config.DefaultPushRefSpec),
+ }
+ }
+
+ for _, r := range o.RefSpecs {
+ if !r.IsValid() {
+ return ErrInvalidRefSpec
+ }
+ }
+
+ return nil
+}