Andriy Gelman (12021-08-15): > That sounds fine. See the attached code.
I have tested it against the 2721 commits I have since the beginning of the year, it finds 56 to object, about half of them real problems, a few with unusually long context (I set the limit at the last percentile) and admittedly a few exceptional case. Since these are warnings and can safely be ignored, I think it is an acceptable rate of false-positives. Regards, -- Nicolas George
def check_commit_message(msg) : (summary, _, rest) = msg.partition("\n") (sep, _, body) = rest.partition("\n") if sep != "" : return "The second line of the commit message must be empty." if len(summary) > 200 : return "The first line of the commit message is way too long." (context, colon, details) = summary.partition(": ") if colon == "" or len(context) > 32 : return "The first line of the commit message must start " + \ "with a context terminated by a colon and a space, " + \ "for example \"lavu/opt: \" or \"doc: \"." longlines = 0 lines = 0 for line in body.split("\n") : lines = lines + 1 if len(line) <= 76 : continue spaces = 0 nontext = 0 probablecode = 0 # Try to detect code lines, probably URLs too for c in line : if c == ' ' : spaces = spaces + 1 if not ((c >= 'a' and c <= 'z') or (c >= 'A' and c <= 'Z') or (c >= '0' and c <= '9') or c == ' ' or c == '.' or c == ',' or c == ';' or c == ':' or c == '-' or c == "'") : nontext = nontext + 1 if c == '/' : probablecode = probablecode + 1 if nontext > 8 or probablecode > 0 or spaces < 8 : continue longlines = longlines + 1 if longlines > lines / 4 : return "Please wrap lines in the body of the commit message between 60 and 72 characters." return None def test(expect, msg) : res = check_commit_message(msg) if expect == None and res != None : print("Should have succeeded, failed with:", res, "\n", msg) elif expect != None and res == None : print("Should have failed, succeeded:\n", msg) elif expect != None and res != None : try : res.index(expect) except : print("Should have failed with", expect, "but failed with:", res, "\n", msg) import sys def test_stdin() : commit = "???" msg = "" for line in sys.stdin : if line.startswith("commit") : commit = line[7 : len(line) - 1] if line.startswith(" ") : msg = msg + line[4 :] if line == "\n" and msg != "" : res = check_commit_message(msg) if res != None : print(commit, res) msg = "" test(None, """avformat/oggdec: Use av_realloc_array()""") test(None, """avcodec/cbs: add a helper to read extradata within packet side data Using ff_cbs_read() on the raw buffer will not parse it as extradata, resulting in parsing errors for example when handling ISOBMFF avcC. This helper works around that. """) test("context", """return value check for init_get_bits in vc1dec.c""") test("wrap", """test: blah Sed ut perspiciatis, unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam eaque ipsa, quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt, explicabo. Nemo enim ipsam voluptatem, quia voluptas sit, aspernatur """) test_stdin()
signature.asc
Description: PGP signature
_______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".