@ -25,12 +25,29 @@ module FileRenamings = struct
let from_json input : t =
let from_json input : t =
let j = Yojson . Basic . from_string input in
let j = Yojson . Basic . from_string input in
let renaming_of_assoc assoc : renaming =
let renaming_of_assoc assoc : renaming =
try
match assoc with
match assoc with
| ` Assoc [ ( " current " , ` String current ) ; ( " previous " , ` String previous ) ]
| ` Assoc l
-> (
let current_opt = List . Assoc . find ~ equal : String . equal l " current " in
let previous_opt = List . Assoc . find ~ equal : String . equal l " previous " in
match ( current_opt , previous_opt ) with
| Some ` String current , Some ` String previous
-> { current ; previous }
-> { current ; previous }
| None , _
-> raise ( Yojson . Json_error " \" current \" field missing " )
| Some _ , None
-> raise ( Yojson . Json_error " \" previous \" field missing " )
| Some _ , Some ` String _
-> raise ( Yojson . Json_error " \" current \" field is not a string " )
| Some _ , Some _
-> raise ( Yojson . Json_error " \" previous \" field is not a string " ) )
| _
| _
-> failwithf " Expected JSON object of the following form: '%s', but instead got: '%s' "
-> raise ( Yojson . Json_error " not a record " )
" { \" current \" : \" aaa.java \" , \" previous \" : \" BBB.java \" } "
with Yojson . Json_error err ->
failwithf
" Error parsing file renamings: %s@ \n Expected JSON object of the following form: '%s', but instead got: '%s' "
err " { \" current \" : \" aaa.java \" , \" previous \" : \" BBB.java \" } "
( Yojson . Basic . to_string assoc )
( Yojson . Basic . to_string assoc )
in
in
match j with
match j with