Skip to content
Snippets Groups Projects
Commit ba03508f authored by Bienchen's avatar Bienchen
Browse files

Extended pre-commit hook

parent 299804d9
No related branches found
No related tags found
No related merge requests found
......@@ -133,7 +133,7 @@ def _GetFileType(filepath):
"'_GetFileType'. Output of 'file %s' was '%s'" % (filepath,
fout), 12)
def GetModifiedFiles(exclude):
def GetModifiedFiles(exclude, committed_only=True):
"""
Get the list of modified files in a commit. Files are sorted into a
dictionary of lists according to file type. If a file of unknown type is
......@@ -144,6 +144,9 @@ def GetModifiedFiles(exclude):
be excluded from being checked.
:type exclude: :class:`list` of :class:`str`
:param committed_only: Only return files marked for comit.
:type committed_only: :class:`bool`
:returns: :class:`dict` of :class:`list` of :class:`str`, with file types
as keys and file names as items in the lists.
"""
......@@ -183,6 +186,11 @@ def GetModifiedFiles(exclude):
if status_line[0] == '??':
# file is not tracked by repo, ignore
continue
if committed_only:
if line[0] == ' ':
# Files marked for commit should have 'M'/ 'A' in the first
# column. If its left empty, skip
continue
tfp = os.path.join(cdup, status_line[-1])
skip = False
for ex_re in re_excludes:
......
......@@ -20,7 +20,8 @@ WHITESPACECHECK_EXCLUDES = [r'.*\.pdf', r'.*\.pdb']
## files like documentation as HTML files.
EXCLUDE_COMPLETELY = [r'^doc/html/.*\.html', r'^doc/html/.*\.js',
r'^doc/html/.*\.inv', r'^doc/html/.*\.txt']
PYCODECHECK_EXCLUDES = ['extras/pre_commit/pre-commit','doc/cmake.py']
PYCODECHECK_EXCLUDES = ['extras/pre_commit/pre-commit','doc/cmake.py',
'core/pymod/__init__.py.in']
ALLOW_LONG_LINES = ['extras/pre_commit/pm3_csc/filecheck/pylint-unittest-rc',
'extras/pre_commit/pm3_csc/filecheck/pylintrc']
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment