Merge #17691: doc: Add missed copyright headers

fac86ac7b3ceac2f884412c7a9f4bd5bab5e3916 scripted-diff: Add missed copyright headers (Hennadii Stepanov)
6fde9d5e47fc9a1042b3fb68031eab5bf55e508d script: Update EXLUDE list in copyright_header.py (Hennadii Stepanov)
1998152f15fd2b0e83f5068c375a34feaf73db8c script: Add empty line after C++ copyright (Hennadii Stepanov)
071f2fc204f542c5a287ca8835115a2ee0bf2f50 script: Add ability to insert copyright to *.sh (Hennadii Stepanov)

Pull request description:

  This PR improves `contrib/devtools/copyright_header.py` script and adds copyright headers to the files in `src` and `test` directories with two exceptions:
  - [`src/reverse_iterator.h`](https://github.com/bitcoin/bitcoin/blob/master/src/reverse_iterator.h) (added to exceptions)
  - [`src/test/fuzz/FuzzedDataProvider.h`](https://github.com/bitcoin/bitcoin/blob/master/src/test/fuzz/FuzzedDataProvider.h) (added to exceptions)

  On master 5622d8f3156a293e61d0964c33d4b21d8c9fd5e0:
  ```
  $ ./contrib/devtools/copyright_header.py report . | grep zero
    25 with zero copyrights
  ```

  With this PR:
  ```
  $ ./contrib/devtools/copyright_header.py report . | grep zero
     2 with zero copyrights
  ```

  ~I am uncertain about our copyright policy with `build_msvc` and `contrib` directories content, so they are out of scope of this PR.~

ACKs for top commit:
  MarcoFalke:
    ACK fac86ac7b3ceac2f884412c7a9f4bd5bab5e3916

Tree-SHA512: d7832c4a7a1a3b7806119775b40ec35d7982f49ff0e6199b8cee4c0e0a36e68d51728b6ee9924b1c161df4bc6105bd93391b79d42914357fa522f499cb113fa8
This commit is contained in:
MarcoFalke 2020-01-16 15:57:24 -05:00 committed by Vijay Das Manikpuri
parent db662cf843
commit 6270a09847
No known key found for this signature in database
GPG Key ID: DB1D81B01DB7C46E
18 changed files with 75 additions and 8 deletions

View File

@ -1,4 +1,7 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
# Copyright (c) 2018 The Bitcoin Core developers
# Distributed under the MIT software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
import sys import sys
import re import re

View File

@ -20,6 +20,8 @@ EXCLUDE = [
'src/qt/bitcoinstrings.cpp', 'src/qt/bitcoinstrings.cpp',
'src/chainparamsseeds.h', 'src/chainparamsseeds.h',
# other external copyrights: # other external copyrights:
'src/reverse_iterator.h',
'src/test/fuzz/FuzzedDataProvider.h',
'src/tinyformat.h', 'src/tinyformat.h',
'src/bench/nanobench.h', 'src/bench/nanobench.h',
'test/functional/test_framework/bignum.py', 'test/functional/test_framework/bignum.py',
@ -459,14 +461,14 @@ CPP_HEADER = '''
def get_cpp_header_lines_to_insert(start_year, end_year): def get_cpp_header_lines_to_insert(start_year, end_year):
return reversed(get_header_lines(CPP_HEADER, start_year, end_year)) return reversed(get_header_lines(CPP_HEADER, start_year, end_year))
PYTHON_HEADER = ''' SCRIPT_HEADER = '''
# Copyright (c) %s The Dash Core developers # Copyright (c) %s The Dash Core developers
# Distributed under the MIT software license, see the accompanying # Distributed under the MIT software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php. # file COPYING or http://www.opensource.org/licenses/mit-license.php.
''' '''
def get_python_header_lines_to_insert(start_year, end_year): def get_script_header_lines_to_insert(start_year, end_year):
return reversed(get_header_lines(PYTHON_HEADER, start_year, end_year)) return reversed(get_header_lines(SCRIPT_HEADER, start_year, end_year))
################################################################################ ################################################################################
# query git for year of last change # query git for year of last change
@ -495,17 +497,18 @@ def file_has_hashbang(file_lines):
return False return False
return file_lines[0][:2] == '#!' return file_lines[0][:2] == '#!'
def insert_python_header(filename, file_lines, start_year, end_year): def insert_script_header(filename, file_lines, start_year, end_year):
if file_has_hashbang(file_lines): if file_has_hashbang(file_lines):
insert_idx = 1 insert_idx = 1
else: else:
insert_idx = 0 insert_idx = 0
header_lines = get_python_header_lines_to_insert(start_year, end_year) header_lines = get_script_header_lines_to_insert(start_year, end_year)
for line in header_lines: for line in header_lines:
file_lines.insert(insert_idx, line) file_lines.insert(insert_idx, line)
write_file_lines(filename, file_lines) write_file_lines(filename, file_lines)
def insert_cpp_header(filename, file_lines, start_year, end_year): def insert_cpp_header(filename, file_lines, start_year, end_year):
file_lines.insert(0, '\n')
header_lines = get_cpp_header_lines_to_insert(start_year, end_year) header_lines = get_cpp_header_lines_to_insert(start_year, end_year)
for line in header_lines: for line in header_lines:
file_lines.insert(0, line) file_lines.insert(0, line)
@ -517,8 +520,8 @@ def exec_insert_header(filename, style):
sys.exit('*** %s already has a copyright by The Dash Core developers' sys.exit('*** %s already has a copyright by The Dash Core developers'
% (filename)) % (filename))
start_year, end_year = get_git_change_year_range(filename) start_year, end_year = get_git_change_year_range(filename)
if style == 'python': if style in ['python', 'shell']:
insert_python_header(filename, file_lines, start_year, end_year) insert_script_header(filename, file_lines, start_year, end_year)
else: else:
insert_cpp_header(filename, file_lines, start_year, end_year) insert_cpp_header(filename, file_lines, start_year, end_year)
@ -559,11 +562,13 @@ def insert_cmd(argv):
if not os.path.isfile(filename): if not os.path.isfile(filename):
sys.exit("*** bad filename: %s" % filename) sys.exit("*** bad filename: %s" % filename)
_, extension = os.path.splitext(filename) _, extension = os.path.splitext(filename)
if extension not in ['.h', '.cpp', '.cc', '.c', '.py']: if extension not in ['.h', '.cpp', '.cc', '.c', '.py', '.sh']:
sys.exit("*** cannot insert for file extension %s" % extension) sys.exit("*** cannot insert for file extension %s" % extension)
if extension == '.py': if extension == '.py':
style = 'python' style = 'python'
elif extension == '.sh':
style = 'shell'
else: else:
style = 'cpp' style = 'cpp'
exec_insert_header(filename, style) exec_insert_header(filename, style)

View File

@ -1,4 +1,7 @@
#!/usr/bin/env bash #!/usr/bin/env bash
# Copyright (c) 2016-2019 The Bitcoin Core developers
# Distributed under the MIT software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
export LC_ALL=C export LC_ALL=C
TOPDIR=${TOPDIR:-$(git rev-parse --show-toplevel)} TOPDIR=${TOPDIR:-$(git rev-parse --show-toplevel)}

View File

@ -1,4 +1,7 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
# Copyright (c) 2017-2018 The Bitcoin Core developers
# Distributed under the MIT software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
import argparse import argparse

View File

@ -1,4 +1,7 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
# Copyright (c) 2018-2019 The Bitcoin Core developers
# Distributed under the MIT software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
import argparse import argparse
import os import os

View File

@ -1,3 +1,7 @@
// Copyright (c) 2017-2019 The Bitcoin Core developers
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#ifdef ENABLE_AVX2 #ifdef ENABLE_AVX2
#include <stdint.h> #include <stdint.h>

View File

@ -1,3 +1,7 @@
// Copyright (c) 2018-2019 The Bitcoin Core developers
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#ifdef ENABLE_SSE41 #ifdef ENABLE_SSE41
#include <stdint.h> #include <stdint.h>

View File

@ -1,3 +1,7 @@
// Copyright (c) 2017-2019 The Bitcoin Core developers
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#include <fs.h> #include <fs.h>
#ifndef WIN32 #ifndef WIN32

View File

@ -1,3 +1,7 @@
// Copyright (c) 2017-2019 The Bitcoin Core developers
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#include <qt/test/addressbooktests.h> #include <qt/test/addressbooktests.h>
#include <qt/test/util.h> #include <qt/test/util.h>
#include <test/util/setup_common.h> #include <test/util/setup_common.h>

View File

@ -1,3 +1,7 @@
// Copyright (c) 2018-2019 The Bitcoin Core developers
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#ifndef BITCOIN_QT_TEST_ADDRESSBOOKTESTS_H #ifndef BITCOIN_QT_TEST_ADDRESSBOOKTESTS_H
#define BITCOIN_QT_TEST_ADDRESSBOOKTESTS_H #define BITCOIN_QT_TEST_ADDRESSBOOKTESTS_H

View File

@ -1,3 +1,7 @@
// Copyright (c) 2018 The Bitcoin Core developers
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#include <QApplication> #include <QApplication>
#include <QMessageBox> #include <QMessageBox>
#include <QPushButton> #include <QPushButton>

View File

@ -1,3 +1,7 @@
// Copyright (c) 2018 The Bitcoin Core developers
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#ifndef BITCOIN_QT_TEST_UTIL_H #ifndef BITCOIN_QT_TEST_UTIL_H
#define BITCOIN_QT_TEST_UTIL_H #define BITCOIN_QT_TEST_UTIL_H

View File

@ -1,3 +1,7 @@
// Copyright (c) 2015-2019 The Bitcoin Core developers
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#include <qt/test/wallettests.h> #include <qt/test/wallettests.h>
#include <qt/test/util.h> #include <qt/test/util.h>

View File

@ -1,3 +1,7 @@
// Copyright (c) 2017-2019 The Bitcoin Core developers
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#ifndef BITCOIN_QT_TEST_WALLETTESTS_H #ifndef BITCOIN_QT_TEST_WALLETTESTS_H
#define BITCOIN_QT_TEST_WALLETTESTS_H #define BITCOIN_QT_TEST_WALLETTESTS_H

View File

@ -1,3 +1,7 @@
// Copyright (c) 2017-2019 The Dash Core developers
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#include <boost/test/unit_test.hpp> #include <boost/test/unit_test.hpp>
#include <stdlib.h> #include <stdlib.h>

View File

@ -1,4 +1,7 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
# Copyright (c) 2017-2019 The Bitcoin Core developers
# Distributed under the MIT software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
"""Combine logs from multiple bitcoin nodes as well as the test_framework log. """Combine logs from multiple bitcoin nodes as well as the test_framework log.
This streams the combined log output to stdout. Use combine_logs.py > outputfile This streams the combined log output to stdout. Use combine_logs.py > outputfile

View File

@ -1,4 +1,7 @@
#!/usr/bin/env bash #!/usr/bin/env bash
# Copyright (c) 2018-2019 The Bitcoin Core developers
# Distributed under the MIT software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
export LC_ALL=C export LC_ALL=C

View File

@ -1,4 +1,8 @@
#!/usr/bin/env bash #!/usr/bin/env bash
# Copyright (c) 2018 The Bitcoin Core developers
# Distributed under the MIT software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
# Assert expected shebang lines # Assert expected shebang lines
export LC_ALL=C export LC_ALL=C