MCPcopy Create free account
hub / github.com/Noumena-Network/code / parseCommitCloudRc

Function parseCommitCloudRc

src/utils/citcWorkspaceSource.ts:20–52  ·  view source on GitHub ↗
(contents: string)

Source from the content-addressed store, hash-verified

18}
19
20export function parseCommitCloudRc(contents: string): {
21 rawWorkspaceName: string
22 locallyOwned: boolean | null
23} | null {
24 const rawWorkspaceName = contents
25 .split(/\r?\n/u)
26 .map(line => line.trim())
27 .find(line => line.startsWith('current_workspace='))
28 ?.slice('current_workspace='.length)
29 .trim()
30
31 if (!rawWorkspaceName) {
32 return null
33 }
34
35 const locallyOwnedValue = contents
36 .split(/\r?\n/u)
37 .map(line => line.trim())
38 .find(line => line.startsWith('locally_owned='))
39 ?.slice('locally_owned='.length)
40 .trim()
41 .toLowerCase()
42
43 return {
44 rawWorkspaceName,
45 locallyOwned:
46 locallyOwnedValue === 'true'
47 ? true
48 : locallyOwnedValue === 'false'
49 ? false
50 : null,
51 }
52}
53
54export function parseSaplingRepoName(contents: string): string | null {
55 const lines = contents.split(/\r?\n/u).map(line => line.trim())

Calls

no outgoing calls

Tested by

no test coverage detected