Skip to content

Add a bash script to simplify calling swift-syntax-dev-utils #2376

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ swift-syntax is formatted using [swift-format](http://github.com/apple/swift-for

To format your changes run the formatter using the following command
```bash
swift run --package-path SwiftSyntaxDevUtils/ swift-syntax-dev-utils format
./swift-syntax-dev-utils format
```
It will build a local copy of swift-format from the `main` branch and format the repository. Since it is building a release version of `swift-format`, the first run will take few minutes. Subsequent runs take less than 2 seconds.

Expand All @@ -36,7 +36,7 @@ Generated source code is not formatted to make it easier to spot changes when re
> #!/usr/bin/env bash
> set -e
> SOURCE_DIR=$(realpath "$(dirname $0)/../..")
> swift run --package-path "$SOURCE_DIR/SwiftSyntaxDevUtils" swift-syntax-dev-utils format --lint
> swift "$SOURCE_DIR/swift-syntax-dev-utils" format --lint
> ```
> 2. Mark the file as executable: `chmod a+x swift-syntax/.git/hooks/pre-commit`
> 3. If you have global git hooks installed, be sure to call them at the end of the script with `path/to/global/hooks/pre-commit "$@"`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,15 +82,15 @@ struct FormatExecutor {

Run the following command to format swift-syntax

swift run --package-path SwiftSyntaxDevUtils/ swift-syntax-dev-utils format
./swift-syntax-dev-utils format

If the issue persists, try updating swift-format by running

swift run --package-path SwiftSyntaxDevUtils/ swift-syntax-dev-utils format --update
./swift-syntax-dev-utils format --update

Should that still fail, fix any remaining issues manually and verify they match the swift-format style using

swift run --package-path SwiftSyntaxDevUtils/ swift-syntax-dev-utils format --lint
./swift-syntax-dev-utils format --lint
"""
}
}
Expand Down
3 changes: 3 additions & 0 deletions swift-syntax-dev-utils
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/usr/bin/env sh

swift run --package-path "$(dirname $0)/SwiftSyntaxDevUtils" swift-syntax-dev-utils "$@"