MCPcopy
hub / github.com/cli/cli / parseBranchConfig

Function parseBranchConfig

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

Source from the content-addressed store, hash-verified

403}
404
405func parseBranchConfig(branchConfigLines []string) BranchConfig {
406 var cfg BranchConfig
407
408 // Read the config lines for the specific branch
409 for _, line := range branchConfigLines {
410 parts := strings.SplitN(line, " ", 2)
411 if len(parts) < 2 {
412 continue
413 }
414 keys := strings.Split(parts[0], ".")
415 switch keys[len(keys)-1] {
416 case "remote":
417 cfg.RemoteURL, cfg.RemoteName = parseRemoteURLOrName(parts[1])
418 case "pushremote":
419 cfg.PushRemoteURL, cfg.PushRemoteName = parseRemoteURLOrName(parts[1])
420 case "merge":
421 cfg.MergeRef = parts[1]
422 case MergeBaseConfig:
423 cfg.MergeBase = parts[1]
424 }
425 }
426
427 return cfg
428}
429
430// SetBranchConfig sets the named value on the given branch.
431func (c *Client) SetBranchConfig(ctx context.Context, branch, name, value string) error {

Callers 2

Test_parseBranchConfigFunction · 0.85
ReadBranchConfigMethod · 0.85

Calls 1

parseRemoteURLOrNameFunction · 0.85

Tested by 1

Test_parseBranchConfigFunction · 0.68