-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Get submodule branch from .gitmodules
- Loading branch information
1 parent
57b942b
commit 639deb7
Showing
6 changed files
with
133 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
// RegExp from: vscode/extensions/git/src/git.ts | ||
const lineSep = /\r?\n/ | ||
const propertyPattern = /^\s*(\w+)\s*=\s*"?([^"]+)"?$/ | ||
const sectionPattern = /^\s*\[\s*([^\]]+?)\s*("[^"]+")*\]\s*$/ | ||
|
||
export function parseGitConfig(config: string): Record<string, string> { | ||
let sectionName = '' | ||
const modulesConfig: Record<string, string> = {} | ||
for (const line of config.split(lineSep)) { | ||
// Sections | ||
const sectionMatch = line.match(sectionPattern) | ||
if (sectionMatch?.length === 3) { | ||
const subSectionName = sectionMatch[2]?.replace(/"/g, '') | ||
sectionName = subSectionName !== undefined | ||
? `${sectionMatch[1]}.${subSectionName}` | ||
: sectionMatch[1] | ||
continue | ||
} | ||
// Properties | ||
const propertyMatch = line.match(propertyPattern) | ||
if (propertyMatch?.length === 3) { | ||
if (sectionName.length === 0) continue | ||
const key = `${sectionName}.${propertyMatch[1]}` | ||
modulesConfig[key] = propertyMatch[2] | ||
} | ||
} | ||
return modulesConfig | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters