diff --git a/.bumpversion.cfg b/.bumpversion.cfg index 9b8902895..39d22701d 100644 --- a/.bumpversion.cfg +++ b/.bumpversion.cfg @@ -1,5 +1,5 @@ [bumpversion] -current_version = 2.14.0.dev1 +current_version = 2.14.0.dev2 commit = True tag = True parse = (?P\d+)\.(?P\d+)\.(?P\d+)(\.(?P[a-z]+)(?P\d+))? diff --git a/.clang-format b/.clang-format index d918b45cb..1e5b3c71e 100644 --- a/.clang-format +++ b/.clang-format @@ -1,4 +1,3 @@ ---- Language: Cpp BasedOnStyle: Google IndentWidth: 4 @@ -56,4 +55,3 @@ SpaceInEmptySquareBrackets: true SpaceInEmptyBlock: true ColumnLimit: 140 ---- \ No newline at end of file diff --git a/.github/workflows/clang-format.yml b/.github/workflows/clang-format.yml new file mode 100644 index 000000000..2bf8ee382 --- /dev/null +++ b/.github/workflows/clang-format.yml @@ -0,0 +1,58 @@ +name: Clang-Format Check and Fix + +on: + push: + branches: + - develop + +jobs: + format-check: + runs-on: ubuntu-latest + + steps: + - name: Checkout Code + uses: actions/checkout@v3 + with: + fetch-depth: 2 + persist-credentials: true + + - name: Install Clang-Format + run: sudo apt-get install -y clang-format + + - name: Display Clang-Format Version + run: clang-format --version + + - name: Identify Changed Files in Push + run: | + echo "Changed files in push:" + git diff --name-only --diff-filter=ACM "${{ github.event.before }}" "${{ github.sha }}" | grep -E '\.(cpp|hpp|c|h)$' || echo "No matching files changed." + + - name: Run Clang-Format on Changed Files + run: | + git diff --name-only --diff-filter=ACM "${{ github.event.before }}" "${{ github.sha }}" | grep -E '\.(cpp|hpp|c|h)$' | xargs -r clang-format -style=file -i + + - name: Check for Formatting Differences + id: check_diff + run: | + # This command will exit with a non-zero status if there are differences. + git diff --exit-code + continue-on-error: true + + - name: Auto-commit Formatting Changes + if: failure() + run: | + git config --local user.name "github-actions[bot]" + git config --local user.email "github-actions[bot]@users.noreply.github.com" + git add . + git commit -m "Apply clang-format" + # Strip the "refs/heads/" prefix to get the branch name. + branch=${GITHUB_REF#refs/heads/} + git push origin HEAD:"$branch" + + - name: Report Success or Failure + run: | + if [ "${{ steps.check_diff.outcome }}" == "failure" ]; then + echo "Formatting issues were detected and fixed." + else + echo "Code is properly formatted." + fi diff --git a/src/simulation/propagation_setup/createEnvironmentUpdater.cpp b/src/simulation/propagation_setup/createEnvironmentUpdater.cpp index 0d87f7dcb..c78587ba8 100644 --- a/src/simulation/propagation_setup/createEnvironmentUpdater.cpp +++ b/src/simulation/propagation_setup/createEnvironmentUpdater.cpp @@ -37,7 +37,7 @@ void checkValidityOfRequiredEnvironmentUpdates( for( unsigned int i = 0; i < updateIterator->second.size( ); i++ ) { // Ignore global required updates. - if( updateIterator->second.at( i ) != "" ) + if( updateIterator->second.at( i ) != "" ) { // Check if body exists. if( bodies.count( updateIterator->second.at( i ) ) == 0 ) diff --git a/version b/version index deef4992d..70b037a85 100644 --- a/version +++ b/version @@ -1 +1 @@ -2.14.0.dev1 +2.14.0.dev2