| 452 | } |
| 453 | |
| 454 | func 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 | |
| 491 | func MapRemoteURL(url string, push bool) (string, bool) { |
| 492 | urls, err := RemoteURLs(push) |