mirror of
https://gitlab.isc.org/isc-projects/bind9
synced 2025-08-22 18:19:42 +00:00
Detect work-in-progress commits in danger CI
To avoid accidentally merging unfinished work, detect prohibited keywords at the start of the subject line. If the first word is any of the following, fail the check: WIP, wip, DROP, drop, TODO, todo The only slightly controversial is the lowercase "drop" which might have a legitimate use - seems like four commits in the history used it as a start of a sentence. However, since people commonly use "drop" to indicate a commit should be dropped before merging, let's prohibit it as well. In case of false-positive, "Drop" with a capitalized first letter can always be used.
This commit is contained in:
parent
e901342dd9
commit
402b11431c
@ -62,6 +62,9 @@ mr = proj.mergerequests.get(os.environ["CI_MERGE_REQUEST_IID"])
|
|||||||
#
|
#
|
||||||
# * The subject line starts with "fixup!" or "Apply suggestion".
|
# * The subject line starts with "fixup!" or "Apply suggestion".
|
||||||
#
|
#
|
||||||
|
# * The subject line starts with a prohibited word indicating a work in
|
||||||
|
# progress commit (e.g. "WIP").
|
||||||
|
#
|
||||||
# * The subject line contains a trailing dot.
|
# * The subject line contains a trailing dot.
|
||||||
#
|
#
|
||||||
# * There is no empty line between the subject line and the log message.
|
# * There is no empty line between the subject line and the log message.
|
||||||
@ -87,6 +90,9 @@ mr = proj.mergerequests.get(os.environ["CI_MERGE_REQUEST_IID"])
|
|||||||
# "[2]", etc.) which allows e.g. long URLs to be included in the
|
# "[2]", etc.) which allows e.g. long URLs to be included in the
|
||||||
# commit log message.
|
# commit log message.
|
||||||
|
|
||||||
|
PROHIBITED_WORDS_RE = re.compile(
|
||||||
|
"^(WIP|wip|DROP|drop|DROPME|checkpoint|experiment|TODO|todo)[^a-zA-Z]"
|
||||||
|
)
|
||||||
fixup_error_logged = False
|
fixup_error_logged = False
|
||||||
for commit in danger.git.commits:
|
for commit in danger.git.commits:
|
||||||
message_lines = commit.message.splitlines()
|
message_lines = commit.message.splitlines()
|
||||||
@ -99,6 +105,12 @@ for commit in danger.git.commits:
|
|||||||
"Please squash them before merging."
|
"Please squash them before merging."
|
||||||
)
|
)
|
||||||
fixup_error_logged = True
|
fixup_error_logged = True
|
||||||
|
match = PROHIBITED_WORDS_RE.search(subject)
|
||||||
|
if match:
|
||||||
|
fail(
|
||||||
|
f"Prohibited keyword `{match.groups()[0]}` detected "
|
||||||
|
f"at the start of a subject line in commit {commit.sha}."
|
||||||
|
)
|
||||||
if len(subject) > 72 and not subject.startswith("Merge branch "):
|
if len(subject) > 72 and not subject.startswith("Merge branch "):
|
||||||
warn(
|
warn(
|
||||||
f"Subject line for commit {commit.sha} is too long: "
|
f"Subject line for commit {commit.sha} is too long: "
|
||||||
|
Loading…
x
Reference in New Issue
Block a user