nicklockwood / SwiftFormat

A command-line tool and Xcode Extension for formatting Swift code
MIT License
7.92k stars 639 forks source link

For fileHeader if author is unavailable format does not work #1802

Open tahirmt opened 3 months ago

tahirmt commented 3 months ago

I'm trying to use --header with {author.name} but it seems in my git history some files do not have an author and I am getting the following error

error: Failed to apply {author} template in file header as required info is unavailable.

I don't know how to get past this issue. Ideally, I would like to be able to provide either a default value or an alternative template without author in case it's not available.

Is there anything I can do to unblock myself?

nicklockwood commented 2 months ago

@tahirmt hi, sorry for not getting back to you sooner. I'll think about the best way to handle this. In the meantime you can probably unblock yourself by using git commit --amend --author "..." to retrospectively set the author for those files

tahirmt commented 2 months ago

I don’t know if that would be feasible due to needing to rewrite history and changing old git hashes. Another thing to point is that most of the files do have Xcode generated headers maybe there’s a way to parse that out?