Skip to content

Conversation

@fanquake
Copy link
Member

After #34084, our copyright headers shouldn't need "managing"; so remove the Python script.

@DrahtBot
Copy link
Contributor

DrahtBot commented Dec 19, 2025

The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

Code Coverage & Benchmarks

For details see: https://corecheck.dev/bitcoin/bitcoin/pulls/34119.

Reviews

See the guideline for information on the review process.

Type Reviewers
ACK fjahr, rkrux, janb84

If your review is incorrectly listed, please copy-paste <!--meta-tag:bot-skip--> into the comment that the bot should ignore.

-BEGIN VERIFY SCRIPT-

sed --in-place --regexp-extended \
       's;( 20[0-2][0-9])(-20[0-2][0-9])? The Bitcoin Core developers;\1-present The Bitcoin Core developers;g' \
       $( git grep -l 'The Bitcoin Core developers' -- ':(exclude)COPYING' ':(exclude)src/ipc/libmultiprocess' ':(exclude)src/minisketch' )

-END VERIFY SCRIPT-
@fanquake fanquake force-pushed the final_copyright_changes branch from 2d851ce to ba6315d Compare December 19, 2025 16:58
@l0rinc
Copy link
Contributor

l0rinc commented Dec 19, 2025

Should we add copyrights to the sources that don't currently have any such header (see: #34084 (comment))?

@fjahr
Copy link
Contributor

fjahr commented Dec 25, 2025

ACK ba6315d

Double-checked that no further references to the script anywhere else in the docs were missed with some grepping.

@fanquake
Copy link
Member Author

Should we add

I think they've all been added. chainparamseeds.h will be added when the script is next run.

@fanquake fanquake marked this pull request as ready for review December 27, 2025 16:23
Copy link
Contributor

@rkrux rkrux left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

crACK ba6315d

While the script is detailed enough, agree on removing it now - prefer to not have code present if it will not be used anymore.

Copy link
Contributor

@janb84 janb84 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ACK ba6315d

PR removes script that manages copyright headers. Given that the new approach is to use -present or no range at all, make the script obsolete.

NIT / suggestion: transform the script to be a linter so that the CI checks for a (correct) copyright:

lint-copyright.py
#!/usr/bin/env python3
#
# Copyright (c) 2025-present The Bitcoin Core developers
# Distributed under the MIT software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php.

"""
Check that all source files have proper copyright headers.
"""

import re
import sys
import fnmatch
from subprocess import check_output

# Excludes for specific files
EXCLUDE = [
   # Autogenerated:
   'src/qt/bitcoinstrings.cpp',
   'src/chainparamsseeds.h',
   # Other external copyrights:
   'src/test/fuzz/FuzzedDataProvider.h',
   'src/tinyformat.h',
   'src/bench/nanobench.h',
   'contrib/devtools/clang-format-diff.py',
   # Python init files:
   '*__init__.py',
   # Devtools bitcoin-tidy example:
   'contrib/devtools/bitcoin-tidy/example_nontrivial-threadlocal.cpp',
   # contrib files:
   'contrib/devtools/check-deps.sh',
   'contrib/macdeploy/gen-sdk.py',
   'contrib/verify-binaries/test.py',
]

EXCLUDE_DIRS = [
   # git subtrees
   "src/crypto/ctaes/",
   "src/leveldb/",
   "src/minisketch/",
   "src/secp256k1/",
   "src/crc32c/",
]

# File extensions to include
INCLUDE = ['*.h', '*.cpp', '*.cc', '*.c', '*.mm', '*.py', '*.sh', '*.bash-completion']

# Compile patterns
EXCLUDE_COMPILED = re.compile('|'.join([fnmatch.translate(m) for m in EXCLUDE]))
INCLUDE_COMPILED = re.compile('|'.join([fnmatch.translate(m) for m in INCLUDE]))

# Generic copyright pattern (accepts any copyright holder)
# Matches "Copyright" with optional "(c)", and optional year/year-range
COPYRIGHT_COMPILED = re.compile(r'Copyright', re.IGNORECASE)


def applies_to_file(filename: str) -> bool:
   for excluded_dir in EXCLUDE_DIRS:
       if filename.startswith(excluded_dir):
           return False
   return (EXCLUDE_COMPILED.match(filename) is None and
           INCLUDE_COMPILED.match(filename) is not None)


def get_filenames_to_examine() -> list[str]:
   git_ls_cmd = ['git', 'ls-files', '--full-name']
   all_files = check_output(git_ls_cmd, text=True).splitlines()
   return sorted([f for f in all_files if applies_to_file(f)])


def file_has_copyright(filename: str) -> bool:
   """
   Check if file has a copyright header in the first 10 lines.
   """
   try:
       with open(filename, 'r', encoding='utf-8') as f:
           # Read first 10 lines
           first_lines = ''.join(f.readline() for _ in range(10))
   except (UnicodeDecodeError, IOError):
       # Skip binary files or files that can't be read
       return True
   
   return COPYRIGHT_COMPILED.search(first_lines) is not None


def main():
   exit_code = 0
   files_to_examine = get_filenames_to_examine()
   
   missing_copyright = []
   for filename in files_to_examine:
       if not file_has_copyright(filename):
           missing_copyright.append(filename)
   
   if missing_copyright:
       print(f"The following {len(missing_copyright)} file(s) have no copyright notice:")
       for filename in missing_copyright:
           print(f"  {filename}")
       exit_code = 1
   
   sys.exit(exit_code)


if __name__ == '__main__':
   main()

@glozow glozow merged commit 7249bcc into bitcoin:master Dec 29, 2025
26 checks passed
@fanquake fanquake deleted the final_copyright_changes branch December 29, 2025 17:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants