Skip to content

Commit

Permalink
Merge pull request #142 from fosslight/develop2
Browse files Browse the repository at this point in the history
Modify condition to exclude git ignore file
  • Loading branch information
bjk7119 authored Mar 15, 2023
2 parents 59f4374 + 2bf15e4 commit 28bbbf5
Showing 1 changed file with 13 additions and 14 deletions.
27 changes: 13 additions & 14 deletions src/fosslight_prechecker/_precheck.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,20 +52,19 @@ def exclude_gitignore_files(current_path, path):
global DEFAULT_EXCLUDE_EXTENSION_FILES
try:
root_path = VCSStrategyGit.find_root(current_path)
if os.path.isfile(os.path.join(root_path, '.gitignore')):
cmd_result = subprocess.check_output(['git',
'ls-files',
'-ci',
'--exclude-from=.gitignore'],
universal_newlines=True)
cmd_result = cmd_result.split('\n')
cmd_result.remove('')
if not path.endswith(f"{os.sep}"):
path += f"{os.sep}"
cmd_result = [file.replace(path, '', 1) for file in cmd_result]
DEFAULT_EXCLUDE_EXTENSION_FILES.extend(cmd_result)
else:
return
if root_path:
if os.path.isfile(os.path.join(root_path, '.gitignore')):
cmd_result = subprocess.check_output(['git',
'ls-files',
'-ci',
'--exclude-from=.gitignore'],
universal_newlines=True)
cmd_result = cmd_result.split('\n')
cmd_result.remove('')
if not path.endswith(f"{os.sep}"):
path += f"{os.sep}"
cmd_result = [file.replace(path, '', 1) for file in cmd_result]
DEFAULT_EXCLUDE_EXTENSION_FILES.extend(cmd_result)
except Exception as ex:
logger.warning(f"Error to get git ignored files : {ex}")

Expand Down

0 comments on commit 28bbbf5

Please sign in to comment.