-
Notifications
You must be signed in to change notification settings - Fork 7
/
fixes.go
59 lines (54 loc) · 1.07 KB
/
fixes.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
package p4
import (
"fmt"
)
// Fix is a single fix from p4 fixes result
type Fix struct {
Code string
Change string
Client string
Date string // seconds since epoch
Job string
Status string
User string
}
// Fixes is all of the results from p4 fixes
type Fixes []Fix
// RunFixes runs p4 fixes args...
func RunFixes(p4r Runner, args []string) ([]Fix, error) {
args = append([]string{"fixes"}, args...)
res, err := p4r.Run(args)
if err != nil {
return nil, fmt.Errorf("Failed to run p4 %s\n%v", args, err)
}
fs := Fixes{}
for _, r := range res {
f := Fix{}
if v, ok := r["code"]; ok {
f.Code = v.(string)
if f.Code == "error" {
return nil, parseError(r)
}
}
if v, ok := r["Change"]; ok {
f.Change = v.(string)
}
if v, ok := r["Client"]; ok {
f.Client = v.(string)
}
if v, ok := r["Date"]; ok {
f.Date = v.(string)
}
if v, ok := r["Job"]; ok {
f.Job = v.(string)
}
if v, ok := r["Status"]; ok {
f.Status = v.(string)
}
if v, ok := r["User"]; ok {
f.User = v.(string)
}
fs = append(fs, f)
}
return fs, nil
}