Skip to content

Commit 45472f0

Browse files
committed
rm redundant if and simplify
1 parent 7aea4ab commit 45472f0

1 file changed

Lines changed: 8 additions & 14 deletions

File tree

internal/git/gitops.go

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -187,20 +187,14 @@ func (d *defaultOps) Push(remote string, branches []string, force, atomic bool)
187187
if atomic {
188188
args = append(args, "--atomic")
189189
}
190-
if force {
191-
// Fully-qualified refspecs: refs/heads/<local>:refs/heads/<remote>.
192-
// Qualifying the source (not a bare branch name) ensures a branch
193-
// name is never reinterpreted as refspec syntax — e.g. a leading
194-
// "+" is part of the ref, not a force modifier. Force is supplied
195-
// out-of-band by the --force-with-lease flags above.
196-
for _, b := range branches {
197-
args = append(args, fmt.Sprintf("refs/heads/%s:refs/heads/%s", b, b))
198-
}
199-
} else {
200-
// Fully-qualified refspecs here too, for the same reason.
201-
for _, b := range branches {
202-
args = append(args, fmt.Sprintf("refs/heads/%s:refs/heads/%s", b, b))
203-
}
190+
// Fully-qualified refspecs: refs/heads/<local>:refs/heads/<remote>.
191+
// Qualifying the source (not a bare branch name) ensures a branch name is
192+
// never reinterpreted as refspec syntax — e.g. a leading "+" is part of the
193+
// ref, not a force modifier. This form is identical whether or not the push
194+
// is forced; force is supplied out-of-band by the --force-with-lease flags
195+
// built above.
196+
for _, b := range branches {
197+
args = append(args, fmt.Sprintf("refs/heads/%s:refs/heads/%s", b, b))
204198
}
205199
return runSilent(args...)
206200
}

0 commit comments

Comments
 (0)