Skip to content

Commit acb0f06

Browse files
committed
change migrate summary
1 parent 6c7be18 commit acb0f06

File tree

1 file changed

+20
-18
lines changed

1 file changed

+20
-18
lines changed

tools/bin/main.ml

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -110,28 +110,30 @@ let main () =
110110
(file, Tools.Migrate.migrate ~entryPointFile:file ~outputMode:`File)
111111
in
112112
let results = List.map process_one files in
113-
let failures =
113+
let migrated, unchanged, failures =
114114
results
115115
|> List.fold_left
116-
(fun acc (_file, res) ->
116+
(fun (migrated, unchanged, failures) (file, res) ->
117117
match res with
118-
| Ok _ -> acc
119-
| Error _ -> acc + 1)
120-
0
118+
| Ok msg ->
119+
let base = Filename.basename file in
120+
if msg = base ^ ": File migrated successfully" then
121+
(migrated + 1, unchanged, failures)
122+
else if msg = base ^ ": File did not need migration" then
123+
(migrated, unchanged + 1, failures)
124+
else
125+
(* Unknown OK message, count as unchanged *)
126+
(migrated, unchanged + 1, failures)
127+
| Error _ -> (migrated, unchanged, failures + 1))
128+
(0, 0, 0)
121129
in
122-
results
123-
|> List.iter (fun (_file, res) ->
124-
match res with
125-
| Ok msg -> print_endline msg
126-
| Error err -> prerr_endline err);
127-
if failures > 0 then
128-
logAndExit
129-
(Error
130-
(Printf.sprintf "Completed with %d failure(s) across %d file(s)"
131-
failures total))
132-
else
133-
logAndExit
134-
(Ok (Printf.sprintf "Migrated %d file(s) successfully" total)))
130+
let summary =
131+
Printf.sprintf
132+
"Migration summary: migrated %d, unchanged %d, failed %d, total %d"
133+
migrated unchanged failures total
134+
in
135+
if failures > 0 then logAndExit (Error summary)
136+
else logAndExit (Ok summary))
135137
| "format-codeblocks" :: rest -> (
136138
match rest with
137139
| ["-h"] | ["--help"] -> logAndExit (Ok formatCodeblocksHelp)

0 commit comments

Comments
 (0)