package volgo

  1. Overview
  2. Docs
Legend:
Page
Library
Module
Module type
Parameter
Class
Class type
Source

Source file trait.ml

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
(*******************************************************************************)
(*  Volgo - a Versatile OCaml Library for Git Operations                       *)
(*  Copyright (C) 2024-2025 Mathieu Barbin <mathieu.barbin@gmail.com>          *)
(*                                                                             *)
(*  This file is part of Volgo.                                                *)
(*                                                                             *)
(*  Volgo is free software; you can redistribute it and/or modify it under     *)
(*  the terms of the GNU Lesser General Public License as published by the     *)
(*  Free Software Foundation either version 3 of the License, or any later     *)
(*  version, with the LGPL-3.0 Linking Exception.                              *)
(*                                                                             *)
(*  Volgo is distributed in the hope that it will be useful, but WITHOUT ANY   *)
(*  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS  *)
(*  FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License and    *)
(*  the file `NOTICE.md` at the root of this repository for more details.      *)
(*                                                                             *)
(*  You should have received a copy of the GNU Lesser General Public License   *)
(*  and the LGPL-3.0 Linking Exception along with this library. If not, see    *)
(*  <http://www.gnu.org/licenses/> and <https://spdx.org>, respectively.       *)
(*******************************************************************************)

module Top = struct
  module Git = Git
  module Hg = Hg
end

open! Import
module Add = Trait_add
module Branch = Trait_branch
module Commit = Trait_commit
module Config = Trait_config
module Current_branch = Trait_current_branch
module Current_revision = Trait_current_revision
module File_system = Trait_file_system
module Git = Trait_git
module Hg = Trait_hg
module Init = Trait_init
module Log = Trait_log
module Ls_files = Trait_ls_files
module Name_status = Trait_name_status
module Num_status = Trait_num_status
module Refs = Trait_refs
module Show = Trait_show

class type add = Add.t
class type branch = Branch.t
class type commit = Commit.t
class type config = Config.t
class type current_branch = Current_branch.t
class type current_revision = Current_revision.t
class type file_system = File_system.t
class type git = Git.t
class type hg = Hg.t
class type init = Init.t
class type log = Log.t
class type ls_files = Ls_files.t
class type name_status = Name_status.t
class type num_status = Num_status.t
class type refs = Refs.t
class type show = Show.t

class type t = object
  inherit add
  inherit branch
  inherit commit
  inherit config
  inherit current_branch
  inherit current_revision
  inherit file_system
  inherit git
  inherit hg
  inherit init
  inherit log
  inherit ls_files
  inherit name_status
  inherit num_status
  inherit refs
  inherit show
end

class unimplemented : t =
  (* When used through the vcs interface, the context for each method is already
     part of the full error trace. This includes the [repo_root] and/or whatever
     useful arguments for each of the methods in the error messages. We do not
     want to include them here too, as they would simply be printed twice. *)
  let unimplemented ~trait ~method_ =
    Error
      (Err.create
         Pp.O.
           [ Pp.text "Trait "
             ++ Pp_tty.id (module String) trait
             ++ Pp.text " method "
             ++ Pp_tty.id (module String) method_
             ++ Pp.text " is not available in this repository."
           ])
  in
  object
    (* add *)

    method add ~repo_root:_ ~path:_ = unimplemented ~trait:"Vcs.Trait.add" ~method_:"add"

    (* branch *)

    method rename_current_branch ~repo_root:_ ~to_:_ =
      unimplemented ~trait:"Vcs.Trait.branch" ~method_:"rename_current_branch"

    (* commit *)

    method commit ~repo_root:_ ~commit_message:_ =
      unimplemented ~trait:"Vcs.Trait.commit" ~method_:"commit"

    (* config *)

    method set_user_name ~repo_root:_ ~user_name:_ =
      unimplemented ~trait:"Vcs.Trait.config" ~method_:"set_user_name"

    method set_user_email ~repo_root:_ ~user_email:_ =
      unimplemented ~trait:"Vcs.Trait.config" ~method_:"set_user_email"

    (* current_branch *)

    method current_branch ~repo_root:_ =
      unimplemented ~trait:"Vcs.Trait.current_branch" ~method_:"current_branch"

    (* current_revision *)

    method current_revision ~repo_root:_ =
      unimplemented ~trait:"Vcs.Trait.current_revision" ~method_:"current_revision"

    (* file_system *)

    method load_file ~path:_ =
      unimplemented ~trait:"Vcs.Trait.file_system" ~method_:"load_file"

    method save_file ?perms:_ () ~path:_ ~file_contents:_ =
      unimplemented ~trait:"Vcs.Trait.file_system" ~method_:"save_file"

    method read_dir ~dir:_ =
      unimplemented ~trait:"Vcs.Trait.file_system" ~method_:"read_dir"

    (* git *)

    method git
      :  'a.
         ?env:string array
      -> unit
      -> cwd:Absolute_path.t
      -> args:string list
      -> f:(Top.Git.Output.t -> ('a, Err.t) Result.t)
      -> ('a, Err.t) Result.t =
      fun ?env:_ () ~cwd:_ ~args:_ ~f:_ ->
        unimplemented ~trait:"Vcs.Trait.git" ~method_:"git"

    (* hg *)

    method hg
      :  'a.
         ?env:string array
      -> unit
      -> cwd:Absolute_path.t
      -> args:string list
      -> f:(Top.Hg.Output.t -> ('a, Err.t) Result.t)
      -> ('a, Err.t) Result.t =
      fun ?env:_ () ~cwd:_ ~args:_ ~f:_ ->
        unimplemented ~trait:"Vcs.Trait.hg" ~method_:"hg"

    (* init *)

    method init ~path:_ = unimplemented ~trait:"Vcs.Trait.init" ~method_:"init"

    (* log *)

    method get_log_lines ~repo_root:_ =
      unimplemented ~trait:"Vcs.Trait.log" ~method_:"get_log_lines"

    (* ls_files *)

    method ls_files ~repo_root:_ ~below:_ =
      unimplemented ~trait:"Vcs.Trait.ls_files" ~method_:"ls_files"

    (* name_status *)

    method name_status ~repo_root:_ ~changed:_ =
      unimplemented ~trait:"Vcs.Trait.name_status" ~method_:"name_status"

    (* num_status *)

    method num_status ~repo_root:_ ~changed:_ =
      unimplemented ~trait:"Vcs.Trait.num_status" ~method_:"num_status"

    (* refs *)

    method get_refs_lines ~repo_root:_ =
      unimplemented ~trait:"Vcs.Trait.refs" ~method_:"get_refs_lines"

    (* show *)

    method show_file_at_rev ~repo_root:_ ~rev:_ ~path:_ =
      unimplemented ~trait:"Vcs.Trait.show" ~method_:"show_file_at_rev"
  end
OCaml

Innovation. Community. Security.