MCPcopy Index your code
hub / github.com/claude-code-best/claude-code / parseConfigString

Function parseConfigString

src/utils/git/gitConfigParser.ts:36–73  ·  view source on GitHub ↗
(
  config: string,
  section: string,
  subsection: string | null,
  key: string,
)

Source from the content-addressed store, hash-verified

34 * Exported for testing.
35 */
36export function parseConfigString(
37 config: string,
38 section: string,
39 subsection: string | null,
40 key: string,
41): string | null {
42 const lines = config.split('\n')
43 const sectionLower = section.toLowerCase()
44 const keyLower = key.toLowerCase()
45
46 let inSection = false
47 for (const line of lines) {
48 const trimmed = line.trim()
49
50 // Skip empty lines and comment-only lines
51 if (trimmed.length === 0 || trimmed[0] === '#' || trimmed[0] === ';') {
52 continue
53 }
54
55 // Section header
56 if (trimmed[0] === '[') {
57 inSection = matchesSectionHeader(trimmed, sectionLower, subsection)
58 continue
59 }
60
61 if (!inSection) {
62 continue
63 }
64
65 // Key-value line: find the key name
66 const parsed = parseKeyValue(trimmed)
67 if (parsed && parsed.key.toLowerCase() === keyLower) {
68 return parsed.value
69 }
70 }
71
72 return null
73}
74
75/**
76 * Parse a key = value line. Returns null if the line doesn't contain a valid key.

Callers 2

parseGitConfigValueFunction · 0.85

Calls 2

matchesSectionHeaderFunction · 0.85
parseKeyValueFunction · 0.85

Tested by

no test coverage detected