Simplify routine used to get the list of files from git
This change remove duplicated code
This commit is contained in:
parent
34b0e17e95
commit
bbdebce0d4
@ -169,6 +169,7 @@ class Packager(object):
|
|||||||
os.mkdir(self.config.dist_dir)
|
os.mkdir(self.config.dist_dir)
|
||||||
|
|
||||||
def get_files_in_git(self):
|
def get_files_in_git(self):
|
||||||
|
git_ls = None
|
||||||
try:
|
try:
|
||||||
git_ls = subprocess.Popen(['git', 'ls-files'],
|
git_ls = subprocess.Popen(['git', 'ls-files'],
|
||||||
stdout=subprocess.PIPE,
|
stdout=subprocess.PIPE,
|
||||||
@ -176,17 +177,14 @@ class Packager(object):
|
|||||||
except OSError:
|
except OSError:
|
||||||
logging.warn('Packager: git is not installed, '
|
logging.warn('Packager: git is not installed, '
|
||||||
'fall back to filtered list')
|
'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()
|
stdout, _ = git_ls.communicate()
|
||||||
if git_ls.returncode:
|
if git_ls.returncode:
|
||||||
# Fall back to filtered list
|
# Fall back to filtered list
|
||||||
logging.warn('Packager: this is not a git repository, '
|
logging.warn('Packager: this is not a git repository, '
|
||||||
'fall back to filtered list')
|
'fall back to filtered list')
|
||||||
return list_files(self.config.source_dir,
|
elif stdout:
|
||||||
IGNORE_DIRS, IGNORE_FILES)
|
|
||||||
if stdout:
|
|
||||||
# pylint: disable=E1103
|
# pylint: disable=E1103
|
||||||
git_output = [path.strip() for path in
|
git_output = [path.strip() for path in
|
||||||
stdout.strip('\n').split('\n')]
|
stdout.strip('\n').split('\n')]
|
||||||
@ -204,7 +202,7 @@ class Packager(object):
|
|||||||
files = [f for f in files if not fnmatch(f, pattern)]
|
files = [f for f in files if not fnmatch(f, pattern)]
|
||||||
|
|
||||||
return files
|
return files
|
||||||
else:
|
|
||||||
return list_files(self.config.source_dir,
|
return list_files(self.config.source_dir,
|
||||||
IGNORE_DIRS, IGNORE_FILES)
|
IGNORE_DIRS, IGNORE_FILES)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user