[workspace] fix broken [SourceFile.to_abs_path]

Summary: That was obviously wrong :/

Reviewed By: martintrojer

Differential Revision: D24764587

fbshipit-source-id: 6b37dbb7d
master
Jules Villard 4 years ago committed by Facebook GitHub Bot
parent 3d74f39102
commit bd2d2d129e

@ -65,14 +65,18 @@ let from_abs_path ?(warn_on_error = true) fname =
Absolute fname_real
let die_missing_workspace ~rel_path ~foreign_rel_project_root =
L.die UserError
"Missing workspace: please provide the --workspace option. A file (relative path: '%s') was \
encountered whose project root at the time of capture is relative to a workspace (project \
root: '%s'). The same workspace must be specified now."
rel_path foreign_rel_project_root
let reroot_rel_path ~foreign_rel_project_root rel_path =
match (workspace_real, foreign_rel_project_root) with
| None, Some foreign_rel_project_root ->
L.die UserError
"Missing workspace: please provide the --workspace option. A file (relative path: '%s') \
was encountered whose project root at the time of capture is relative to a workspace \
(project root: '%s'). The same workspace must be specified now."
rel_path foreign_rel_project_root
die_missing_workspace ~rel_path ~foreign_rel_project_root
| Some workspace, foreign_offset_opt
when not (Option.equal String.equal foreign_offset_opt workspace_rel_root_opt) ->
(* re-root rel_path relative to the current project_root *)
@ -120,12 +124,19 @@ let pp fmt fname = Format.pp_print_string fmt (to_string fname)
let to_abs_path fname =
match fname with
| Invalid {ml_source_file} ->
L.(die InternalError)
"cannot be called with Invalid source file originating in %s" ml_source_file
L.die InternalError "cannot be called with Invalid source file originating in %s"
ml_source_file
| RelativeProjectRoot rel_path ->
Config.project_root ^/ rel_path
| RelativeProjectRootAndWorkspace {workspace_rel_root; rel_path} ->
workspace_rel_root ^/ Config.project_root ^/ rel_path
let workspace_abs =
match Config.workspace with
| Some workspace ->
workspace
| None ->
die_missing_workspace ~rel_path ~foreign_rel_project_root:workspace_rel_root
in
workspace_abs ^/ workspace_rel_root ^/ rel_path
| Absolute path ->
path

Loading…
Cancel
Save