aboutsummaryrefslogtreecommitdiffstats
path: root/options.go
diff options
context:
space:
mode:
authorJohn Cai <johncai86@gmail.com>2021-11-01 18:11:08 -0400
committerJohn Cai <jcai@gitlab.com>2021-11-02 18:19:46 -0400
commit7db545b14827462679760b2d584782d69695acf4 (patch)
tree11fb005a0de44b9672e663bb6e785bce1fdd7e33 /options.go
parent3211a7a12a0ec2922d257fb14f09c6ecfb0b7c77 (diff)
downloadgo-git-7db545b14827462679760b2d584782d69695acf4.tar.gz
Add ForceWithLease Push Option
--force-with-lease allows a push to force push with some safety measures. If the ref on the remote is what we expect, then the force push is allowed to happen. See https://git-scm.com/docs/git-push#Documentation/git-push.txt---force-with-leaseltrefnamegt for more information
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 == "" {