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
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
3 changes: 2 additions & 1 deletion .gitattributes
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
*.pbxproj binary merge=union
*.pbxproj binary merge=union
*.[hm] filter=typhoonheader
41 changes: 41 additions & 0 deletions Scripts/typhoonheader
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#!/usr/bin/env ruby -wKU

# To use this script, add the following keys to your local config.
# git config filter.typhoonheader.smudge 'cat'
# git config filter.typhoonheader.clean '`git rev-parse --git-dir`/../scripts/typhoonheader'

TYPHOON_HEADER = <<EOS
////////////////////////////////////////////////////////////////////////////////
//
// TYPHOON FRAMEWORK
// Copyright 2013, Jasper Blues & Contributors
// All Rights Reserved.
//
// NOTICE: The authors permit you to use, modify, and distribute this file
// in accordance with the terms of the license agreement accompanying it.
//
////////////////////////////////////////////////////////////////////////////////
EOS

XCODE_HEADER = Regexp.new(<<EOS)
\\A//
// .*
// .*
//
// Created by .* on \\d\\d/\\d\\d/\\d\\d\\.
// Copyright \\(c\\) \\d{4} .*\\. All rights reserved\\.
//
EOS

input = STDIN.read
output = STDOUT

if input.start_with? TYPHOON_HEADER
output.write input
elsif XCODE_HEADER.match(input)
output.puts TYPHOON_HEADER
output.write input.gsub(XCODE_HEADER, '')
else
output.puts TYPHOON_HEADER
output.write input
end