HomePhabricator

Update copyright_header.py to not duplicate parts of the header

Description

Update copyright_header.py to not duplicate parts of the header

Summary:
Currently, using the insert command of this script on a file like
wallet_zapwallettxes.py will cause part of the copyright header to be
duplicated.

current behavior (without this patch) example:

# Copyright (c) 2014-2016 The Bitcoin Core developers
# Distributed under the MIT software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php.

to:

# Copyright (c) 2015-2019 The Bitcoin developers
# Distributed under the MIT software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
# Copyright (c) 2014-2016 The Bitcoin Core developers
# Distributed under the MIT software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php.

This change fixes the behavior so that it does not duplicate lines.
example:

# Copyright (c) 2014-2016 The Bitcoin Core developers
# Distributed under the MIT software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php.

to:

# Copyright (c) 2014-2016 The Bitcoin Core developers
# Copyright (c) 2014-2019 The Bitcoin developers
# Distributed under the MIT software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php.

Test Plan:
On a file with the copyright header:

contrib/devtools/copyright_headers.py insert <file>

This should outout the following error and make no change:
*** src/seeder/main.cpp already has a copyright by The Bitcoin developers

Remove the // Copyright (c) <oldyear>-<newyear> The Bitcoin developers line from a .cpp or .h file.

contrib/devtools/copyright_headers.py insert <file>

The copyright header should be the same as before (maybe newyear is updated to something more recent).

Edit the // Copyright (c) <oldyear>-<newyear> The Bitcoin developers line in a .cpp or .h file to // Copyright (c) <oldyear>-<newyear> The Bitcoin Core developers.

contrib/devtools/copyright_headers.py insert <file>

The copyright header should now include the The Bitcoin developers line (which could have its newyear updated as before) underneath the The Bitcoin Core developers line.

Completely remove the entire copyright header from the file.

contrib/devtools/copyright_headers.py insert <file>

This should reproduce the results of the second case.

Repeat using a python file.

Reviewers: O1 Bitcoin ABC, #bitcoin_abc, jasonbcox

Reviewed By: O1 Bitcoin ABC, #bitcoin_abc, jasonbcox

Subscribers: jasonbcox

Differential Revision: https://reviews.bitcoinabc.org/D5157

Details

Provenance
nakihitoAuthored on Feb 4 2020, 01:55
nakihitoPushed on Feb 7 2020, 18:32
Reviewer
Restricted Owners Package
Differential Revision
D5157: Update copyright_header.py to not duplicate parts of the header
Parents
rABC025472d9a046: Run the linters as part of arc land
Branches
Unknown
Tags
Unknown