Skip to content

Commit e484750

Browse files
author
Richard Lee
committed
Fix logic error preventing github integration.
Need to check return code of rfind() for errors to avoid screwing up the match check for a match on the following line, which eventually leads to an invalid JSON exception.
1 parent 248f579 commit e484750

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

ide/tests/test_find_project_root.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,3 +103,12 @@ def test_ignore_invalid_package_file(self):
103103
"src/main.c",
104104
"appinfo.json"
105105
], "", "appinfo.json")
106+
107+
def test_PR_317(self):
108+
""" PR 317 fixes a bug where find_project_root would fail with 11 character filenames """
109+
self.run_test([
110+
"MAINTAINERS",
111+
"package.json",
112+
"src/"
113+
"src/main.c",
114+
], "", "package.json")

ide/utils/project.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,8 @@ def find_project_root_and_manifest(project_items):
5656
# Check if the file is one of the kinds of manifest file
5757
for name in MANIFEST_KINDS:
5858
dir_end = base_dir.rfind(name)
59+
if dir_end == -1:
60+
continue
5961
# Ensure that the file is actually a manifest file
6062
if dir_end + len(name) == len(base_dir):
6163
if is_manifest(name, item.read()):

0 commit comments

Comments
 (0)