Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
ADIOS2
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Podhorszki, Norbert
ADIOS2
Commits
abd8d292
Commit
abd8d292
authored
7 years ago
by
Atkins, Charles Vernon
Browse files
Options
Downloads
Patches
Plain Diff
Allow a regex to exclude files from format checks
parent
4825e586
No related branches found
No related tags found
1 merge request
!82
Add googletest
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
flake8.cfg
+1
-0
1 addition, 0 deletions
flake8.cfg
scripts/developer/git/git-clang-format
+13
-0
13 additions, 0 deletions
scripts/developer/git/git-clang-format
scripts/travis/run-format.sh
+1
-1
1 addition, 1 deletion
scripts/travis/run-format.sh
with
15 additions
and
1 deletion
flake8.cfg
+
1
−
0
View file @
abd8d292
...
...
@@ -3,3 +3,4 @@ max-line-length = 80
max-complexity
= 14
format
= pylint
ignore
= F403,F405,F999
exclude
= thirdparty/
This diff is collapsed.
Click to expand it.
scripts/developer/git/git-clang-format
+
13
−
0
View file @
abd8d292
...
...
@@ -112,6 +112,8 @@ def main():
help
=
'
passed to clang-format
'
),
p
.
add_argument
(
'
-v
'
,
'
--verbose
'
,
action
=
'
count
'
,
default
=
0
,
help
=
'
print extra information
'
)
p
.
add_argument
(
'
-x
'
,
'
--exclude
'
,
help
=
'
Regex to match for files to exclude from checking
'
)
# We gather all the remaining positional arguments into 'args' since we need
# to use some heuristics to determine whether or not <commit> was present.
# However, to print pretty messages, we make use of metavar and help.
...
...
@@ -134,6 +136,7 @@ def main():
changed_lines
=
compute_diff_and_extract_lines
(
commits
,
files
)
if
opts
.
verbose
>=
1
:
ignored_files
=
set
(
changed_lines
)
filter_by_exclude
(
changed_lines
,
opts
.
exclude
)
filter_by_extension
(
changed_lines
,
opts
.
extensions
.
lower
().
split
(
'
,
'
))
if
opts
.
verbose
>=
1
:
ignored_files
.
difference_update
(
changed_lines
)
...
...
@@ -314,6 +317,16 @@ def extract_lines(patch_file):
return
matches
def
filter_by_exclude
(
dictionary
,
exclude_re
):
"""
Delete every key in `dictionary` that matches the exclusion regex.
`exclude_re` must be a valid regex.
"""
exre
=
re
.
compile
(
exclude_re
)
for
filename
in
dictionary
.
keys
():
if
exre
.
match
(
filename
):
del
dictionary
[
filename
]
def
filter_by_extension
(
dictionary
,
allowed_extensions
):
"""
Delete every key in `dictionary` that doesn
'
t have an allowed extension.
...
...
This diff is collapsed.
Click to expand it.
scripts/travis/run-format.sh
+
1
−
1
View file @
abd8d292
...
...
@@ -15,7 +15,7 @@ cd ${SOURCE_DIR}
# Check C and C++ code with clang-format
echo
"Checking formatting for commit range:
${
COMMIT_RANGE
}
"
DIFF
=
"
$(
./scripts/developer/git/git-clang-format
--diff
${
COMMIT_RANGE
}
)
"
DIFF
=
"
$(
./scripts/developer/git/git-clang-format
-x
'^thirdparty/'
--diff
${
COMMIT_RANGE
}
)
"
if
[
-n
"
${
DIFF
}
"
]
&&
[
"
${
DIFF
}
"
!=
"no modified files to format"
]
then
echo
"clang-format:"
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment