Simplify routine used to get the list of files from git

This change remove duplicated code
master
Gonzalo Odiard 9 years ago committed by Sam Parkinson
parent 34b0e17e95
commit bbdebce0d4

@ -169,6 +169,7 @@ class Packager(object):
os.mkdir(self.config.dist_dir)
def get_files_in_git(self):
git_ls = None
try:
git_ls = subprocess.Popen(['git', 'ls-files'],
stdout=subprocess.PIPE,
@ -176,17 +177,14 @@ class Packager(object):
except OSError:
logging.warn('Packager: git is not installed, '
'fall back to filtered list')
return list_files(self.config.source_dir,
IGNORE_DIRS, IGNORE_FILES)
if git_ls is not None:
stdout, _ = git_ls.communicate()
if git_ls.returncode:
# Fall back to filtered list
logging.warn('Packager: this is not a git repository, '
'fall back to filtered list')
return list_files(self.config.source_dir,
IGNORE_DIRS, IGNORE_FILES)
if stdout:
elif stdout:
# pylint: disable=E1103
git_output = [path.strip() for path in
stdout.strip('\n').split('\n')]
@ -204,7 +202,7 @@ class Packager(object):
files = [f for f in files if not fnmatch(f, pattern)]
return files
else:
return list_files(self.config.source_dir,
IGNORE_DIRS, IGNORE_FILES)

Loading…
Cancel
Save