MCPcopy
hub / github.com/catppuccin/catppuccin / get_vcs

Function get_vcs

samples/python1.py:69–92  ·  view source on GitHub ↗

Determines root directory for VCS and which of VCS systems should be used for a given directory Returns dictionary {name: .., root: .., cmd: .., dir: ..}

(directory)

Source from the content-addressed store, hash-verified

67
68
69def get_vcs(directory):
70 """
71 Determines root directory for VCS and which of VCS systems should be used for a given directory
72 Returns dictionary {name: .., root: .., cmd: .., dir: ..}
73 """
74
75 vcs_check = [(lambda vcs: lambda dir: os.path.exists(os.path.join(dir, vcs.get('dir', False)))
76 and vcs)(vcs) for vcs in get_vcs_settings()]
77
78 start_directory = directory
79 while directory:
80 available = list(filter(bool, [check(directory) for check in vcs_check]))
81 if available:
82 available[0]['root'] = directory
83 return available[0]
84
85 parent = os.path.realpath(os.path.join(directory, os.path.pardir))
86 if parent == directory: # /.. == /
87 # try TFS as a last resort
88 # I'm not sure why we need to do this. Seems like it should find root for TFS in the main loop
89 return tfs_root(start_directory)
90 directory = parent
91
92 return None
93
94
95def main_thread(callback, *args, **kwargs):

Callers 4

is_enabledMethod · 0.85
runMethod · 0.85
get_working_dirMethod · 0.85
runMethod · 0.85

Calls 2

tfs_rootFunction · 0.85
get_vcs_settingsFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…