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)
| 11 | |
| 12 | |
| 13 | def 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 | |
| 30 | def make_resolved_dir(dir: str, follow_symlinks=False) -> str: |