Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
S
schaapcommon
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Jira
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container 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
Insights
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
ResearchAndDevelopment
schaapcommon
Commits
0e73f765
Commit
0e73f765
authored
1 year ago
by
André Offringa
Browse files
Options
Downloads
Patches
Plain Diff
Fix CI error: the format script was outdated
parent
0b03827e
No related branches found
Branches containing commit
No related tags found
1 merge request
!133
Fix CI error: the format script was outdated
Pipeline
#69457
passed
1 year ago
Stage: versioning
Stage: prepare
Stage: linting
Stage: build
Stage: test
Changes
1
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
scripts/format.sh
+16
-8
16 additions, 8 deletions
scripts/format.sh
with
16 additions
and
8 deletions
scripts/format.sh
+
16
−
8
View file @
0e73f765
...
...
@@ -2,7 +2,9 @@
# SPDX-License-Identifier: GPL-3.0-or-later
# format.sh: Formats source code in a repository in accordance with
# .clang-format and .cmake-format.py files.
# .clang-format and .cmake-format.py files. The script only formats source code
# that has been added to git. E.g. new untracked files are ignored and will only
# be formatted once they are staged.
#
# This script uses the following variables:
# - SOURCE_DIR: The directory that contains the source files.
...
...
@@ -37,10 +39,10 @@ elif [ -n "$GIT_AUTHOR_DATE" ]; then
DRYRUN
=
" (dry run in git hook)"
fi
#
p
rint in bold-face
#
P
rint in bold-face
echo
-e
"
\e
[1mRunning formatters
$DRYRUN
...
\e
[0m"
# Convert SOURCES into "-name ext1 -o -name ext2 -o name ext3 ..."
# Convert SOURCES into "-name ext1 -o -name ext2 -o
-
name ext3 ..."
CXX_FIND_NAMES
=
"-name
${
CXX_SOURCES
[0]
}
"
for
i
in
`
seq
1
$((${#
CXX_SOURCES
[*]
}
-
1
))
`
;
do
CXX_FIND_NAMES+
=
" -o -name
${
CXX_SOURCES
[
$i
]
}
"
...
...
@@ -62,10 +64,16 @@ for e in ${EXCLUDE_DIRS[*]}; do
FIND_EXCLUDES+
=
"-path ./
$e
-prune -o "
done
# Use `find` to incorporate the EXCLUDE_DIRS
cd
$SOURCE_DIR
CXX_FILES
=
$(
find
.
$FIND_EXCLUDES
-type
f
\(
$CXX_FIND_NAMES
\)
-print
)
CMAKE_FILES
=
$(
find
.
$FIND_EXCLUDES
-type
f
\(
$CMAKE_FIND_NAMES
\)
-print
)
PYTHON_FILES
=
$(
find
.
$FIND_EXCLUDES
-type
f
\(
$PYTHON_FIND_NAMES
\)
-print
)
CXX_FILES_EXCLUDEDIRS
=
$(
find
.
$FIND_EXCLUDES
-type
f
\(
$CXX_FIND_NAMES
\)
-print
)
CMAKE_FILES_EXCLUDEDIRS
=
$(
find
.
$FIND_EXCLUDES
-type
f
\(
$CMAKE_FIND_NAMES
\)
-print
)
PYTHON_FILES_EXCLUDEDIRS
=
$(
find
.
$FIND_EXCLUDES
-type
f
\(
$PYTHON_FIND_NAMES
\)
-print
)
# Only format files that are in the git repo
CXX_FILES
=
$(
git ls-files
$CXX_FILES_EXCLUDEDIRS
)
CMAKE_FILES
=
$(
git ls-files
$CMAKE_FILES_EXCLUDEDIRS
)
PYTHON_FILES
=
$(
git ls-files
$PYTHON_FILES_EXCLUDEDIRS
)
# Use line length 79, which complies with PEP-8.
BLACK
=
"black -l 79"
...
...
@@ -80,7 +88,7 @@ if [ -n "$DRYRUN" ]; then
grep
-q
"<replacement "
)
&&
cmake-format
--check
$CMAKE_FILES
&&
$BLACK
--check
$PYTHON_FILES
;
then
#
p
rint in bold-face green
#
P
rint in bold-face green
echo
-e
"
\e
[1m
\e
[32mGreat job, all files are properly formatted!
\e
[0m"
else
# Print in bold-face red
...
...
@@ -92,6 +100,6 @@ else
${
CLANG_FORMAT_BINARY
}
-i
-style
=
file
$CXX_FILES
cmake-format
-i
$CMAKE_FILES
$BLACK
-q
$PYTHON_FILES
#
p
rint in bold-face
#
P
rint in bold-face
echo
-e
"
\e
[1mSuccessfully formatted all files.
\e
[0m"
fi
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