Skip to content
This repository has been archived by the owner on Feb 1, 2019. It is now read-only.

License maintainer #40

Open
wants to merge 113 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
113 commits
Select commit Hold shift + click to select a range
0748b8e
Git pre-commit hook for keeping licenses up-to-date in *.java, *.txt …
xkr47 Mar 16, 2013
c2a6eba
Git pre-commit hook now also verifies that unmodified files have thei…
xkr47 Mar 17, 2013
64b77f1
Better error handling
xkr47 Mar 17, 2013
1b4174e
Cleanup, variable names, comments
xkr47 Mar 17, 2013
355d8fd
Use license.pl as module instead for much faster execution
xkr47 Mar 18, 2013
f677164
pre-commit: Update license prepender to support author list maintenance
xkr47 Sep 23, 2013
3f900f3
pre-commit: Add install script for pre-commit hook
xkr47 Jun 23, 2015
5a74821
pre-commit: Degrade ERROR message to WARNING
xkr47 Jun 23, 2015
284020c
pre-commit: Add option to add/update licenses to all files, even thos…
xkr47 Jun 23, 2015
d1d7632
Move LICENSE and README to .githooks subdirectory
xkr47 Jun 25, 2015
7fa964e
Initial instructions
xkr47 Oct 22, 2015
f6fafc0
automatic install is optional
xkr47 Oct 22, 2015
630c915
Implement #2: Externalize license configuration by adopting gitattrib…
xkr47 Oct 24, 2015
c29c290
README: Add license section
xkr47 Oct 24, 2015
c50ee5f
README: How to temporarily inhibit license maintenance
xkr47 Oct 24, 2015
7480d1a
Install script should be executable
xkr47 Oct 24, 2015
fbf1102
Include filename if license file cannot be read
xkr47 Oct 24, 2015
f6ba278
Copy .gitignore from master
xkr47 Oct 25, 2015
ef672cd
Document .gitattributes file in overview
xkr47 Oct 25, 2015
558c6a0
README: Command for verifying license template configuration
xkr47 Oct 26, 2015
77e8394
Fixes #1
xkr47 Oct 26, 2015
e162019
Update README.md
xkr47 Oct 26, 2015
47c3095
NOTE! Add note about directory structure update
xkr47 Oct 26, 2015
7636375
Add xml support
xkr47 Feb 19, 2016
01a02d4
Update README.md
xkr47 Jan 26, 2016
47da504
README: git 2.9 fixes to installation instructions
xkr47 Jan 10, 2017
77e0f3a
Allow author names to contain email addresses
lalloni Feb 14, 2017
aa2a4a5
Merge pull request #6 from lalloni/hooks-only
xkr47 Feb 15, 2017
2996807
Fix #7 by making sure "." is in search path
xkr47 Sep 11, 2017
10a11e2
Adding license maintainer as per https://github.com/NitorCreations/li…
jamesray1 Apr 18, 2018
e1318f4
add a license maintainer.
jamesray1 Apr 18, 2018
19afef8
add a license maintainer.
jamesray1 Apr 18, 2018
1c07c2b
Add/update licenses for all maintained files
jamesray1 Apr 18, 2018
bcee67d
Fix the license-maintainer, copying the license to .gitattributes/ an…
jamesray1 Apr 18, 2018
76e4704
Copy the license to .githooks/license-maintainer and comment it out w…
jamesray1 Apr 18, 2018
818e41c
Update the license header in build.rs and diagrams/ml.dot.
jamesray1 Apr 18, 2018
4ad5d6d
Update license template with YEAR AUTHORS instead of literally.
jamesray1 Apr 18, 2018
950e116
Add a line at the end of the license header.
jamesray1 Apr 18, 2018
212b68c
Update .gitattributes.
jamesray1 Apr 18, 2018
833ad0a
src/lib.rs with YEAR AUTHORS to test if the error will go away for it.
jamesray1 Apr 18, 2018
f0a1676
added to tracking multiple files.
jamesray1 Apr 18, 2018
4e34ab2
Merge branch 'jamesray1-license-maintainer' into develop
jamesray1 Apr 18, 2018
7998b06
stop tracking ml.dot
jamesray1 Apr 18, 2018
6fe3cce
add .gitignore to tracking
jamesray1 Apr 18, 2018
e195230
Delete ml.dot
jamesray1 Apr 18, 2018
ab0eadd
Merge branch 'develop' of https://github.com/jamesray1/diamond_drops …
jamesray1 Apr 18, 2018
c0a88bc
Merge branch 'jamesray1-develop' into develop
jamesray1 Apr 18, 2018
ce4fd5a
Git pre-commit hook for keeping licenses up-to-date in *.java, *.txt …
xkr47 Mar 16, 2013
a571a58
Git pre-commit hook now also verifies that unmodified files have thei…
xkr47 Mar 17, 2013
814e685
Better error handling
xkr47 Mar 17, 2013
7f58ced
Cleanup, variable names, comments
xkr47 Mar 17, 2013
ceb115f
Use license.pl as module instead for much faster execution
xkr47 Mar 18, 2013
c7308e0
pre-commit: Update license prepender to support author list maintenance
xkr47 Sep 23, 2013
7b4c15d
pre-commit: Add install script for pre-commit hook
xkr47 Jun 23, 2015
7c3e118
pre-commit: Degrade ERROR message to WARNING
xkr47 Jun 23, 2015
06577ed
pre-commit: Add option to add/update licenses to all files, even thos…
xkr47 Jun 23, 2015
85b2131
Move LICENSE and README to .githooks subdirectory
xkr47 Jun 25, 2015
95fe068
Initial instructions
xkr47 Oct 22, 2015
e819d67
automatic install is optional
xkr47 Oct 22, 2015
dbd85bb
Implement #2: Externalize license configuration by adopting gitattrib…
xkr47 Oct 24, 2015
a6f0c7f
README: Add license section
xkr47 Oct 24, 2015
61f1700
README: How to temporarily inhibit license maintenance
xkr47 Oct 24, 2015
4a76adc
Install script should be executable
xkr47 Oct 24, 2015
60aae3b
Include filename if license file cannot be read
xkr47 Oct 24, 2015
f9bf4c4
Copy .gitignore from master
xkr47 Oct 25, 2015
8df568b
Document .gitattributes file in overview
xkr47 Oct 25, 2015
d0b2053
README: Command for verifying license template configuration
xkr47 Oct 26, 2015
a1c8058
Fixes #1
xkr47 Oct 26, 2015
0008c8e
Update README.md
xkr47 Oct 26, 2015
7ce0fec
NOTE! Add note about directory structure update
xkr47 Oct 26, 2015
e16a7ca
Add xml support
xkr47 Feb 19, 2016
6eb500b
Update README.md
xkr47 Jan 26, 2016
47622d8
README: git 2.9 fixes to installation instructions
xkr47 Jan 10, 2017
ae8437a
Allow author names to contain email addresses
lalloni Feb 14, 2017
c8cc9a6
Fix #7 by making sure "." is in search path
xkr47 Sep 11, 2017
0cb8f34
fix merge conflicts
jamesray1 Apr 18, 2018
d3219ce
update tracking
jamesray1 Apr 18, 2018
588c590
Add deleted lines
jamesray1 Apr 18, 2018
4b2da8d
Remove new line at EOF
jamesray1 Apr 18, 2018
fb52679
Remove new line at EOF, doc comment
jamesray1 Apr 18, 2018
319fd82
Remove new line at EOF
jamesray1 Apr 18, 2018
1812fc0
Remove new line at EOF
jamesray1 Apr 18, 2018
3b7192a
Delete body.rs.orig
jamesray1 Apr 18, 2018
ce9e1ee
Delete header.rs.orig
jamesray1 Apr 18, 2018
b7367ed
Delete tree.rs.orig
jamesray1 Apr 18, 2018
620b12d
rm *.orig
jamesray1 Apr 18, 2018
085aff7
Remove duplicate lines from accidentally adding from resolving merge …
jamesray1 Apr 18, 2018
73c7e66
Fix from merge conflict: collation::collation::Collation
jamesray1 Apr 18, 2018
97be384
Update to collation::collation::Collation from accidental reversion
jamesray1 Apr 18, 2018
0852f68
use ethereum_types;
jamesray1 Apr 18, 2018
fbfe870
parse_cli_args
jamesray1 Apr 18, 2018
48a4128
Update build.rs with Github username
ltfschoen Apr 19, 2018
b41439b
Update LICENSE with full names
ltfschoen Apr 19, 2018
fd7cad2
Update build.rs with consistent names and Github usernames
ltfschoen Apr 19, 2018
4d03011
Update args.rs with consistent names and Github usernames
ltfschoen Apr 19, 2018
b005c36
Update config.rs with consistent names and Github usernames
ltfschoen Apr 19, 2018
e652788
Update config_env.rs with consistent names and Github usernames
ltfschoen Apr 19, 2018
5bdd07e
Update config_log.rs with consistent names and Github usernames
ltfschoen Apr 19, 2018
de310f2
Update mod.rs with consistent names and Github usernames
ltfschoen Apr 19, 2018
9357293
Update client_thread.rs with consistent names and Github username
ltfschoen Apr 19, 2018
893f723
Update body.rs with consistent names and Github username
ltfschoen Apr 19, 2018
b1b11bd
Update collation.rs with consistent names and Github username
ltfschoen Apr 19, 2018
a806b4e
Update header.rs with consistent names and Github username
ltfschoen Apr 19, 2018
58a1402
Update mod.rs with consistent names and Github username
ltfschoen Apr 19, 2018
cda4627
Update tree.rs with consistent names and Github username
ltfschoen Apr 19, 2018
c3395e1
Update lib.rs with consistent names and Github username
ltfschoen Apr 19, 2018
61e712f
Update main.rs with consistent names and Github username
ltfschoen Apr 19, 2018
b998757
Update message.rs with consistent names and Github username
ltfschoen Apr 19, 2018
550b3dd
Update notary.rs with consistent names and Github username
ltfschoen Apr 19, 2018
06c18b6
Update proposer.rs with consistent names and Github username
ltfschoen Apr 19, 2018
9dc3aa5
Update serialize_blob.rs with consistent names and Github username
ltfschoen Apr 19, 2018
ab27d02
Update smc_listener.rs with consistent names and Github username
ltfschoen Apr 19, 2018
be36671
Update cli_test.rs with consistent names and Github username
ltfschoen Apr 19, 2018
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
5 changes: 5 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
*.rs licensefile=.githooks/license-maintainer/LICENSE-C-style
*.dot licensefile=.githooks/license-maintainer/LICENSE-C-style
*.java licensefile=.githooks/license-maintainer/LICENSE-javadoc
*.sh licensefile=.githooks/license-maintainer/LICENSE-hash
/install licensefile=.githooks/license-maintainer/LICENSE-hash
4 changes: 4 additions & 0 deletions .githooks/license-maintainer/.gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
* -licensefile
/license.pm licensefile=.githooks/license-maintainer/LICENSE-hash
/pre-commit licensefile=.githooks/license-maintainer/LICENSE-hash
/install licensefile=.githooks/license-maintainer/LICENSE-hash
1 change: 1 addition & 0 deletions .githooks/license-maintainer/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*~
26 changes: 26 additions & 0 deletions .githooks/license-maintainer/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
Copyright 2018 James Ray (@jamesray1), Josiah Evans (@ChosunOne), Luke Schoen (@ltfschoen)

This is free and unencumbered software released into the public domain.

Anyone is free to copy, modify, publish, use, compile, sell, or
distribute this software, either in source code form or as a compiled
binary, for any purpose, commercial or non-commercial, and by any
means.

In jurisdictions that recognize copyright laws, the author or authors
of this software dedicate any and all copyright interest in the
software to the public domain. We make this dedication for the benefit
of the public at large and to the detriment of our heirs and
successors. We intend this dedication to be an overt act of
relinquishment in perpetuity of all present and future rights to this
software under copyright law.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.

For more information, please refer to <http://unlicense.org>
30 changes: 30 additions & 0 deletions .githooks/license-maintainer/LICENSE-C-style
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/* Copyright YEAR AUTHORS

This is free and unencumbered software released into the public domain.

Anyone is free to copy, modify, publish, use, compile, sell, or
distribute this software, either in source code form or as a compiled
binary, for any purpose, commercial or non-commercial, and by any
means.

In jurisdictions that recognize copyright laws, the author or authors
of this software dedicate any and all copyright interest in the
software to the public domain. We make this dedication for the benefit
of the public at large and to the detriment of our heirs and
successors. We intend this dedication to be an overt act of
relinquishment in perpetuity of all present and future rights to this
software under copyright law.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE
AUTHORS
BE LIABLE FOR ANY CLAIM, DAMAGES OR
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.

For more information, please refer to <http://unlicense.org>
*/

14 changes: 14 additions & 0 deletions .githooks/license-maintainer/LICENSE-hash
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Copyright YEAR AUTHORS
#
# 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.

15 changes: 15 additions & 0 deletions .githooks/license-maintainer/LICENSE-javadoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/**
* Copyright YEAR AUTHORS
*
* 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.
*/
118 changes: 118 additions & 0 deletions .githooks/license-maintainer/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
# license-maintainer
Maintains copyright/license preamble in source files etc in your project.

<blockquote><b>NOTE!</b> Recently moved entire script to new subdirectory .githooks/license-maintainer/ - you must re-install the pre-commit hook using the normal procedure (see below)</blockquote>

This project provides a tool that hooks into the `git commit` process to maintain copyright/license preamble in the files in your project.

When committing files, the tool inspects the files you are about to commit to see if an expected license header is present. If there is no license header, it is added, and if it already exists, it updates it to make sure that:

* the license is formatted properly
* the copyright year list contains the current year
* the list of organizations/individuals holding the copyright contains the origanization/individual represented by the user of the git checkout

Additionally, it also scans files that are not about to be committed, and warns if there are any files that don't contain the expected license. The warning includes instructions how to automatically add licenses to those files as a separate commit.

You can freely configure which files (using wildcards) should contain a license, and in what format the license should be presented using license template files. The license template files may contain the dynamic variables AUTHORS and YEARS that are then updated on each commit. Example Apache 2.0 license templates are included in a few different presentations.

In the suggested default configuration, the tool is imported to be a part of your project's source tree, and can be updated at will from this (or your own forked version of this) repository.

# Requirements

* Perl 5
* Bash (for automatic install, optional)

Honestly I have only tested this on Linux so far. Please file any issues you have with any operating system you end up using this tool in.

# Overview of the relevant part of this repository

* `.githooks/`
* `.githooks/license-maintainer/`
* `README.md` - this file
* `LICENSE` - license by which the license-maintainer is distributed
* `install` - script for automatic install
* `pre-commit` - entry point for "pre-commit" git hook, has the git-specific parts
* `license.pm` - perl module for adding & updating license in a single file at a time
* `.gitattributes` - license maintenance configuration for the license maintainer itself
* `LICENSE-hash` - sample (Apache 2.0) license file formatted for inclusion in files using `#` for end-of-line comments
* `LICENSE-javadoc` - sample (Apache 2.0) license file formatted for inclusion with javadoc style comments

# Importing the license maintainer into your project

* **one-shot**: If you want, you can just copy the `.githooks/license-maintainer` directory into the same location in your project. Jump over the rest of this section and continue from the "Enabling the license maintainer in a git repository" section after copying the directory.
* **the git way**: I recommend importing it using git itself, which will allow you to update it easily later, should you want to. Continue with the instructions below.

The "master" branch of this project contains both the .githooks/license-maintainer directory (containing the files you want) and some github-required files. But for your own project you want just the .githooks/license-maintainer directory. So for easy deployment into your project, there is a separate "hooks-only" branch which contains just the .githooks/license-maintainer directory.

## Adding the license-maintainer repository as a remote repository in your project

So, we add a git remote called `githooks-license-maintainer` for the hooks-only branch from this repository.

git remote add --no-tags -t hooks-only githooks-license-maintainer https://github.com/NitorCreations/license-maintainer

# or if you have a github account set up:

git remote add --no-tags -t hooks-only githooks-license-maintainer git@github.com:NitorCreations/license-maintainer.git

## Importing / updating the license-maintainer code into your project

To import and later update the license-maintainer code in your project, execute these commands in your "master" branch of your project:

git fetch githooks-license-maintainer
git merge --allow-unrelated-histories githooks-license-maintainer/hooks-only

*for git 2.8 and older, remove the `--allow-unrelated-histories` parameter*

Now you have the code in your repository. The next step is to enable it.

# Enabling the license maintainer in a git repository

Using the the license maintainer is an opt-in procedure that everybody using your repository (or rather every clone of the repository) will need to do once in order for the license maintainer to do its work.

There are two ways to do it, automatic or manual. If you don't have any other git hooks in your project, the automatic installation will do fine. However if you already have git hooks in use, you might want to manually integrate the license maintainer with your existing hooks.

## Automatic install

To automatically enable the license maintainer in your git checkout, run the following command in the base directory of your project.

.githooks/license-maintainer/install

This will create a symbolic link from .git/hooks/pre-commit to .githooks/license-maintainer/pre-commit

## Manual install

If you already have a `pre-commit` hook in use, you just need to call the `.githooks/license-maintainer/pre-commit` script at some point during the execution of your `pre-commit` script (perhaps preferrably as late as possible), and make sure that your script also exits with failure if the license-maintainer pre-commit script exits with failure when you call it.

# Configuration

Now we configure which files should have automatic copyright/license maintenance, and which template of copyright/license should be used for each.

Configuration is done using the "gitattributes" mechanism, which is similar to gitignore. See `gitattributes(5)` manual page for details.

The license maintainer includes its own configuration for license maintenance in `.githooks/license-maintainer/.gitattributes`. That is the only maintenance done by default. To enable license maintaintenance for files in your project, you specify the license template file to use for a file, or a filename pattern. First create a `.gitattributes` file, for example in the root directory of your repository. Then, for each file or pattern, specify the license using the "licensefile" attribute, e.g. with lines like:

*.java licensefile=.githooks/license-maintainer/LICENSE-javadoc
*.sh licensefile=.githooks/license-maintainer/LICENSE-hash
/install licensefile=.githooks/license-maintainer/LICENSE-hash

This will enable maintenance of all `*.java` files in the project with the `LICENSE-javadoc` license template and all `*.sh` files with the `LICENSE-hash` license template. The `install` file in the root directory of the repository also uses the `LICENSE-hash` template.

Patterns starting with / are effective only in the directory where the `.gitattributes` file resides, and patterns without are effective also in subdirectories recursively. Again, see the `gitattributes(5)` manual page for more information.

If you want to inhibit license maintenance for some specific file/pattern that otherwise would have license maintenance (by an earlier pattern match for example), you can specify `!licensefile` for that file to remove the setting.

If you want to verify that the correct license templates will be used for each file, you can do that with the following command:

git ls-files | git check-attr licensefile --stdin | sed -e 's!licensefile: !!' -e 's!un\(set\|specified\)$!-!'

The example `LICENSE-*` template files included in the `.githooks/license-maintainer/` directory are based on the Apache 2.0 license that the license maintainer itself is licensed under. You can freely use them or create your own template files anywhere in your repository with the license(s) you want to use for your project.

# Temporarily avoiding license maintenance

You can skip the maintenance of licenses for a single commit if you want. Just add the `-n` or `--no-verify` to disable processing of hooks. Example:

git commit -n

# License

The license-maintainer is distributed under the Apache 2.0 license. You may embed it in your project as long as you comply with the license for the files belonging to license-maintainer.
35 changes: 35 additions & 0 deletions .githooks/license-maintainer/install
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#!/bin/sh

# Copyright 2015 Nitor Creations Oy
#
# 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.

set -e

if [ "$#" -gt 0 ]; then
echo "usage: $0"
echo
echo "Installs the git hooks in this directory into .git/hooks/"
echo "Any existing destination file is backed up first if necessary."
exit 1
fi

cd "$(dirname "$0")/../.."

for i in pre-commit ; do
oldlink="$(readlink .git/hooks/${i} ||:)"
newlink="../../.githooks/license-maintainer/${i}"
if [ "$newlink" != "$oldlink" ]; then
ln -snv --backup=numbered "${newlink}" .git/hooks/
fi
done
Loading