Skip to content

Commit e6e5d83

Browse files
committed
Ensure the correct source URL is stored with an install.
Fixes #259
1 parent 35a9ec7 commit e6e5d83

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

src/manage/indexutils.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -225,11 +225,11 @@ def find_to_install(self, tag, *, loose_company=False, prefer_prerelease=False):
225225
tag_list = [tag] if tag else []
226226
LOGGER.debug("Finding %s to install", tag_list)
227227
for i in self.find_all(tag_list, loose_company=loose_company, with_prerelease=prefer_prerelease):
228-
return i
228+
return {**i, "source": self.source_url}
229229
if not loose_company:
230230
return self.find_to_install(tag, loose_company=True, prefer_prerelease=prefer_prerelease)
231231
if not prefer_prerelease:
232232
for i in self.find_all(tag_list, loose_company=loose_company, with_prerelease=True):
233-
return i
233+
return {**i, "source": self.source_url}
234234
LOGGER.debug("No install found for %s", tag_list)
235235
raise LookupError(tag)

src/manage/install_command.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -609,8 +609,9 @@ def _install_one(cmd, source, install, *, target=None):
609609
install["shortcuts"] = shortcuts
610610

611611
install["url"] = sanitise_url(install["url"])
612-
if source != cmd.fallback_source:
613-
install["source"] = sanitise_url(source)
612+
# If there's a non-empty and non-default source, sanitise it
613+
if install.get("source") and install["source"] != cmd.fallback_source:
614+
install["source"] = sanitise_url(install["source"])
614615

615616
LOGGER.debug("Write __install__.json to %s", dest)
616617
with open(dest / "__install__.json", "w", encoding="utf-8") as f:

0 commit comments

Comments
 (0)