File tree Expand file tree Collapse file tree 2 files changed +10
-12
lines changed Expand file tree Collapse file tree 2 files changed +10
-12
lines changed Original file line number Diff line number Diff line change @@ -20,7 +20,7 @@ module Action (Github_api : Api.Github) (Slack_api : Api.Slack) = struct
20
20
let filter_by_branch = Rule.Prefix. filter_by_branch ~branch ~main_branch in
21
21
n.commits
22
22
|> List. filter ~f: (fun c ->
23
- let skip = Github. is_main_merge_message ~msg: c.message ~branch cfg in
23
+ let skip = Github. is_merge_commit_to_ignore ~cfg ~branch c in
24
24
if skip then log#info " main branch merge, ignoring %s: %s" c.id (first_line c.message);
25
25
not skip
26
26
)
Original file line number Diff line number Diff line change @@ -36,25 +36,23 @@ let event_of_filename filename =
36
36
| [ kind; _; " json" ] -> Some kind
37
37
| _ -> None
38
38
39
- let is_main_merge_message ~msg :message ~branch (cfg : Config_t.config ) =
39
+ let merge_commit_re = Re2. create_exn {|^ Merge (?: remote- tracking)? branch '(?: origin/ )?.+ '(?: of .+ )? into (.+ )$| }
40
+
41
+ let is_merge_commit_to_ignore ~(cfg : Config_t.config ) ~branch commit =
40
42
match cfg.main_branch_name with
41
- | Some main_branch ->
43
+ | Some main_branch when String. equal branch main_branch ->
42
44
(*
43
- handle "Merge <main branch> into <feature branch>" commits when they are merged into main branch
45
+ handle "Merge <any branch> into <feature branch>" commits when they are merged into main branch
44
46
we should have already seen these commits on the feature branch but for some reason they are distinct:true
45
47
*)
46
- let re =
47
- Re2. create_exn
48
- (sprintf {|^ Merge (?: remote- tracking)? branch '(?: origin/ )?% s'(?: of .+ )? into (.+ )$| } (Re2. escape main_branch))
49
- in
50
- let title = Common. first_line message in
48
+ let title = Common. first_line commit.message in
51
49
begin
52
50
try
53
- let other_branch = Re2. find_first_exn ~sub: (`Index 1 ) re title in
54
- String. equal branch main_branch || String. equal branch other_branch
51
+ let receiving_branch = Re2. find_first_exn ~sub: (`Index 1 ) merge_commit_re title in
52
+ not @@ String. equal branch receiving_branch
55
53
with Re2.Exceptions. Regex_match_failed _ -> false
56
54
end
57
- | _ -> false
55
+ | Some _ | None -> false
58
56
59
57
let modified_files_of_commit commit = List. concat [ commit.added; commit.removed; commit.modified ]
60
58
You can’t perform that action at this time.
0 commit comments