mirror of
https://github.com/appleboy/drone-scp.git
synced 2026-06-04 10:15:05 +08:00
refactor: remove unnecessary quotes in plugin build process (#177)
- Modify `rmcmd` and `mkdircmd` to remove unneeded quotes - Update `buildUnTarArgs` in `plugin.go` to use target without quotes - Add `Exec` function to `plugin.go` with `strings.Replace` call - Update tests in `plugin_test.go` to use target without quotes ref: https://github.com/appleboy/scp-action/issues/112
This commit is contained in:
+6
-6
@@ -615,7 +615,7 @@ func TestPlugin_buildUnTarArgs(t *testing.T) {
|
||||
args: args{
|
||||
target: "foo",
|
||||
},
|
||||
want: []string{"tar", "-zxf", "foo.tar.gz", "-C", "'foo'"},
|
||||
want: []string{"tar", "-zxf", "foo.tar.gz", "-C", "foo"},
|
||||
},
|
||||
{
|
||||
name: "strip components",
|
||||
@@ -631,7 +631,7 @@ func TestPlugin_buildUnTarArgs(t *testing.T) {
|
||||
args: args{
|
||||
target: "foo",
|
||||
},
|
||||
want: []string{"tar", "-zxf", "foo.tar.gz", "--strip-components", "2", "-C", "'foo'"},
|
||||
want: []string{"tar", "-zxf", "foo.tar.gz", "--strip-components", "2", "-C", "foo"},
|
||||
},
|
||||
{
|
||||
name: "overwrite",
|
||||
@@ -647,7 +647,7 @@ func TestPlugin_buildUnTarArgs(t *testing.T) {
|
||||
args: args{
|
||||
target: "foo",
|
||||
},
|
||||
want: []string{"tar", "-zxf", "foo.tar.gz", "--strip-components", "2", "--overwrite", "-C", "'foo'"},
|
||||
want: []string{"tar", "-zxf", "foo.tar.gz", "--strip-components", "2", "--overwrite", "-C", "foo"},
|
||||
},
|
||||
{
|
||||
name: "unlink first",
|
||||
@@ -663,7 +663,7 @@ func TestPlugin_buildUnTarArgs(t *testing.T) {
|
||||
args: args{
|
||||
target: "foo",
|
||||
},
|
||||
want: []string{"tar", "-zxf", "foo.tar.gz", "--strip-components", "2", "--overwrite", "--unlink-first", "-C", "'foo'"},
|
||||
want: []string{"tar", "-zxf", "foo.tar.gz", "--strip-components", "2", "--overwrite", "--unlink-first", "-C", "foo"},
|
||||
},
|
||||
{
|
||||
name: "output folder path with space",
|
||||
@@ -677,9 +677,9 @@ func TestPlugin_buildUnTarArgs(t *testing.T) {
|
||||
DestFile: "foo.tar.gz",
|
||||
},
|
||||
args: args{
|
||||
target: "foo bar",
|
||||
target: "foo\\ bar",
|
||||
},
|
||||
want: []string{"tar", "-zxf", "foo.tar.gz", "--strip-components", "2", "--overwrite", "--unlink-first", "-C", "'foo bar'"},
|
||||
want: []string{"tar", "-zxf", "foo.tar.gz", "--strip-components", "2", "--overwrite", "--unlink-first", "-C", "foo\\ bar"},
|
||||
},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
|
||||
Reference in New Issue
Block a user