Module B0_vcs.Git
Git specific operations.
All the following operations assume the repository is of kind Git. Use check_kind to assert this first otherwise the operations will fail in a non-user friendly way.
val check_kind : t -> (unit, string) Stdlib.resultcheck_kind risOk ()ifr's kind isGitand errors otherwise.
Branches
val pp_branch : branch B0_std.Fmt.tpp_branchformats a branch like colorizedgitwould.
val pp_remote_branch : (remote * branch) B0_std.Fmt.tpp_remote_branchformats a remote branch like colorizedgitwould.
val remote_branch_exists : t -> remote:remote -> branch:branch -> (bool, string) Stdlib.resultremote_branch_exists r remote branchasserts whetherbranchexists onremote.
val remote_branch_fetch : ?stdout:B0_std.Os.Cmd.stdo -> ?stderr:B0_std.Os.Cmd.stdo -> t -> remote:remote -> branch:branch -> (unit, string) Stdlib.resultremote_branch_fetch r remote branchfetchesbranchofremote.stderrandstdoutindicates where they should be redirected, defaults to the values ofOs.Cmd.run_status.
val remote_branch_push : ?stdout:B0_std.Os.Cmd.stdo -> ?stderr:B0_std.Os.Cmd.stdo -> t -> force:bool -> src:branch -> remote:remote -> dst:remote -> (unit, string) Stdlib.resultremote_branch_push r ~force ~local ~remote ~dstpushes branchsrcondstofremote. Ifdstdoes not exist onremotea new branch is created. Ifforceistruethis is a forced update.stderrandstdoutindicates where they should be redirected, defaults to the values ofOs.Cmd.run_status.
val remote_branch_delete : ?stdout:B0_std.Os.Cmd.stdo -> ?stderr:B0_std.Os.Cmd.stdo -> t -> force:bool -> remote:remote -> branch:branch -> (unit, string) Stdlib.resultremote_branch_delete r ~remote ~branchdeletesbranchonremote. Ifforceistruethis is a forced update.stderrandstdoutindicates where they should be redirected, defaults to the values ofOs.Cmd.run_status.
val branch_delete : ?stdout:B0_std.Os.Cmd.stdo -> ?stderr:B0_std.Os.Cmd.stdo -> t -> force:bool -> branch:branch -> (unit, string) Stdlib.resultbranch_delete r ~force ~branchdeletesbranchinr. Ifforceistruethis is a forced deletion.stderrandstdoutindicates where they should be redirected, defaults to the values ofOs.Cmd.run_status.
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 : t -> force:bool -> branch:branch -> B0_std.Fpath.t -> commit_ish option -> (t, string) Stdlib.resultcheckout_tmp_branch r ~force ~branch dir commit_ishcreates and checkouts and a branchbranchindirthat points tocommit_ish(ifNonean empty orphan branch is created). Unlessforceistruethis fails ifbranchalready exists. The resulting repo should be used to interact with the checkout. Once finished it should be disposed withtransient_checkout_delete.
val transient_checkout_delete : t -> force:bool -> (unit, string) Stdlib.resulttransient_checkout_delete rdeletes a transient checkout. The branch created bytransient_checkoutis not deleted by the operation, only the corresponding working tree. Ifforcewill delete even if the checkout is dirty.
val with_transient_checkout : ?dir:B0_std.Fpath.t -> t -> force:bool -> branch:branch -> commit_ish option -> (t -> 'a) -> ('a, string) Stdlib.resultwith_transient_checkout r ~force ~branch ~dir commit_ish fcallstransient_checkoutand thenf rwithrthe repo to act on the checkout. Oncef rreturns normally or via an exceptiontransient_checkout_deleteis called.dirdefaults to a temporary directory given byB0_std.Os.Path.tmp.
Working directory
val add : t -> force:bool -> B0_std.Fpath.t list -> (unit, string) Stdlib.resultadd t ~force fsaddsfstor's staged changes. Ifforcebypasses the.gitignores.
val has_staged_changes : t -> (bool, string) Stdlib.resulthas_staged_changes ristrueifrhas staged changes that can becommited andfalseotherwise.
val commit : ?stdout:B0_std.Os.Cmd.stdo -> ?stderr:B0_std.Os.Cmd.stdo -> ?sign:bool -> ?reset_author:bool -> ?amend:bool -> ?msg:string -> t -> (unit, string) Stdlib.resultcommit r ~sign ~msg ~ammend ~reset_authoris basicallygit commit, seegit-commit(1)for the semantics of options.stderrandstdoutindicates where they should be redirected, defaults to the values ofOs.Cmd.run_status.
val commit_exists : t -> commit_ish -> (bool, string) Stdlib.resultcommit_exists r cishchecks whethercishexists inr. In particular using this withHEADallows to know if a commit exists in the branch checkout.
val rm : ?stdout:B0_std.Os.Cmd.stdo -> ?stderr:B0_std.Os.Cmd.stdo -> t -> force:bool -> recurse:bool -> ignore_unmatch:bool -> B0_std.Fpath.t list -> (unit, string) Stdlib.resultrm r ~force ~recurse ~ignore_unmatch filesremovesfilesfrom the working tree and from the index. ifforceremoves the files even if they are not up-to-date. Ifrecurseremoves directories recursively iftrue. Ifignore_unmatchdoes not error if elements offilesdo not match files.stderrandstdoutindicates where they should be redirected, defaults to the values ofOs.Cmd.run_status.