]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Skip subject line length check for merge commits
authorMichał Kępień <michal@isc.org>
Mon, 18 Jan 2021 13:57:47 +0000 (14:57 +0100)
committerMichał Kępień <michal@isc.org>
Mon, 18 Jan 2021 13:57:47 +0000 (14:57 +0100)
Some merge requests (e.g. those created for release branches) include
merge commits.  Prevent Danger from warning about excessive subject line
length for merge commits.  (While the proper way to detect a merge
commit would be to check the 'parents' attribute of a commit object,
Danger Python does not seem to populate that attribute, so a simple
string search is performed on the commit subject instead.)

dangerfile.py

index 1943df62b112698430b71e3c7c0d0e3a83eff3a3..f9db5bd7d7eac97be9030608a5b461dc3513ba8c 100644 (file)
@@ -49,7 +49,8 @@ target_branch = danger.gitlab.mr.target_branch
 #
 # - WARN if any of the following is true for any commit on the MR branch:
 #
-#     * The length of the subject line exceeds 72 characters.
+#     * The length of the subject line for a non-merge commit exceeds 72
+#       characters.
 #
 #     * There is no log message present (i.e. commit only has a subject) and
 #       the subject line does not contain any of the following strings:
@@ -77,7 +78,7 @@ for commit in danger.git.commits:
         fail('Fixup commits are still present in this merge request. '
              'Please squash them before merging.')
         fixup_error_logged = True
-    if len(subject) > 72:
+    if len(subject) > 72 and not subject.startswith('Merge branch '):
         warn(
             f'Subject line for commit {commit.sha} is too long: '
             f'```{subject}``` ({len(subject)} > 72 characters).'