Module B0_vcs.Git

module Git: sig .. end
Git specific operations.

All the following operations assume the repository is of kind Git. Use B0_vcs.Git.check_kind to assert this first otherwise the operations will fail in a non-user friendly way.

type remote = string 
The type for remote identifiers.
type branch = string 
The type for branch identifiers.
val check_kind : B0_vcs.t -> (unit, string) Pervasives.result
check_kind r is Ok () if r's kind is Git and errors otherwise.


val remote_branch_exists : B0_vcs.t ->
remote:remote ->
branch:branch -> (bool, string) Pervasives.result
remote_branch_exists r remote branch asserts whether branch exists on remote.
val remote_branch_fetch : B0_vcs.t ->
remote:remote ->
branch:branch -> (unit, string) Pervasives.result
remote_branch_fetch r remote branch fetches branch of remote.
val remote_branch_push : B0_vcs.t ->
force:bool ->
src:branch ->
remote:remote ->
dst:remote -> (unit, string) Pervasives.result
remote_branch_push r ~force ~local ~remote ~dst pushes branch src on dst of remote. If dst does not exist on remote a new branch is created. If force is true this is a forced update.
val remote_branch_delete : B0_vcs.t ->
force:bool ->
remote:remote ->
branch:branch -> (unit, string) Pervasives.result
remote_branch_delete r ~remote ~branch deletes branch on remote. If force is true this is a forced update.
val branch_delete : B0_vcs.t ->
force:bool -> branch:branch -> (unit, string) Pervasives.result
branch_delete r ~force ~branch deletes branch in r. If force is true this is a forced deletion.

Transient checkouts

The following functions use git worktree to programmatically act on repo branches without disturbing the user's checkout and/or needing to clone the repo. Use them for short-lived operations that need a work tree and then delete them. The branch that was created can the be pushed on other branches and then deleted.

val transient_checkout : B0_vcs.t ->
force:bool ->
branch:branch ->
B0_std.Fpath.t ->
B0_vcs.commit_ish option -> (B0_vcs.t, string) Pervasives.result
checkout_tmp_branch r ~force ~branch dir commit_ish creates and checkouts and a branch branch in dir that points to commit_ish (if None an orphan branch is created). Unless force is true this fails if branch already exists. The resulting repo should be used to interact with the checkout. Once finished it should be disposed with B0_vcs.Git.transient_checkout_delete.
val transient_checkout_delete : B0_vcs.t -> force:bool -> (unit, string) Pervasives.result
transient_checkout_delete r deletes a transient checkout. The branch created by B0_vcs.Git.transient_checkout is not deleted by the operation, only the corresponding working tree. If force will delete even if the checkout is dirty.

Working directory

val add : B0_vcs.t ->
force:bool -> B0_std.Fpath.t list -> (unit, string) Pervasives.result
add t ~force fs adds fs to r's staged changes. If force bypasses the .gitignores.
val commit : ?sign:bool ->
?reset_author:bool ->
?amend:bool -> ?msg:string -> B0_vcs.t -> (unit, string) Pervasives.result
commit r ~sign ~msg ~ammend ~reset_author is basically git commit, see git-commit(1) for the semantics of options.
val rm : B0_vcs.t ->
force:bool ->
recurse:bool ->
ignore_unmatch:bool ->
B0_std.Fpath.t list -> (unit, string) Pervasives.result
rm r ~force ~recurse ~ignore_unmatch files removes files from the working tree and from the index. if force removes the files even if they are not up-to-date. If recurse removes directories recursively if true. If ignore_unmatch does not error if elements of files do not match files.