MCPcopy Create free account
hub / github.com/Kong/insomnia / getTreeMap

Method getTreeMap

packages/insomnia/src/sync/git/git-vcs.ts:1631–1657  ·  view source on GitHub ↗
(oid: string)

Source from the content-addressed store, hash-verified

1629 }
1630
1631 async getTreeMap(oid: string): Promise<Record<string, git.TreeEntry>> {
1632 const { commit } = await git.readCommit({ ...this._baseOpts, oid });
1633 const { tree } = await git.readTree({ ...this._baseOpts, oid: commit.tree });
1634
1635 const treeMap: Record<string, git.TreeEntry> = {};
1636
1637 const baseOpts = this._baseOpts;
1638
1639 async function walkTree(entries: ArrayIterator<git.TreeEntry>, prefix = '') {
1640 for (const entry of entries) {
1641 const filepath = path.posix.join(prefix, entry.path);
1642 if (entry.type === 'tree') {
1643 const { tree: subtree } = await git.readTree({ ...baseOpts, oid: entry.oid });
1644 await walkTree(subtree.values(), filepath);
1645 } else if (entry.type === 'blob') {
1646 treeMap[filepath] = entry;
1647 }
1648 }
1649 }
1650
1651 await walkTree(tree.values());
1652
1653 // Return the tree map with file paths as keys and git.TreeEntry as values
1654 // This allows us to easily check for conflicts between local and remote trees
1655 // and to extract file contents when needed
1656 return treeMap;
1657 }
1658
1659 extractConflictParts(content: any) {
1660 const regex = /^<<<<<<< .*\n([\s\S]*?)^=======\n([\s\S]*?)^>>>>>>> .*/gm;

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected