aboutsummaryrefslogtreecommitdiffstats
path: root/options.go
diff options
context:
space:
mode:
authorSantiago M. Mola <santi@mola.io>2016-12-19 23:36:44 +0100
committerMáximo Cuadros <mcuadros@gmail.com>2016-12-19 23:36:44 +0100
commit90d67bb648ae32d5b1a0f7b1af011da6dfb24315 (patch)
treefc8c14e82974be6ff49e842328ec3206ebf1b4c2 /options.go
parent725ade0de6f60549e65cc4d94094b1f5ed48587f (diff)
downloadgo-git-90d67bb648ae32d5b1a0f7b1af011da6dfb24315.tar.gz
remote: add Push (#178)
* remote: add Push. * add Push method to Remote. * add method Push to Repository. * examples: add push example. * requested changes * add tests, fixes
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
+}