Skip to content

Commit

Permalink
Fixes to TimothyEarley's pull about config for ignored files.
Browse files Browse the repository at this point in the history
  • Loading branch information
svetlyak40wt committed Oct 27, 2016
1 parent 479b4c3 commit 4b2d935
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 13 deletions.
1 change: 1 addition & 0 deletions .ignored_files → .dotignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# List of files to be ignored, not copied
# these are case insencetive
readme.*
news
licence
Expand Down
26 changes: 13 additions & 13 deletions bin/lib/dot/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,21 +137,21 @@ def process(*lines):
def create_tree_from_filesystem(base_dir, envs):
ignored_dirs = {'.git'}
# read ignored files from file.
ignored_files_config = os.path.join(base_dir, '.ignored_files')
if (os.path.isfile(ignored_files_config)):
ignored_files_list = []
# This just reads every line and adds it to the regex directly, so probably will break with some input.
for line in open(ignored_files_config, 'r'):
file_name = line.rstrip() # remove whitespace and newlines
if (file_name and not file_name.startswith('#')): #check if line is empty and not a comment
ignored_files_list.append(file_name)
ignored_files = '(' + "|".join(ignored_files_list) + ')$' #format for regex
else:
# default
ignored_files = ur'(readme.*|news|licence|license|changelog.*|.gitignore|tags)$'
ignored_files_config = os.path.join(base_dir, '.dotignore')
ignored_files = []

if os.path.isfile(ignored_files_config):
with open(ignored_files_config) as f:
for line in f:
file_name = line.rstrip()
# we only add non empty files and ignore comments starting with #
if file_name and not file_name.startswith('#'):
ignored_files.append(file_name)

ignored_files = '(' + "|".join(ignored_files) + ')$' #format for regex
ignored_files_re = re.compile(ignored_files, re.I)
base_dir_len = len(base_dir)

base_dir_len = len(base_dir)
text = u''
for env in envs:
env_path = os.path.join(base_dir, env)
Expand Down

0 comments on commit 4b2d935

Please sign in to comment.