[FEAT] Allow non-explicit push options
- Currently the parsing of the push options require that `=` is present in the value, however we shouldn't be that strict and assume if that's not set the value is `true`. - This allow for more natural commands, so become `-o force-push=true` simply `-o force-push`. - Add unit test.
This commit is contained in:
parent
7d35a76ebf
commit
f5ad6d4be5
3 changed files with 24 additions and 7 deletions
|
@ -15,6 +15,7 @@ import (
|
|||
"testing"
|
||||
"time"
|
||||
|
||||
"code.gitea.io/gitea/modules/private"
|
||||
"code.gitea.io/gitea/modules/setting"
|
||||
"code.gitea.io/gitea/modules/test"
|
||||
|
||||
|
@ -162,3 +163,17 @@ func TestDelayWriter(t *testing.T) {
|
|||
require.Empty(t, out)
|
||||
})
|
||||
}
|
||||
|
||||
func TestPushOptions(t *testing.T) {
|
||||
require.NoError(t, os.Setenv(private.GitPushOptionCount, "3"))
|
||||
require.NoError(t, os.Setenv("GIT_PUSH_OPTION_0", "force-push"))
|
||||
require.NoError(t, os.Setenv("GIT_PUSH_OPTION_1", "option=value"))
|
||||
require.NoError(t, os.Setenv("GIT_PUSH_OPTION_2", "option-double=another=value"))
|
||||
require.NoError(t, os.Setenv("GIT_PUSH_OPTION_3", "not=valid"))
|
||||
|
||||
assert.Equal(t, map[string]string{
|
||||
"force-push": "true",
|
||||
"option": "value",
|
||||
"option-double": "another=value",
|
||||
}, pushOptions())
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue