IAP GITLAB
Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
corsika
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository 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
Air Shower Physics
corsika
Commits
cb2e0552
Commit
cb2e0552
authored
5 years ago
by
Hans Dembinski
Browse files
Options
Downloads
Patches
Plain Diff
fix
parent
234365c4
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!160
Better do clang format
Pipeline
#935
failed
5 years ago
Stage: config
Stage: build_test
Stage: optional
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
do-clang-format.py
+54
-15
54 additions, 15 deletions
do-clang-format.py
with
54 additions
and
15 deletions
do-clang-format.py
+
54
−
15
View file @
cb2e0552
#!/bin/bash
command
=
"
clang-format -style=file `find . -iregex
'
^.*\.\(cc\|h\)$
'
-not -path
'
./ThirdParty/*
'
`
"
if
[
"
$1
"
==
"
check
"
];
then
`! ${command} -output-replacements-xml | grep -qc "<replacement "`
||
\
{
echo
"
format-check FAILED!
"
;
exit
1
;
}
echo
"
Congratulations: format-check succeeded
"
elif
[
"
$1
"
==
"
apply
"
];
then
$
{
command
}
-
i
else
echo
"
please use: ./do-clang-format.sh [check] or [apply]
"
fi
#!/usr/bin/env python3
"""
Run clang-format with the style file in the CORSIKA repository.
By default it finds new files and files with modifications with respect to the current master and prints
the filenames which need clang-formatting. Returns 1 if there are files with need modifications and 0 otherwise.
"""
import
argparse
import
subprocess
as
subp
import
os
import
sys
parser
=
argparse
.
ArgumentParser
(
description
=
__doc__
)
parser
.
add_argument
(
'
--apply
'
,
action
=
"
store_true
"
,
help
=
"
Apply clang-format to files which need changes.
"
)
parser
.
add_argument
(
"
--all
"
,
action
=
"
store_true
"
,
help
=
"
Check all files below current path instead of new/modified.
"
)
args
=
parser
.
parse_args
()
filelist
=
[]
if
args
.
all
:
for
dirpath
,
dirnames
,
filenames
in
os
.
walk
(
"
.
"
):
if
"
ThirdParty
"
in
dirpath
:
continue
for
f
in
filenames
:
if
f
.
endswith
(
"
.h
"
)
or
f
.
endswith
(
"
.cc
"
):
filename
=
os
.
path
.
join
(
dirpath
,
f
)
if
not
os
.
path
.
islink
(
filename
):
filelist
.
append
(
filename
)
if
not
filelist
:
raise
SystemExit
(
"
Error: You specified --all, but file list is empty. Did you run from the build directory?
"
)
else
:
cmd
=
"
git diff master --name-status
"
for
line
in
subp
.
check_output
(
cmd
,
shell
=
True
).
decode
(
"
utf8
"
).
strip
().
split
(
"
\n
"
):
if
line
.
startswith
(
"
D
"
):
continue
filelist
.
append
(
line
[
1
:].
lstrip
())
cmd
=
"
git ls-files --exclude-standard --others
"
filelist
+=
subp
.
check_output
(
cmd
,
shell
=
True
).
decode
(
"
utf8
"
).
strip
().
split
(
"
\n
"
)
filelist
=
[
x
for
x
in
filelist
if
"
ThirdParty
"
not
in
x
and
(
x
.
endswith
(
"
.h
"
)
or
x
.
endswith
(
"
.cc
"
))]
cmd
=
"
clang-format -style=file
"
if
args
.
apply
:
for
filename
in
filelist
:
subp
.
check_call
(
cmd
.
split
()
+
[
"
-i
"
,
filename
])
else
:
# only print files which need formatting
files_need_formatting
=
0
for
filename
in
filelist
:
a
=
open
(
filename
,
"
rb
"
).
read
()
b
=
subp
.
check_output
(
cmd
.
split
()
+
[
filename
])
if
a
!=
b
:
files_need_formatting
+=
1
print
(
filename
)
sys
.
exit
(
1
if
files_need_formatting
>
0
else
0
)
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