Make git push options accept short name (#32245)
Just like what most CLI parsers do: `--opt` means `opt=true` Then users could use `-o force-push` as `-o force-push=true`
This commit is contained in:
parent
900ac62251
commit
afa8dd45af
7 changed files with 149 additions and 44 deletions
30
modules/private/pushoptions_test.go
Normal file
30
modules/private/pushoptions_test.go
Normal file
|
@ -0,0 +1,30 @@
|
|||
// Copyright 2024 The Gitea Authors. All rights reserved.
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
package private
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func TestGitPushOptions(t *testing.T) {
|
||||
o := GitPushOptions{}
|
||||
|
||||
v := o.Bool("no-such")
|
||||
assert.False(t, v.Has())
|
||||
assert.False(t, v.Value())
|
||||
|
||||
o.AddFromKeyValue("opt1=a=b")
|
||||
o.AddFromKeyValue("opt2=false")
|
||||
o.AddFromKeyValue("opt3=true")
|
||||
o.AddFromKeyValue("opt4")
|
||||
|
||||
assert.Equal(t, "a=b", o["opt1"])
|
||||
assert.False(t, o.Bool("opt1").Value())
|
||||
assert.True(t, o.Bool("opt2").Has())
|
||||
assert.False(t, o.Bool("opt2").Value())
|
||||
assert.True(t, o.Bool("opt3").Value())
|
||||
assert.True(t, o.Bool("opt4").Value())
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue