Skip to content

Commit 86567a8

Browse files
committed
github: handle more main merge commit msg patterns
1 parent 5dd40af commit 86567a8

File tree

1 file changed

+6
-9
lines changed

1 file changed

+6
-9
lines changed

lib/github.ml

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -38,20 +38,17 @@ let event_of_filename filename =
3838

3939
let is_main_merge_message ~msg:message ~branch (cfg : Config_t.config) =
4040
match cfg.main_branch_name with
41-
| Some main_branch when String.equal branch main_branch ->
41+
| Some main_branch ->
4242
(*
4343
handle "Merge <main branch> into <feature branch>" commits when they are merged into main branch
4444
we should have already seen these commits on the feature branch but for some reason they are distinct:true
4545
*)
46-
let prefix = sprintf "Merge branch '%s' into " main_branch in
47-
let prefix2 = sprintf "Merge remote-tracking branch 'origin/%s' into " main_branch in
48-
let title = Common.first_line message in
49-
String.is_prefix title ~prefix || String.is_prefix title ~prefix:prefix2
50-
| Some main_branch ->
51-
let expect = sprintf "Merge branch '%s' into %s" main_branch branch in
52-
let expect2 = sprintf "Merge remote-tracking branch 'origin/%s' into %s" main_branch branch in
46+
let re =
47+
Str.regexp (sprintf {|^Merge\( remote-tracking\)? branch '\(origin/\)?%s'\( of .+\)? into \(.+\)$|} main_branch)
48+
in
5349
let title = Common.first_line message in
54-
String.equal title expect || String.equal title expect2
50+
let matched = Str.string_match re title 0 in
51+
matched && (String.equal branch main_branch || String.equal branch (Str.matched_group 4 title))
5552
| _ -> false
5653

5754
let modified_files_of_commit commit = List.concat [ commit.added; commit.removed; commit.modified ]

0 commit comments

Comments
 (0)