Skip to content

Commit

Permalink
fix: handle broken symbolic links that were listing as missing files
Browse files Browse the repository at this point in the history
  • Loading branch information
Psycojoker committed Jun 7, 2023
1 parent a35f260 commit fe7963c
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
7 changes: 6 additions & 1 deletion check_manifest.py
Original file line number Diff line number Diff line change
Expand Up @@ -961,10 +961,15 @@ def check_manifest(source_tree='.', create=False, update=False,
ui.info_continue(": %d files and directories" % len(sdist_files))
version = extract_version_from_filename(sdist_filename)
existing_source_files = list(filter(os.path.exists, all_source_files))
missing_source_files = sorted(set(all_source_files) - set(existing_source_files))
existing_source_files_with_broken_symlinks = list(filter(os.path.lexists, all_source_files))
missing_source_files = sorted(set(all_source_files) - set(existing_source_files_with_broken_symlinks))
if missing_source_files:
ui.warning("some files listed as being under source control are missing:\n%s"
% format_list(missing_source_files))
broken_symlinks = set(existing_source_files_with_broken_symlinks) - set(existing_source_files)
if broken_symlinks:
ui.warning("some symbolic links listed as being under source control are pointing to missing files:\n%s"
% format_list(["%s -> %s (missing)" % (x, os.readlink(x)) for x in broken_symlinks]))
ui.info_begin("copying source files to a temporary directory")
with mkdtemp('-sources') as tempsourcedir:
copy_files(existing_source_files, tempsourcedir)
Expand Down
18 changes: 18 additions & 0 deletions tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -1815,3 +1815,21 @@ def test_missing_source_files(self):
"some files listed as being under source control are missing:\n"
" missing.py",
sys.stderr.getvalue())

def test_broken_symbolic_link(self):
from check_manifest import check_manifest
self._create_repo_with_code()
os.symlink(os.path.join(self.tmpdir, "some-file"),
os.path.join(self.tmpdir, "some-symbolic-link"))
self._add_to_vcs('some-file')
self._add_to_vcs('some-symbolic-link')
self._add_to_vcs('MANIFEST.in')
with open(os.path.join(self.tmpdir, "MANIFEST.in"), "w") as f:
f.write("include some-symbolic-link\ninclude some-file\n")
self.assertTrue(check_manifest())
self._vcs._commit()
os.unlink('some-file')
check_manifest()
self.assertIn("some symbolic links listed as being under source control are pointing to missing files:\n"
f" some-symbolic-link -> {self.tmpdir}/some-file (missing)",
sys.stderr.getvalue())

0 comments on commit fe7963c

Please sign in to comment.