MCPcopy Create free account
hub / github.com/containerd/release-tool / parseVendorConfDependencies

Function parseVendorConfDependencies

util.go:280–324  ·  view source on GitHub ↗
(r io.Reader)

Source from the content-addressed store, hash-verified

278}
279
280func parseVendorConfDependencies(r io.Reader) ([]dependency, error) {
281 var deps []dependency
282 re, err := regexp.Compile("[0-9a-f]{40}")
283 if err != nil {
284 return nil, err
285 }
286
287 s := bufio.NewScanner(r)
288 for s.Scan() {
289 ln := sanitizeLine(s.Text(), "#")
290 if ln == "" {
291 continue
292 }
293 parts := strings.Fields(ln)
294 if len(parts) != 2 && len(parts) != 3 {
295 return nil, fmt.Errorf("invalid config format: %s", ln)
296 }
297
298 var gitURL string
299 if len(parts) == 3 {
300 gitURL = parts[2]
301 } else {
302 gitURL = getGitURL(parts[0])
303 }
304
305 // trim the commit to 12 characters to match go mod length
306 commitOrVersion := parts[1]
307 var sha string
308 if matched := re.Match([]byte(commitOrVersion)); matched {
309 commitOrVersion = commitOrVersion[:12]
310 sha = commitOrVersion
311 }
312
313 deps = append(deps, dependency{
314 Name: parts[0],
315 Ref: commitOrVersion,
316 Sha: sha,
317 GitURL: gitURL,
318 })
319 }
320 if err := s.Err(); err != nil {
321 return nil, err
322 }
323 return deps, nil
324}
325
326func changelog(previous, commit string) ([]*change, error) {
327 raw, err := getChangelog(previous, commit)

Callers 1

parseDependenciesFunction · 0.85

Calls 2

sanitizeLineFunction · 0.85
getGitURLFunction · 0.85

Tested by

no test coverage detected