swiftlang / swift-format

Formatting technology for Swift source code
Apache License 2.0
2.49k stars 229 forks source link

Output of `swift format --version` is confusing #834

Open jkmathew opened 2 weeks ago

jkmathew commented 2 weeks ago

I am using Xcode 16 which comes with a bundled swift format. When I run swift format --version, it prints main. Does this mean the swift format bundled with Xcode will always be updated with the latest main branch? Or the bundled version is the latest from the main branch at the time of Xcode release is created?

I tried installing swift-format with homebrew and swift-format --version prints the version correctly.

ahoppen commented 2 weeks ago

Synced to Apple’s issue tracker as rdar://137309661

allevato commented 2 weeks ago

Unfortunately we've had to manually update the version number when cutting a release, and that can get overlooked easily. I know I've done it in the past.

IIRC, a recent change in SwiftPM has added a package API to query Git repository information and generate constants that we could reference from the --version handler instead. I would need to look further into it to see if that works as intended when a release is tagged and built.

cc @ahoppen who is in charge of releases.

jkmathew commented 2 weeks ago

I see there is already an automation implemented here Tags containing proper versions like https://github.com/swiftlang/swift-format/blob/93ebb779c07dad2598919de8202d6df1f97189d4/Sources/swift-format/PrintVersion.swift#L15

I hope Xcode 16.1 release will have the proper version 🙂