MCPcopy Create free account
hub / github.com/AnukarOP/claude-code-leaked / parseConfigString

Function parseConfigString

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

Source from the content-addressed store, hash-verified

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

Callers 1

parseGitConfigValueFunction · 0.85

Calls 2

matchesSectionHeaderFunction · 0.85
parseKeyValueFunction · 0.85

Tested by

no test coverage detected