Skip to content

Commit 469a4a1

Browse files
authored
Merge pull request #94 from chennes/removeTrailingSlash
Remove trailing slash from URL in Zip extraction
2 parents 14b6739 + 83ef07f commit 469a4a1

File tree

3 files changed

+26
-15
lines changed

3 files changed

+26
-15
lines changed

AddonManagerTest/app/test_installer.py

Lines changed: 22 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -166,19 +166,28 @@ def test_code_in_branch_subdirectory_more_than_one(self):
166166

167167
def test_move_code_out_of_subdirectory(self):
168168
"""All files are moved out and the subdirectory is deleted"""
169-
self.mock_addon.url = "https://something.com/something_else/something"
170-
installer = AddonInstaller(self.mock_addon, [])
171-
with tempfile.TemporaryDirectory() as temp_dir:
172-
subdir = os.path.join(temp_dir, f"something-{self.mock_addon.branch}")
173-
os.mkdir(subdir)
174-
with open(os.path.join(subdir, "README.txt"), "w", encoding="utf-8") as f:
175-
f.write("# Test file for unit testing")
176-
with open(os.path.join(subdir, "AnotherFile.txt"), "w", encoding="utf-8") as f:
177-
f.write("# Test file for unit testing")
178-
installer._move_code_out_of_subdirectory(temp_dir)
179-
self.assertTrue(os.path.isfile(os.path.join(temp_dir, "README.txt")))
180-
self.assertTrue(os.path.isfile(os.path.join(temp_dir, "AnotherFile.txt")))
181-
self.assertFalse(os.path.isdir(subdir))
169+
test_urls = [
170+
"https://something.com/something_else/something",
171+
"https://something.com/something_else/something.git",
172+
"https://something.com/something_else/something/",
173+
"https://something.com/something_else/something.git/",
174+
]
175+
for url in test_urls:
176+
with self.subTest(url=url):
177+
self.mock_addon.url = url
178+
installer = AddonInstaller(self.mock_addon, [])
179+
# TODO: Someday use a mock filesystem instead of a temp dir
180+
with tempfile.TemporaryDirectory() as temp_dir:
181+
subdir = os.path.join(temp_dir, f"something-{self.mock_addon.branch}")
182+
os.mkdir(subdir)
183+
with open(os.path.join(subdir, "README.txt"), "w", encoding="utf-8") as f:
184+
f.write("# Test file for unit testing")
185+
with open(os.path.join(subdir, "AnotherFile.txt"), "w", encoding="utf-8") as f:
186+
f.write("# Test file for unit testing")
187+
installer._move_code_out_of_subdirectory(temp_dir)
188+
self.assertTrue(os.path.isfile(os.path.join(temp_dir, "README.txt")))
189+
self.assertTrue(os.path.isfile(os.path.join(temp_dir, "AnotherFile.txt")))
190+
self.assertFalse(os.path.isdir(subdir))
182191

183192
def test_install_by_git(self):
184193
"""Test using git to install. Depends on there being a local git

addonmanager_installer.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -419,6 +419,8 @@ def _code_in_branch_subdirectory(self, destination: str) -> bool:
419419

420420
def _expected_subdirectory_name(self) -> str:
421421
url = self.addon_to_install.url
422+
if url.endswith("/"):
423+
url = url[:-1]
422424
if url.endswith(".git"):
423425
url = url[:-4]
424426
_, _, name = url.rpartition("/")

package.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
<name>AddonManager</name>
66
<description>Tool to install workbenches, macros, themes, etc.</description>
77
<icon>resources/icons/addon_manager.svg</icon>
8-
<version>2025.05.01a</version>
9-
<date>2025-05-01</date>
8+
<version>2025.06.01</version>
9+
<date>2025-06-01</date>
1010
<maintainer email='chennes@freecad.org'>Chris Hennes</maintainer>
1111
<author email = 'yorik@uncreated.net'>Yorik van Havre</author>
1212
<author>Jonathan Wiedemann</author>

0 commit comments

Comments
 (0)