-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add script to test for correct copyright headers
- Loading branch information
1 parent
6206c05
commit e9fb2c8
Showing
2 changed files
with
36 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
# Copyright 2018 Martin Holters | ||
# See accompanying license file. | ||
@static if VERSION < v"0.6" | ||
ACMEdir = joinpath(dirname(@__FILE__), "..") | ||
else | ||
ACMEdir = joinpath(@__DIR__, "..") | ||
end | ||
println("Checking copyright headers...") | ||
for dirname in ("src", "examples", "test") | ||
dirname = joinpath(ACMEdir, dirname) | ||
for name in readdir(dirname) | ||
if endswith(name, ".jl") | ||
name = joinpath(dirname, name) | ||
years = sort!(unique(parse.([Int], readlines(`git log --format=%cd --date=format:%Y -- $name`)))) | ||
if isempty(years) | ||
continue | ||
end | ||
println(name) | ||
open(name, "r") do io | ||
l = readline(io) | ||
#println(l) | ||
m = match(r"#\s*Copyright\s+(([0-9]+(,\s*)?)*)", l) | ||
if m === nothing | ||
error("Missing copyright header in $name") | ||
end | ||
headyears = parse.([Int], strip.(split(m.captures[1], ','))) | ||
d = setdiff(years, headyears) | ||
if !isempty(d) | ||
error("Missing years in copyright header of $name: $d") | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters