Files
swift-crypto/scripts/update-swiftformatingore.sh
dc4c2c14e7 Enable swift-format in CI (#302)
## Motivation

As part of the Github Actions CI migration we held off enabling the
format check and moving to the same formatting rules as Swift NIO, but
we'd like to do that now.

## Modifications

- Add a script to generate (and update) the `.swiftformatignore` file
since this repo only wants to format a specific set of files matching a
pattern.
- Generate and commit the `.swiftformatignore` file.
- Run the fomatter and commit the results.
- Additional commits to satisfy the remaining linter rules that weren't
auto-fixed by swift-format.
- Enable the format check in CI.

## Result

- Code that's not shared is formatted with a style consistent with the
other repos this team maintain.
- CI is now checking code format again.

---------

Co-authored-by: Cory Benfield <lukasa@apple.com>
Co-authored-by: Rick Newton-Rogers <rnro@apple.com>
2024-11-28 14:46:23 +00:00

28 lines
1.0 KiB
Bash
Executable File

#!/bin/bash
##===----------------------------------------------------------------------===##
##
## This source file is part of the SwiftCrypto open source project
##
## Copyright (c) 2024 Apple Inc. and the SwiftCrypto project authors
## Licensed under Apache License v2.0
##
## See LICENSE.txt for license information
## See CONTRIBUTORS.txt for the list of SwiftCrypto project authors
##
## SPDX-License-Identifier: Apache-2.0
##
##===----------------------------------------------------------------------===##
set -euo pipefail
# The upstream soundness check only supports _excluding_ specific files using
# an ignore file, but we want to only _include_ some specific files based on
# patterns. That's fine, we'll invert the predicate here to create the ignore
# file on the fly, then run the same command as the upstream soundness check.
repo_root=$(git rev-parse --show-toplevel)
git -C "${repo_root}" ls-files \
'*.swift' \
':(exclude)*/*Boring*/*.swift' \
':(exclude)*_boring.swift' \
> "${repo_root}/.swiftformatignore"