@@ -29,8 +29,16 @@ import (
29
29
"strings"
30
30
)
31
31
32
- func newP4Command (params ... string ) * shell.Command {
33
- return shell .NewCommand ("p4" , params ... )
32
+ func init () {
33
+ shell .NewCommandFunc = shell .NewCommand
34
+ }
35
+
36
+ func newP4Command (params ... string ) shell.Command {
37
+ return shell .NewCommandFunc ("p4" , params ... )
38
+ }
39
+
40
+ func newP4CommandImpl (params ... string ) * shell.CommandImpl {
41
+ return shell .NewCommandImpl ("p4" , params ... )
34
42
}
35
43
36
44
// IsP4CommandAvailable indicates if p4 command is available on local machine
@@ -52,7 +60,7 @@ func GetP4CommandVersion() string {
52
60
scanner := bufio .NewScanner (bytes .NewReader (p4Output ))
53
61
for scanner .Scan () {
54
62
if strings .Index (scanner .Text (), "Rev." ) == 0 {
55
- return strings .SplitAfter (scanner .Text (), "Rev. " )[1 ]
63
+ return strings .Split (scanner .Text (), " " )[1 ]
56
64
}
57
65
}
58
66
return ""
@@ -65,7 +73,8 @@ func GetP4UserName() string {
65
73
66
74
func getP4ConfigValue (variable string ) string {
67
75
p4Output , err := runP4Command ("set" , "-q" , variable )
68
- if err != nil || p4Output == nil || len (p4Output ) == 0 {
76
+
77
+ if err != nil || p4Output == nil || len (bytes .Trim (p4Output , "\r \n " )) == 0 {
69
78
return "not set"
70
79
}
71
80
scanner := bufio .NewScanner (bytes .NewReader (p4Output ))
@@ -84,11 +93,11 @@ func runP4Command(params ...string) (output []byte, err error) {
84
93
}
85
94
86
95
// tracePipedP4Command calls p4 command, pipes it to pipedTo command, and reports its output traces
87
- func tracePipedP4Command (pipedTo * shell.Command , params ... string ) error {
96
+ func tracePipedP4Command (pipedTo shell.Command , params ... string ) error {
88
97
return newP4Command ().TraceAndPipe (pipedTo , params ... )
89
98
}
90
99
91
100
// runPipedP4Command calls p4 command, pipes it to pipedTo command, and reports its output traces
92
- func runPipedP4Command (pipedTo * shell.Command , params ... string ) (output []byte , err error ) {
101
+ func runPipedP4Command (pipedTo shell.Command , params ... string ) (output []byte , err error ) {
93
102
return newP4Command ().RunAndPipe (pipedTo , params ... )
94
103
}
0 commit comments