aboutsummaryrefslogtreecommitdiffstats
path: root/options.go
diff options
context:
space:
mode:
authorMáximo Cuadros <mcuadros@gmail.com>2021-12-10 06:44:42 +0100
committerGitHub <noreply@github.com>2021-12-10 06:44:42 +0100
commit152fefc2179ad63e4936eda644a77b84a44a6eab (patch)
tree651b84e5b41f4a19a444f22b7ad12e671cba1dd5 /options.go
parent605e273ea37d638802cd96f955d55ace59c1ce9b (diff)
parent7db545b14827462679760b2d584782d69695acf4 (diff)
downloadgo-git-152fefc2179ad63e4936eda644a77b84a44a6eab.tar.gz
Merge pull request #404 from john-cai/jc-force-with-lease
Remote: Push, add ForceWithLease Push Option
Diffstat (limited to 'options.go')
-rw-r--r--options.go15
1 files changed, 15 insertions, 0 deletions
diff --git a/options.go b/options.go
index e54889f..fee2e16 100644
--- a/options.go
+++ b/options.go
@@ -228,10 +228,25 @@ type PushOptions struct {
// FollowTags will send any annotated tags with a commit target reachable from
// the refs already being pushed
FollowTags bool
+ // ForceWithLease allows a force push as long as the remote ref adheres to a "lease"
+ ForceWithLease *ForceWithLease
// PushOptions sets options to be transferred to the server during push.
Options map[string]string
}
+// ForceWithLease sets fields on the lease
+// If neither RefName nor Hash are set, ForceWithLease protects
+// all refs in the refspec by ensuring the ref of the remote in the local repsitory
+// matches the one in the ref advertisement.
+type ForceWithLease struct {
+ // RefName, when set will protect the ref by ensuring it matches the
+ // hash in the ref advertisement.
+ RefName plumbing.ReferenceName
+ // Hash is the expected object id of RefName. The push will be rejected unless this
+ // matches the corresponding object id of RefName in the refs advertisement.
+ Hash plumbing.Hash
+}
+
// Validate validates the fields and sets the default values.
func (o *PushOptions) Validate() error {
if o.RemoteName == "" {