-
Notifications
You must be signed in to change notification settings - Fork 268
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
.gitattributes and filter to add copyright header #127
.gitattributes and filter to add copyright header #127
Conversation
Remove standard Xcode header if found.
.gitattributes and filter to add copyright header
That was fast. I hope I didn’t make any mistake. |
"If we're going to make mistakes, let them be the ones we make from moving too quickly, not the ones from going too slowly." - Dancing With Elephants |
A few things: It would be ideal if the copyright header wasn't duplicated in the script and was instead loaded from the file in the repository. What about replacing anything before the first #import with the Typhoon header instead of trying to detect the Xcode header? This way it would not fail if the user has changed their default header or if the Xcode header changes at some point. |
Certainly sounds better. |
Loading the header from the file crossed my mind. I wanted the script to be as independent as possible, and not be affected if that file moves or disappear. I will do it, it is not a problem. We just have to be careful. About the second proposal, I think that trying to be more “clever” will lead to more errors. For example if someone decides to provide another comment block as introduccion to the file, before any import, the script will remove it... or if the first thing is a conditional preprocessing ( |
Good points. . those rainy day events don't sound like much fun at all. If you can make sure the header is not already there before adding that will be good - I'm usually in the habit of adding it anyway. |
The header should be added only once. If the header is there isn’t added again. Did that happen in some file? |
Nope, just making sure. As long as it does that, I'm happy. I see your point about not getting clever. We can clean up any mess easier than we can fix stuff that got eaten up. |
I modified the script and the gitattributes file a little to use the |
Awesome, thanks! In hindsight I agree that replacing things before the first import is more dangerous and we should stay with the simpler approach. |
The filter script appends Typhoon header when adding/modifying files, and removes standard Xcode header if found.
It seems to work for the simple cases I have tried:
It did me something weird after a reset. Status keep telling me there was changes in a file, and there weren’t changes any more.
One gotcha: you will not have the correct header until you checkout that file again. The changes happen from the working directory to the staging area, but do not persist in the working directory until a checkout of that file happens.
Probably needs a change in the readme/contributing page to tell other contributors to “install” the filter. Nothing happens if the filter is not defined (not even a warning).
See #116