summaryrefslogtreecommitdiffstats
path: root/pkg
diff options
context:
space:
mode:
authorStefan Haller <stefan@haller-berlin.de>2024-05-30 21:03:02 +0200
committerStefan Haller <stefan@haller-berlin.de>2024-06-01 08:12:45 +0200
commite93617b1de4b668aa7e4ac4bf483df4d11cf1edb (patch)
treebb80301a41c44a167228098ab713471906aebf6c /pkg
parentaac253510430379b5e74b61899d8f9a708dd80f5 (diff)
Rename Force to ForceWithLease
This describes better what it is, and we're going to add the regular --force in the next commit. No change in behavior in this commit.
Diffstat (limited to 'pkg')
-rw-r--r--pkg/commands/git_commands/sync.go4
-rw-r--r--pkg/commands/git_commands/sync_test.go16
-rw-r--r--pkg/gui/controllers/sync_controller.go10
3 files changed, 15 insertions, 15 deletions
diff --git a/pkg/commands/git_commands/sync.go b/pkg/commands/git_commands/sync.go
index 4ab1f336b..31561455a 100644
--- a/pkg/commands/git_commands/sync.go
+++ b/pkg/commands/git_commands/sync.go
@@ -18,7 +18,7 @@ func NewSyncCommands(gitCommon *GitCommon) *SyncCommands {
// Push pushes to a branch
type PushOpts struct {
- Force bool
+ ForceWithLease bool
UpstreamRemote string
UpstreamBranch string
SetUpstream bool
@@ -30,7 +30,7 @@ func (self *SyncCommands) PushCmdObj(task gocui.Task, opts PushOpts) (oscommands
}
cmdArgs := NewGitCmd("push").
- ArgIf(opts.Force, "--force-with-lease").
+ ArgIf(opts.ForceWithLease, "--force-with-lease").
ArgIf(opts.SetUpstream, "--set-upstream").
ArgIf(opts.UpstreamRemote != "", opts.UpstreamRemote).
ArgIf(opts.UpstreamBranch != "", opts.UpstreamBranch).
diff --git a/pkg/commands/git_commands/sync_test.go b/pkg/commands/git_commands/sync_test.go
index f5f281e14..f1f76415d 100644
--- a/pkg/commands/git_commands/sync_test.go
+++ b/pkg/commands/git_commands/sync_test.go
@@ -18,15 +18,15 @@ func TestSyncPush(t *testing.T) {
scenarios := []scenario{
{
testName: "Push with force disabled",
- opts: PushOpts{Force: false},
+ opts: PushOpts{ForceWithLease: false},
test: func(cmdObj oscommands.ICmdObj, err error) {
assert.Equal(t, cmdObj.Args(), []string{"git", "push"})
assert.NoError(t, err)
},
},
{
- testName: "Push with force enabled",
- opts: PushOpts{Force: true},
+ testName: "Push with force-with-lease enabled",
+ opts: PushOpts{ForceWithLease: true},
test: func(cmdObj oscommands.ICmdObj, err error) {
assert.Equal(t, cmdObj.Args(), []string{"git", "push", "--force-with-lease"})
assert.NoError(t, err)
@@ -35,7 +35,7 @@ func TestSyncPush(t *testing.T) {
{
testName: "Push with force disabled, upstream supplied",
opts: PushOpts{
- Force: false,
+ ForceWithLease: false,
UpstreamRemote: "origin",
UpstreamBranch: "master",
},
@@ -47,7 +47,7 @@ func TestSyncPush(t *testing.T) {
{
testName: "Push with force disabled, setting upstream",
opts: PushOpts{
- Force: false,
+ ForceWithLease: false,
UpstreamRemote: "origin",
UpstreamBranch: "master",
SetUpstream: true,
@@ -58,9 +58,9 @@ func TestSyncPush(t *testing.T) {
},
},
{
- testName: "Push with force enabled, setting upstream",
+ testName: "Push with force-with-lease enabled, setting upstream",
opts: PushOpts{
- Force: true,
+ ForceWithLease: true,
UpstreamRemote: "origin",
UpstreamBranch: "master",
SetUpstream: true,
@@ -73,7 +73,7 @@ func TestSyncPush(t *testing.T) {
{
testName: "Push with remote branch but no origin",
opts: PushOpts{
- Force: true,
+ ForceWithLease: true,
UpstreamRemote: "",
UpstreamBranch: "master",
SetUpstream: true,
diff --git a/pkg/gui/controllers/sync_controller.go b/pkg/gui/controllers/sync_controller.go
index bbea9d64c..d94a49bb1 100644
--- a/pkg/gui/controllers/sync_controller.go
+++ b/pkg/gui/controllers/sync_controller.go
@@ -179,7 +179,7 @@ func (self *SyncController) pullWithLock(task gocui.Task, opts PullFilesOptions)
}
type pushOpts struct {
- force bool
+ forceWithLease bool
upstreamRemote string
upstreamBranch string
setUpstream bool
@@ -197,13 +197,13 @@ func (self *SyncController) pushAux(currentBranch *models.Branch, opts pushOpts)
err := self.c.Git().Sync.Push(
task,
git_commands.PushOpts{
- Force: opts.force,
+ ForceWithLease: opts.forceWithLease,
UpstreamRemote: opts.upstreamRemote,
UpstreamBranch: opts.upstreamBranch,
SetUpstream: opts.setUpstream,
})
if err != nil {
- if !opts.force && strings.Contains(err.Error(), "Updates were rejected") {
+ if !opts.forceWithLease && strings.Contains(err.Error(), "Updates were rejected") {
if opts.remoteBranchStoredLocally {
return errors.New(self.c.Tr.UpdatesRejected)
}
@@ -217,7 +217,7 @@ func (self *SyncController) pushAux(currentBranch *models.Branch, opts pushOpts)
Prompt: self.forcePushPrompt(),
HandleConfirm: func() error {
newOpts := opts
- newOpts.force = true
+ newOpts.forceWithLease = true
return self.pushAux(currentBranch, newOpts)
},
@@ -240,7 +240,7 @@ func (self *SyncController) requestToForcePush(currentBranch *models.Branch, opt
Title: self.c.Tr.ForcePush,
Prompt: self.forcePushPrompt(),
HandleConfirm: func() error {
- opts.force = true
+ opts.forceWithLease = true
return self.pushAux(currentBranch, opts)
},
})