aboutsummaryrefslogtreecommitdiff
path: root/contrib/devtools/fix-copyright-headers.py
diff options
context:
space:
mode:
authorisle2983 <[email protected]>2016-09-07 19:21:41 -0600
committerisle2983 <[email protected]>2016-09-10 14:58:42 -0600
commit159597a2b8967c8bc8106d98705d68932500b58a (patch)
treed6a6cbe1b7c1fb4fdba74c4ba5a59b2e0731bff9 /contrib/devtools/fix-copyright-headers.py
parentMerge #8645: Remove unused Qt 4.6 patch. (diff)
downloaddiscoin-159597a2b8967c8bc8106d98705d68932500b58a.tar.xz
discoin-159597a2b8967c8bc8106d98705d68932500b58a.zip
[devtools] script support for managing source file copyright headers
Three subcommands to this script: 1) ./copyright_header.py report Examines git-tracked files with extensions that match: INCLUDE = ['*.h', '*.cpp', '*.cc', '*.c', '*.py'] Helps to: -> Identify source files without copyright -> Identify source files added with something other than "The Bitcoin Core developers" holder so we can be sure it is appropriate -> Identify unintentional typos in the copyright line 2) ./copyright_header.py update Replaces fix-copyright-headers.py. It does file editing in native python rather than subprocessing out to perl as was the case with fix-copyright-headers.py. It also shares code with the 'report' functions. 3) ./copyright_header.py insert Inserts a copyright header into a source file with the proper format and dates.
Diffstat (limited to 'contrib/devtools/fix-copyright-headers.py')
-rwxr-xr-xcontrib/devtools/fix-copyright-headers.py67
1 files changed, 0 insertions, 67 deletions
diff --git a/contrib/devtools/fix-copyright-headers.py b/contrib/devtools/fix-copyright-headers.py
deleted file mode 100755
index 54836bd83..000000000
--- a/contrib/devtools/fix-copyright-headers.py
+++ /dev/null
@@ -1,67 +0,0 @@
-#!/usr/bin/env python3
-"""
-Run this script to update all the copyright headers of files
-that were changed this year.
-
-For example:
-
-// Copyright (c) 2009-2012 The Bitcoin Core developers
-
-it will change it to
-
-// Copyright (c) 2009-2015 The Bitcoin Core developers
-"""
-import subprocess
-import time
-import re
-
-CMD_GIT_LIST_FILES = ['git', 'ls-files']
-CMD_GIT_DATE = ['git', 'log', '--format=%ad', '--date=short', '-1']
-CMD_PERL_REGEX = ['perl', '-pi', '-e']
-REGEX_TEMPLATE = 's/(20\\d\\d)(?:-20\\d\\d)? The Bitcoin/$1-%s The Bitcoin/'
-
-FOLDERS = ["qa/", "src/"]
-EXTENSIONS = [".cpp",".h", ".py"]
-
-
-def get_git_date(file_path):
- d = subprocess.run(CMD_GIT_DATE + [file_path],
- stdout=subprocess.PIPE,
- check=True,
- universal_newlines=True).stdout
- # yyyy-mm-dd
- return d.split('-')[0]
-
-
-def skip_file(file_path):
- for ext in EXTENSIONS:
- if file_path.endswith(ext):
- return False
- else:
- return True
-
-if __name__ == "__main__":
- year = str(time.gmtime()[0])
- regex_current = re.compile("%s The Bitcoin" % year)
- n = 1
- for folder in FOLDERS:
- for file_path in subprocess.run(
- CMD_GIT_LIST_FILES + [folder],
- stdout=subprocess.PIPE,
- check=True,
- universal_newlines=True
- ).stdout.split("\n"):
- if skip_file(file_path):
- # print(file_path, "(skip)")
- continue
- git_date = get_git_date(file_path)
- if not year == git_date:
- # print(file_path, year, "(skip)")
- continue
- if regex_current.search(open(file_path, "r").read()) is not None:
- # already up to date
- # print(file_path, year, "(skip)")
- continue
- print(n, file_path, "(update to %s)" % year)
- subprocess.run(CMD_PERL_REGEX + [REGEX_TEMPLATE % year, file_path], check=True)
- n = n + 1