[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[tor-commits] [tor/master] Add `check-changes` rule for checking formatting of changes files.
commit 9dc90a5b7bf02bc9a034b57bdbc1588745d00447
Author: cypherpunks <cypherpunks@xxxxxxxxxxxxxx>
Date: Fri Mar 6 11:56:57 2015 +0100
Add `check-changes` rule for checking formatting of changes files.
Additional fixes to make the change work;
- fix Python 2 vs 3 issues
- fix some PEP 8 warnings
- handle paths with numbers correctly
- mention the make rule in doc/HACKING.
---
Makefile.am | 6 ++++++
changes/feature15180 | 3 +++
doc/HACKING | 7 ++++---
scripts/maint/lintChanges.py | 18 +++++++++++-------
4 files changed, 24 insertions(+), 10 deletions(-)
diff --git a/Makefile.am b/Makefile.am
index b1f92f5..03dff91 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -111,6 +111,12 @@ check-logs:
./scripts/maint/checkLogs.pl \
src/*/*.[ch] | sort -n
+.PHONY: check-changes
+check-changes:
+ @if test -d "$(top_srcdir)/changes"; then \
+ $(PYTHON) $(top_srcdir)/scripts/maint/lintChanges.py $(top_srcdir)/changes/*; \
+ fi
+
version:
@echo "Tor @VERSION@"
@if test -d "$(top_srcdir)/.git" && test -x "`which git 2>&1;true`"; then \
diff --git a/changes/feature15180 b/changes/feature15180
new file mode 100644
index 0000000..f73ab96
--- /dev/null
+++ b/changes/feature15180
@@ -0,0 +1,3 @@
+ o Minor features (testing):
+ - Add make rule `check-changes` to verify the format of changes files.
+ Closes ticket 15180.
diff --git a/doc/HACKING b/doc/HACKING
index 5c71b74..f006bb6 100644
--- a/doc/HACKING
+++ b/doc/HACKING
@@ -61,9 +61,10 @@ it's a bugfix, mention what bug it fixes and when the bug was
introduced. To find out which Git tag the change was introduced in,
you can use "git describe --contains <sha1 of commit>".
-If at all possible, try to create this file in the same commit where
-you are making the change. Please give it a distinctive name that no
-other branch will use for the lifetime of your change.
+If at all possible, try to create this file in the same commit where you are
+making the change. Please give it a distinctive name that no other branch will
+use for the lifetime of your change. To verify the format of the changes file,
+you can use "make check-changes".
When we go to make a release, we will concatenate all the entries
in changes to make a draft changelog, and clear the directory. We'll
diff --git a/scripts/maint/lintChanges.py b/scripts/maint/lintChanges.py
index 69963ae..19d03ec 100755
--- a/scripts/maint/lintChanges.py
+++ b/scripts/maint/lintChanges.py
@@ -1,19 +1,22 @@
#!/usr/bin/python
+from __future__ import print_function
+from __future__ import with_statement
import sys
import re
-
+import os
def lintfile(fname):
have_warned = []
+
def warn(s):
if not have_warned:
have_warned.append(1)
- print fname,":"
- print "\t",s
+ print("{}:".format(fname))
+ print("\t{}".format(s))
- m = re.search(r'(\d{3,})', fname)
+ m = re.search(r'(\d{3,})', os.path.basename(fname))
if m:
bugnum = m.group(1)
else:
@@ -23,7 +26,7 @@ def lintfile(fname):
contents = f.read()
if bugnum and bugnum not in contents:
- warn("bug number %s does not appear"%bugnum)
+ warn("bug number {} does not appear".format(bugnum))
lines = contents.split("\n")
isBug = ("bug" in lines[0] or "fix" in lines[0])
@@ -44,11 +47,12 @@ def lintfile(fname):
if re.search(r'[bB]ug (\d+)', contents):
if not re.search(r'[Bb]ugfix on ', contents):
warn("bugfix does not say 'bugfix on X.Y.Z'")
- elif not re.search('[fF]ixes ([a-z ]*)bug (\d+); bugfix on ', contents):
+ elif not re.search('[fF]ixes ([a-z ]*)bug (\d+); bugfix on ',
+ contents):
warn("bugfix incant is not semicoloned")
-if __name__=='__main__':
+if __name__ == '__main__':
for fname in sys.argv[1:]:
if fname.endswith("~"):
continue
_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits