Skip to content

Instantly share code, notes, and snippets.

@vst
Created January 11, 2012 04:34
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vst/1593039 to your computer and use it in GitHub Desktop.
Save vst/1593039 to your computer and use it in GitHub Desktop.
Automated management of copyright and licensing notes for individual source code files.

How-to Manage Copyright Notice for Individual Source Code Files

If you want to manage the copyright and licensing information of your source code files automatically, you may use headache tool.

Steps to apply:

  1. Install headache. If you are on Ubuntu or Debian GNU/Linux, simply issue the command:

    apt-get install headache
  2. Create a copyright notice template. You can use the attached sample which is an Apache License, Version 2.0.
  3. Create a configuration file. You can use the attached sample which extends the default configuration for python files.
  4. Run:

    headache -c config.cfg -h template.txt [source_file(s)]
# Objective Caml source
".*\\.ml[il]?" -> frame open:"(*" line:"*" close:"*)"
| ".*\\.mly" -> frame open:"/*" line:"*" close:"*/"
# C source
| ".*\\.[ch]" -> frame open:"/*" line:"*" close:"*/"
# Misc
| ".*Makefile.*" -> frame open:"#" line:"#" close:"#"
| ".*README.*" -> frame open:"*" line:"*" close:"*"
| ".*LICENSE.*" -> frame open:"*" line:"*" close:"*"
# Python
| ".*\\.py" -> frame open:"#" line:"#" close:"#"
Copyright [yyyy] [name of copyright owner]
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment