Module Vcs.Repo_root

The root of a version control repository that is expected to exists on the local file system.

This is a wrapper around Absolute_path.t to increase type safety.

type t
include Ppx_compare_lib.Comparable.S with type t := t
val compare : t Base__Ppx_compare_lib.compare
include Ppx_compare_lib.Equal.S with type t := t
val equal : t Base__Ppx_compare_lib.equal
include Ppx_hash_lib.Hashable.S with type t := t
val hash_fold_t : t Base__Ppx_hash_lib.hash_fold
val hash : t -> Base__Ppx_hash_lib.Std.Hash.hash_value
val sexp_of_t : t -> Sexplib0.Sexp.t
val to_string : t -> Base.string

Given that t = string in the implementation, this function is just the identity.

val of_string : Base.string -> (t, [ `Msg of Base.string ]) Base.Result.t

of_string str returns Ok str if X.invariant str = true, and an error otherwise. This is meant to be used to validate untrusted entries.

val v : Base.string -> t

v str is a convenient wrapper to build a t or raise Invalid_argument. This is typically handy for applying on trusted literals.

val of_absolute_path : Fpath_base.Absolute_path.t -> t
val to_absolute_path : t -> Fpath_base.Absolute_path.t
val relativize : t -> Fpath_base.Absolute_path.t -> Path_in_repo.t Base.option

Given an absolute path that is under this repository, returns its relative repo path. This returns None if the supplied absolute path doesn't point to a path within this repository.

val append : t -> Path_in_repo.t -> Fpath_base.Absolute_path.t

This is useful to access file on the file system.