Skip to content
Merged
Changes from all commits
Commits
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
31 changes: 17 additions & 14 deletions contrib/devtools/copyright_header.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#!/usr/bin/env python3
# Copyright (c) 2016 The Bitcoin Core developers
# Copyright (c) 2017 The Bitcoin developers
# Distributed under the MIT software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php.

Expand Down Expand Up @@ -105,6 +106,8 @@ def compile_copyright_regex(copyright_style, year_style, name):
"Jan-Klaas Kollhof\n",
"Sam Rushing\n",
"ArtForz -- public domain half-a-node\n",
"Amaury SÉCHET\n",
"Jeremy Rubin\n",
]

DOMINANT_STYLE_COMPILED = {}
Expand Down Expand Up @@ -340,7 +343,7 @@ def write_file_lines(filename, file_lines):
COPYRIGHT = 'Copyright \(c\)'
YEAR = "20[0-9][0-9]"
YEAR_RANGE = '(%s)(-%s)?' % (YEAR, YEAR)
HOLDER = 'The Bitcoin Core developers'
HOLDER = 'The Bitcoin developers'
UPDATEABLE_LINE_COMPILED = re.compile(' '.join([COPYRIGHT, YEAR_RANGE, HOLDER]))

def get_updatable_copyright_line(file_lines):
Expand Down Expand Up @@ -408,24 +411,24 @@ def exec_update_header_year(base_directory):
################################################################################

UPDATE_USAGE = """
Updates all the copyright headers of "The Bitcoin Core developers" which were
Updates all the copyright headers of "The Bitcoin developers" which were
changed in a year more recent than is listed. For example:

// Copyright (c) <firstYear>-<lastYear> The Bitcoin Core developers
// Copyright (c) <firstYear>-<lastYear> The Bitcoin developers

will be updated to:

// Copyright (c) <firstYear>-<lastModifiedYear> The Bitcoin Core developers
// Copyright (c) <firstYear>-<lastModifiedYear> The Bitcoin developers

where <lastModifiedYear> is obtained from the 'git log' history.

This subcommand also handles copyright headers that have only a single year. In those cases:

// Copyright (c) <year> The Bitcoin Core developers
// Copyright (c) <year> The Bitcoin developers

will be updated to:

// Copyright (c) <year>-<lastModifiedYear> The Bitcoin Core developers
// Copyright (c) <year>-<lastModifiedYear> The Bitcoin developers

where the update is appropriate.

Expand Down Expand Up @@ -458,7 +461,7 @@ def get_header_lines(header, start_year, end_year):
return [line + '\n' for line in lines]

CPP_HEADER = '''
// Copyright (c) %s The Bitcoin Core developers
// Copyright (c) %s The Bitcoin developers
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
'''
Expand All @@ -467,7 +470,7 @@ def get_cpp_header_lines_to_insert(start_year, end_year):
return reversed(get_header_lines(CPP_HEADER, start_year, end_year))

PYTHON_HEADER = '''
# Copyright (c) %s The Bitcoin Core developers
# Copyright (c) %s The Bitcoin developers
# Distributed under the MIT software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
'''
Expand All @@ -487,7 +490,7 @@ def get_git_change_year_range(filename):
# check for existing core copyright
################################################################################

def file_already_has_core_copyright(file_lines):
def file_already_has_bitcoin_copyright(file_lines):
index, _ = get_updatable_copyright_line(file_lines)
return index != None

Expand Down Expand Up @@ -520,8 +523,8 @@ def insert_cpp_header(filename, file_lines, start_year, end_year):

def exec_insert_header(filename, style):
file_lines = read_file_lines(filename)
if file_already_has_core_copyright(file_lines):
sys.exit('*** %s already has a copyright by The Bitcoin Core developers'
if file_already_has_bitcoin_copyright(file_lines):
sys.exit('*** %s already has a copyright by The Bitcoin developers'
% (filename))
start_year, end_year = get_git_change_year_range(filename)
if style == 'python':
Expand All @@ -534,7 +537,7 @@ def exec_insert_header(filename, style):
################################################################################

INSERT_USAGE = """
Inserts a copyright header for "The Bitcoin Core developers" at the top of the
Inserts a copyright header for "The Bitcoin developers" at the top of the
file in either Python or C++ style as determined by the file extension. If the
file is a Python file and it has a '#!' starting the first line, the header is
inserted in the line below it.
Expand All @@ -548,7 +551,7 @@ def exec_insert_header(filename, style):

"<current_year>"

If the file already has a copyright for "The Bitcoin Core developers", the
If the file already has a copyright for "The Bitcoin developers", the
script will exit.

Usage:
Expand Down Expand Up @@ -581,7 +584,7 @@ def insert_cmd(argv):

USAGE = """
copyright_header.py - utilities for managing copyright headers of 'The Bitcoin
Core developers' in repository source files.
developers' in repository source files.

Usage:
$ ./copyright_header <subcommand>
Expand Down