Skip to content

Commit

Permalink
Add script to test for correct copyright headers
Browse files Browse the repository at this point in the history
  • Loading branch information
martinholters committed Feb 12, 2018
1 parent 6206c05 commit e9fb2c8
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 0 deletions.
34 changes: 34 additions & 0 deletions test/checklic.jl
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
2 changes: 2 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# Copyright 2015, 2016, 2017, 2018 Martin Holters
# See accompanying license file.

include("checklic.jl")

using ACME
using Compat
using Compat.Test
Expand Down

0 comments on commit e9fb2c8

Please sign in to comment.