Simplify commandString
Use the same logic for both go and non-go actions. This also has a slight performance improvement for go actions by allocating the slice in advance instead of using append() Test: Presubmits Change-Id: I92b60c547d8470816a67ac1ef6e334fd5f547701
This commit is contained in:
parent
c70be4b986
commit
b378c18ddf
1 changed files with 13 additions and 18 deletions
|
@ -443,26 +443,21 @@ func (a *aqueryArtifactHandler) depsetContentHashes(inputDepsetIds []uint32) ([]
|
||||||
|
|
||||||
// escapes the args received from aquery and creates a command string
|
// escapes the args received from aquery and creates a command string
|
||||||
func commandString(actionEntry *analysis_v2_proto.Action) string {
|
func commandString(actionEntry *analysis_v2_proto.Action) string {
|
||||||
switch actionEntry.Mnemonic {
|
argsEscaped := make([]string, len(actionEntry.Arguments))
|
||||||
case "GoCompilePkg", "GoStdlib":
|
for i, arg := range actionEntry.Arguments {
|
||||||
argsEscaped := []string{}
|
if arg == "" {
|
||||||
for _, arg := range actionEntry.Arguments {
|
// If this is an empty string, add ''
|
||||||
if arg == "" {
|
// And not
|
||||||
// If this is an empty string, add ''
|
// 1. (literal empty)
|
||||||
// And not
|
// 2. `''\'''\'''` (escaped version of '')
|
||||||
// 1. (literal empty)
|
//
|
||||||
// 2. `''\'''\'''` (escaped version of '')
|
// If we had used (1), then this would appear as a whitespace when we strings.Join
|
||||||
//
|
argsEscaped[i] = "''"
|
||||||
// If we had used (1), then this would appear as a whitespace when we strings.Join
|
} else {
|
||||||
argsEscaped = append(argsEscaped, "''")
|
argsEscaped[i] = proptools.ShellEscapeIncludingSpaces(arg)
|
||||||
} else {
|
|
||||||
argsEscaped = append(argsEscaped, proptools.ShellEscapeIncludingSpaces(arg))
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return strings.Join(argsEscaped, " ")
|
|
||||||
default:
|
|
||||||
return strings.Join(proptools.ShellEscapeListIncludingSpaces(actionEntry.Arguments), " ")
|
|
||||||
}
|
}
|
||||||
|
return strings.Join(argsEscaped, " ")
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *aqueryArtifactHandler) normalActionBuildStatement(actionEntry *analysis_v2_proto.Action) (*BuildStatement, error) {
|
func (a *aqueryArtifactHandler) normalActionBuildStatement(actionEntry *analysis_v2_proto.Action) (*BuildStatement, error) {
|
||||||
|
|
Loading…
Reference in a new issue