Skip to content
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

Merged
merged 1 commit into from
Dec 10, 2013

Conversation

drodriguez
Copy link
Contributor

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:

  • Create a new file without any kind of header.
  • Create a new file with Xcode header.
  • Create a new file with Typhoon header.
  • Modify an existing file with Xcode header.
  • Modify an existing file with Typhoon header.

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

Remove standard Xcode header if found.
jasperblues added a commit that referenced this pull request Dec 10, 2013
.gitattributes and filter to add copyright header
@jasperblues jasperblues merged commit 35cfbba into appsquickly:master Dec 10, 2013
@drodriguez
Copy link
Contributor Author

That was fast. I hope I didn’t make any mistake.

@drodriguez drodriguez deleted the copyright-gitattributes branch December 10, 2013 14:51
@jasperblues
Copy link
Member

"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

@rhgills
Copy link
Contributor

rhgills commented Dec 11, 2013

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.

@jasperblues
Copy link
Member

Certainly sounds better.

@drodriguez
Copy link
Contributor Author

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 (#if IOS #import this.h #else #import that.h #end). My opinion is not modifying that part.

@jasperblues
Copy link
Member

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.

@drodriguez
Copy link
Contributor Author

The header should be added only once. If the header is there isn’t added again. Did that happen in some file?

@jasperblues
Copy link
Member

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.

@drodriguez
Copy link
Contributor Author

I modified the script and the gitattributes file a little to use the Copyright-Header.txt contents, and also I have changed the attributes file to restrict the filter to Source and Tests directories (I haven’t noticed before that Pods did have a lot of .m and .h files.

@rhgills
Copy link
Contributor

rhgills commented Dec 14, 2013

Awesome, thanks!

In hindsight I agree that replacing things before the first import is more dangerous and we should stay with the simpler approach.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants