Skip to content

Commit bae81b8

Browse files
committed
Merge #8674: tools for analyzing, updating and adding copyright headers in source files
159597a [devtools] script support for managing source file copyright headers (isle2983)
2 parents 1107653 + 159597a commit bae81b8

File tree

3 files changed

+662
-76
lines changed

3 files changed

+662
-76
lines changed

contrib/devtools/README.md

Lines changed: 52 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,21 +24,64 @@ the script should be called from the git root folder as follows.
2424
```
2525
git diff -U0 HEAD~1.. | ./contrib/devtools/clang-format-diff.py -p1 -i -v
2626
```
27+
copyright\_header.py
28+
====================
2729

28-
fix-copyright-headers.py
29-
========================
30+
Provides utilities for managing copyright headers of `The Bitcoin Core
31+
developers` in repository source files. It has three subcommands:
3032

31-
Every year newly updated files need to have its copyright headers updated to reflect the current year.
32-
If you run this script from the root folder it will automatically update the year on the copyright header for all
33-
source files if these have a git commit from the current year.
33+
```
34+
$ ./copyright_header.py report <base_directory> [verbose]
35+
$ ./copyright_header.py update <base_directory>
36+
$ ./copyright_header.py insert <file>
37+
```
38+
Running these subcommands without arguments displays a usage string.
3439

35-
For example a file changed in 2015 (with 2015 being the current year):
40+
copyright\_header.py report \<base\_directory\> [verbose]
41+
---------------------------------------------------------
3642

37-
```// Copyright (c) 2009-2013 The Bitcoin Core developers```
43+
Produces a report of all copyright header notices found inside the source files
44+
of a repository. Useful to quickly visualize the state of the headers.
45+
Specifying `verbose` will list the full filenames of files of each category.
3846

39-
would be changed to:
47+
copyright\_header.py update \<base\_directory\> [verbose]
48+
---------------------------------------------------------
49+
Updates all the copyright headers of `The Bitcoin Core developers` which were
50+
changed in a year more recent than is listed. For example:
51+
```
52+
// Copyright (c) <firstYear>-<lastYear> The Bitcoin Core developers
53+
```
54+
will be updated to:
55+
```
56+
// Copyright (c) <firstYear>-<lastModifiedYear> The Bitcoin Core developers
57+
```
58+
where `<lastModifiedYear>` is obtained from the `git log` history.
4059

41-
```// Copyright (c) 2009-2015 The Bitcoin Core developers```
60+
This subcommand also handles copyright headers that have only a single year. In
61+
those cases:
62+
```
63+
// Copyright (c) <year> The Bitcoin Core developers
64+
```
65+
will be updated to:
66+
```
67+
// Copyright (c) <year>-<lastModifiedYear> The Bitcoin Core developers
68+
```
69+
where the update is appropriate.
70+
71+
copyright\_header.py insert \<file\>
72+
------------------------------------
73+
Inserts a copyright header for `The Bitcoin Core developers` at the top of the
74+
file in either Python or C++ style as determined by the file extension. If the
75+
file is a Python file and it has `#!` starting the first line, the header is
76+
inserted in the line below it.
77+
78+
The copyright dates will be set to be `<year_introduced>-<current_year>` where
79+
`<year_introduced>` is according to the `git log` history. If
80+
`<year_introduced>` is equal to `<current_year>`, it will be set as a single
81+
year rather than two hyphenated years.
82+
83+
If the file already has a copyright for `The Bitcoin Core developers`, the
84+
script will exit.
4285

4386
gen-manpages.sh
4487
===============

0 commit comments

Comments
 (0)