MCPcopy Create free account
hub / github.com/danvk/webdiff / contains_symlinks

Function contains_symlinks

webdiff/dirdiff.py:13–27  ·  view source on GitHub ↗

Check whether a directory contains any symlinks. If it does, then git diff --no-index will not handle it in the way that we'd like. It will diff the target file names rather than their contents. To work around this we need to follow the symlinks. Since this might be expensive, we'd

(dir: str)

Source from the content-addressed store, hash-verified

11
12
13def contains_symlinks(dir: str):
14 """Check whether a directory contains any symlinks.
15
16 If it does, then git diff --no-index will not handle it in the way that we'd
17 like. It will diff the target file names rather than their contents. To work
18 around this we need to follow the symlinks. Since this might be expensive,
19 we'd like to avoid that if possible.
20 """
21 for root, _dirs, files in os.walk(dir):
22 # (git difftool should not produce directory symlinks)
23 for file_name in files:
24 file_path = os.path.join(root, file_name)
25 if os.path.islink(file_path):
26 return True
27 return False
28
29
30def make_resolved_dir(dir: str, follow_symlinks=False) -> str:

Callers 1

gitdiffFunction · 0.85

Calls 1

walkMethod · 0.80

Tested by

no test coverage detected