MCPcopy Create free account
hub / github.com/cli/cli / parseBranchConfig

Function parseBranchConfig

git/client.go:461–484  ·  view source on GitHub ↗
(branchConfigLines []string)

Source from the content-addressed store, hash-verified

459}
460
461func parseBranchConfig(branchConfigLines []string) BranchConfig {
462 var cfg BranchConfig
463
464 // Read the config lines for the specific branch
465 for _, line := range branchConfigLines {
466 parts := strings.SplitN(line, " ", 2)
467 if len(parts) < 2 {
468 continue
469 }
470 keys := strings.Split(parts[0], ".")
471 switch keys[len(keys)-1] {
472 case "remote":
473 cfg.RemoteURL, cfg.RemoteName = parseRemoteURLOrName(parts[1])
474 case "pushremote":
475 cfg.PushRemoteURL, cfg.PushRemoteName = parseRemoteURLOrName(parts[1])
476 case "merge":
477 cfg.MergeRef = parts[1]
478 case MergeBaseConfig:
479 cfg.MergeBase = parts[1]
480 }
481 }
482
483 return cfg
484}
485
486// SetBranchConfig sets the named value on the given branch.
487func (c *Client) SetBranchConfig(ctx context.Context, branch, name, value string) error {

Callers 2

TestParseBranchConfigFunction · 0.85
ReadBranchConfigMethod · 0.85

Calls 1

parseRemoteURLOrNameFunction · 0.85

Tested by 1

TestParseBranchConfigFunction · 0.68