OLD | NEW |
1 // Copyright 2016 The LUCI Authors. All rights reserved. | 1 // Copyright 2016 The LUCI Authors. All rights reserved. |
2 // Use of this source code is governed under the Apache License, Version 2.0 | 2 // Use of this source code is governed under the Apache License, Version 2.0 |
3 // that can be found in the LICENSE file. | 3 // that can be found in the LICENSE file. |
4 | 4 |
5 package main | 5 package main |
6 | 6 |
7 import ( | 7 import ( |
8 "os" | 8 "os" |
9 "os/exec" | 9 "os/exec" |
10 "path/filepath" | 10 "path/filepath" |
(...skipping 30 matching lines...) Expand all Loading... |
41 } | 41 } |
42 | 42 |
43 if t.pathMap == nil { | 43 if t.pathMap == nil { |
44 t.pathMap = make(map[string]string) | 44 t.pathMap = make(map[string]string) |
45 } | 45 } |
46 t.pathMap[command] = path | 46 t.pathMap[command] = path |
47 } | 47 } |
48 | 48 |
49 if path == "" { | 49 if path == "" { |
50 // Lookup was attempted, but tool could not be found. | 50 // Lookup was attempted, but tool could not be found. |
51 » » return "", errors.Reason("tool %(toolName)q is not available").D
("toolName", command).Err() | 51 » » return "", errors.Reason("tool %q is not available", command).Er
r() |
52 } | 52 } |
53 return path, nil | 53 return path, nil |
54 } | 54 } |
55 | 55 |
56 func (t *tools) genericTool(name string) (*genericTool, error) { | 56 func (t *tools) genericTool(name string) (*genericTool, error) { |
57 exe, err := t.getLookup(name) | 57 exe, err := t.getLookup(name) |
58 if err != nil { | 58 if err != nil { |
59 return nil, err | 59 return nil, err |
60 } | 60 } |
61 return &genericTool{ | 61 return &genericTool{ |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
166 | 166 |
167 func (t *gitTool) getRevListCount(c context.Context, gitDir string) (int, error)
{ | 167 func (t *gitTool) getRevListCount(c context.Context, gitDir string) (int, error)
{ |
168 x := t.exec(gitDir, "rev-list", "--count", "HEAD") | 168 x := t.exec(gitDir, "rev-list", "--count", "HEAD") |
169 if err := x.check(c); err != nil { | 169 if err := x.check(c); err != nil { |
170 return 0, err | 170 return 0, err |
171 } | 171 } |
172 | 172 |
173 output := strings.TrimSpace(x.stdout.String()) | 173 output := strings.TrimSpace(x.stdout.String()) |
174 v, err := strconv.Atoi(output) | 174 v, err := strconv.Atoi(output) |
175 if err != nil { | 175 if err != nil { |
176 » » return 0, errors.Annotate(err).Reason("failed to parse rev-list
count").D("output", output).Err() | 176 » » return 0, errors.Annotate(err, "failed to parse rev-list count")
. |
| 177 » » » InternalReason("output(%s)", output).Err() |
177 } | 178 } |
178 return v, nil | 179 return v, nil |
179 } | 180 } |
180 | 181 |
181 type goTool struct { | 182 type goTool struct { |
182 exe string | 183 exe string |
183 goPath []string | 184 goPath []string |
184 } | 185 } |
185 | 186 |
186 func (t *goTool) exec(subCommand string, args ...string) *workExecutor { | 187 func (t *goTool) exec(subCommand string, args ...string) *workExecutor { |
(...skipping 23 matching lines...) Expand all Loading... |
210 } | 211 } |
211 | 212 |
212 type gcloudTool struct { | 213 type gcloudTool struct { |
213 exe string | 214 exe string |
214 project string | 215 project string |
215 } | 216 } |
216 | 217 |
217 func (t *gcloudTool) exec(command string, args ...string) *workExecutor { | 218 func (t *gcloudTool) exec(command string, args ...string) *workExecutor { |
218 return execute(t.exe, append([]string{"--project", t.project, command},
args...)...) | 219 return execute(t.exe, append([]string{"--project", t.project, command},
args...)...) |
219 } | 220 } |
OLD | NEW |