Skip to content

Commit 6adab90

Browse files
ishanSrtMakman2
authored andcommitted
.coafile: Fix ignore files field not created
* Convert generator to list (it was getting exhausted before). * Remove an if statement which would always evaluate to False. * Add a test case for ignore_globs. Fixes #157, Fixes #173
1 parent 50b358a commit 6adab90

File tree

3 files changed

+35
-2
lines changed

3 files changed

+35
-2
lines changed

coala_quickstart/generation/FileGlobs.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ def get_project_files(log_printer,
4949
file_path_completer.deactivate()
5050
printer.print()
5151

52+
ignore_globs = list(ignore_globs)
5253
escaped_project_dir = glob_escape(project_dir)
5354
file_path_globs = [os.path.join(
5455
escaped_project_dir, glob_exp) for glob_exp in file_globs]

coala_quickstart/generation/Settings.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,7 @@ def generate_ignore_field(project_dir,
6161
for glob in ignore_globs:
6262
gitignore_files = {file
6363
for file in collect_files([glob], null_printer)}
64-
if not all_files.isdisjoint(gitignore_files):
65-
ignores.append(os.path.relpath(glob, project_dir))
64+
ignores.append(os.path.relpath(glob, project_dir))
6665

6766
return ", ".join(ignores)
6867

tests/generation/SettingsTest.py

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,13 @@
1616

1717
class SettingsTest(unittest.TestCase):
1818

19+
def path_leaf(self, path):
20+
"""
21+
:return: The file name from the given path.
22+
"""
23+
head, tail = os.path.split(path)
24+
return tail or os.path.basename(head)
25+
1926
def setUp(self):
2027
self.project_dir = os.getcwd()
2128
self.printer = ConsolePrinter()
@@ -42,6 +49,32 @@ def test_write_info(self):
4249

4350
self.assertEqual(result_comment, line)
4451

52+
def test_allow_complete_section_mode_with_ignore_globs(self):
53+
project_dir = "/repo"
54+
project_files = ['/repo/hello.html']
55+
ignore_globs = ["/repo/style.css"]
56+
used_languages = list(get_used_languages(project_files))
57+
relevant_bears = filter_relevant_bears(
58+
used_languages, self.printer, self.arg_parser, {})
59+
60+
res = generate_settings(
61+
project_dir, project_files, ignore_globs, relevant_bears, {}, True)
62+
63+
bears_list = res["all.HTML"]["bears"].value.replace(" ", "").split(",")
64+
65+
files_list = res["all.HTML"]["files"].value.replace(" ", "").split(",")
66+
67+
self.assertEqual(
68+
['HTMLLintBear', 'coalaBear', 'BootLintBear',
69+
'LicenseCheckBear', 'SpaceConsistencyBear', 'KeywordBear',
70+
'LineLengthBear', 'DuplicateFileBear'].sort(),
71+
bears_list.sort())
72+
73+
ignore_file = str(os.path.normpath(self.path_leaf(
74+
str(res["all"]["ignore"]))))
75+
self.assertEqual(['**.html'], files_list)
76+
self.assertEqual('style.css', ignore_file)
77+
4578
def test_allow_complete_section_mode(self):
4679
project_dir = "/repo"
4780
project_files = ['/repo/hello.html']

0 commit comments

Comments
 (0)