MCPcopy
hub / github.com/git-lfs/git-lfs / RemoteURLs

Function RemoteURLs

git/git.go:454–489  ·  view source on GitHub ↗
(push bool)

Source from the content-addressed store, hash-verified

452}
453
454func RemoteURLs(push bool) (map[string][]string, error) {
455 cmd, err := gitNoLFS("remote", "-v")
456 if err != nil {
457 return nil, errors.New(tr.Tr.Get("failed to find `git remote -v`: %v", err))
458 }
459
460 outp, err := cmd.StdoutPipe()
461 if err != nil {
462 return nil, errors.New(tr.Tr.Get("failed to call `git remote -v`: %v", err))
463 }
464 cmd.Start()
465 defer cmd.Wait()
466
467 scanner := bufio.NewScanner(outp)
468
469 text := "(fetch)"
470 if push {
471 text = "(push)"
472 }
473 ret := make(map[string][]string)
474 for scanner.Scan() {
475 // [remote, urlpair-text]
476 pair := strings.Split(strings.TrimSpace(scanner.Text()), "\t")
477 if len(pair) != 2 {
478 continue
479 }
480 // [url, "(fetch)" | "(push)"]
481 urlpair := strings.Split(pair[1], " ")
482 if len(urlpair) != 2 || urlpair[1] != text {
483 continue
484 }
485 ret[pair[0]] = append(ret[pair[0]], urlpair[0])
486 }
487
488 return ret, nil
489}
490
491func MapRemoteURL(url string, push bool) (string, bool) {
492 urls, err := RemoteURLs(push)

Callers 2

MapRemoteURLFunction · 0.85
TestRemoteURLsFunction · 0.85

Calls 7

NewFunction · 0.92
gitNoLFSFunction · 0.85
StdoutPipeMethod · 0.80
GetMethod · 0.65
WaitMethod · 0.65
ScanMethod · 0.65
StartMethod · 0.45

Tested by 1

TestRemoteURLsFunction · 0.68