-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathdescribe.go
63 lines (58 loc) · 1.3 KB
/
describe.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
60
61
62
63
package p4
import (
"log"
"strconv"
)
// Description has the describe result of a single changelist.
type Description struct {
Change string
User string
Describe string
ChangeType string
Path string
Client string
Time string
Status string
DepotFiles []*File
}
func (d *Description) String() string {
return d.Describe
}
func (conn *Conn) Describe(number uint64) (desc *Description, err error) {
var (
results []Result
)
if results, err = conn.RunMarshaled("describe", []string{strconv.FormatUint(number, 10)}); err != nil {
return
}
for idx := range results {
if d, ok := results[idx].(*Description); !ok {
log.Printf("type translate err: %s", results[idx])
continue
} else {
// Get the first valid describe result and return it.
desc = d
return
}
}
return
}
func (conn *Conn) DescribeShelved(number uint64) (desc *Description, err error) {
var (
results []Result
)
if results, err = conn.RunMarshaled("describe", []string{"-S", "-s", strconv.FormatUint(number, 10)}); err != nil {
return
}
for idx := range results {
if d, ok := results[idx].(*Description); !ok {
log.Printf("type translate err: %s", results[idx])
continue
} else {
// Get the first valid describe result and return it.
desc = d
return
}
}
return
}