Skip to content

Commit 208ffff

Browse files
Extended the rules for review-patch.py for files w/o extension
Implement these rules in test code and describe them in comment
1 parent 54ba134 commit 208ffff

File tree

1 file changed

+31
-3
lines changed

1 file changed

+31
-3
lines changed

review-patch.py

Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,32 @@ def review_patches(patches):
4747

4848
added_files.sort()
4949
for f in added_files:
50-
dir_id = f.rfind("/") + 1
50+
dir_id = f.rfind("/") + 1 # f[dir_id:] is name.type[.source.txt]
51+
if dir_id == 0:
52+
out += "\tMalformed patch: " + f + " should be of the form 'b/db/type/name.type[.source.txt]'\n"
53+
ret = 1
54+
local_error = True
55+
continue
56+
if not "/db/" in f:
57+
continue # file is not in db subdir
58+
5159
ext_id = dir_id + f[dir_id:].find(".")
52-
if ext_id != -1:
53-
ext = f[ext_id + 1:]
60+
if ext_id == dir_id-1: # check if f is .../db/type/type or .../db/misc/type
61+
dir_id2 = f.rfind("/", 0, dir_id-1)+1 # f[dir_id2:dir_id] is subdir within db/
62+
if f[dir_id2:dir_id-1] == f[dir_id:]:
63+
pass # ok, is .../db/type/type
64+
if f[dir_id2] in ('.', '_'):
65+
out += "\t" + f + ": Subdir names may not start with . or _\n"
66+
ret = 1
67+
local_error = True
68+
elif f[dir_id2:dir_id-1] == 'misc':
69+
pass # ok, is .../db/msic/type
70+
else:
71+
out += "\t" + f + ": File is not in proper directory according to extension\n"
72+
ret = 1
73+
local_error = True
74+
else:
75+
ext = f[ext_id + 1:] # ext is type[.source.txt]
5476
if ext.endswith("source.txt"):
5577
real_db_file = f[:-len(".source.txt")]
5678
try:
@@ -87,6 +109,12 @@ def review_patches(patches):
87109
- Every file with extension '.X' has to be in directory 'db/X' according to
88110
its extension. Note that case sensitivity is important and must be
89111
respected.
112+
- If a file has no (typical) extension (e.g. AppleDouble), then it has to go
113+
to folder db/misc or must be given a descriptive short name and no extension
114+
and appear in a directory of the same name (e.g. db/AppleDouble/AppleDouble).
115+
The corresponding .source.txt needs to explain this in a line starting with
116+
'NOTE: ' (see e.g. db/AppleDouble/AppleDouble.source.txt). No leading . or _
117+
(e.g. .DS_Store --> DS_Store)
90118
"""
91119
print "Usage: " + sys.argv[0] + " [[patch1], [patch2], ...]"
92120
print "Usage: " + sys.argv[0] + " *.patch"

0 commit comments

Comments
 (0)