Monorepo management for opam overlays
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Remove broken default_knot_from_handle; require knot in config file

default_knot_from_handle("gazagnaire.org") produced "git.org" instead
of "git.recoil.org" — it split on the first dot, which fails for
two-part domains.

Rather than trying to guess the knot server from the handle, require
it explicitly in the config file ([identity] knot = "git.recoil.org").
The programmatic Config.v constructor still defaults to "git.recoil.org"
for the verse init bootstrapping case.

+19 -28
+7 -18
lib/config.ml
··· 105 105 106 106 (** {1 Construction} *) 107 107 108 - (** Derive knot (git push server) from handle. E.g., "anil.recoil.org" -> 109 - "git.recoil.org" *) 110 - let default_knot_from_handle handle = 111 - match String.index_opt handle '.' with 112 - | None -> "git." ^ handle (* fallback *) 113 - | Some i -> 114 - let domain = String.sub handle (i + 1) (String.length handle - i - 1) in 115 - "git." ^ domain 108 + let default_knot = "git.recoil.org" 116 109 117 - let v ~root ~handle ?knot ?(packages = []) ?(paths = default_paths) () = 118 - let knot = 119 - match knot with Some k -> k | None -> default_knot_from_handle handle 120 - in 110 + let v ~root ~handle ?(knot = default_knot) ?(packages = []) 111 + ?(paths = default_paths) () = 121 112 { root; handle; knot; packages; paths } 122 113 123 114 let with_package_override t ~name ?branch:branch_opt () = ··· 180 171 *) 181 172 182 173 type workspace_section = { w_root : Fpath.t } 183 - type identity_section = { i_handle : string; i_knot : string option } 184 - 185 - let default_knot = "git.recoil.org" 174 + type identity_section = { i_handle : string; i_knot : string } 186 175 187 176 let workspace_codec : workspace_section Tomlt.t = 188 177 Tomlt.( ··· 196 185 Table.( 197 186 obj (fun i_handle i_knot -> { i_handle; i_knot }) 198 187 |> mem "handle" string ~enc:(fun i -> i.i_handle) 199 - |> opt_mem "knot" string ~enc:(fun i -> i.i_knot) 188 + |> mem "knot" string ~enc:(fun i -> i.i_knot) 200 189 |> finish)) 201 190 202 191 (* Codec for the [packages] table which contains subtree->override mappings *) ··· 213 202 obj (fun workspace identity packages paths -> 214 203 let packages = Option.value ~default:[] packages in 215 204 let paths = Option.value ~default:default_paths paths in 216 - let knot = Option.value ~default:default_knot identity.i_knot in 205 + let knot = identity.i_knot in 217 206 { 218 207 root = workspace.w_root; 219 208 handle = identity.i_handle; ··· 223 212 }) 224 213 |> mem "workspace" workspace_codec ~enc:(fun t -> { w_root = t.root }) 225 214 |> mem "identity" identity_codec ~enc:(fun t -> 226 - { i_handle = t.handle; i_knot = Some t.knot }) 215 + { i_handle = t.handle; i_knot = t.knot }) 227 216 |> opt_mem "packages" packages_table_codec ~enc:(fun t -> 228 217 if t.packages = [] then None else Some t.packages) 229 218 |> opt_mem "paths" paths_codec ~enc:(fun t ->
+1
lib/config.mli
··· 131 131 unit -> 132 132 t 133 133 (** [v ~root ~handle ?knot ?packages ?paths ()] creates a new configuration. 134 + [knot] defaults to ["git.recoil.org"]; it must be set in the config file. 134 135 135 136 @param root Workspace root directory (absolute path). 136 137 @param handle User's handle.
+11 -10
test/test_config.ml
··· 19 19 in 20 20 Alcotest.(check string) "knot" "git.example.com" (Config.knot config) 21 21 22 - let test_default_knot_derivation () = 22 + let test_default_knot () = 23 23 let root = Fpath.v "/home/user/workspace" in 24 24 let config = Config.v ~root ~handle:"anil.recoil.org" () in 25 - (* Default knot should be derived from handle: anil.recoil.org -> git.recoil.org *) 26 - Alcotest.(check string) "derived knot" "git.recoil.org" (Config.knot config) 25 + (* Default knot when not specified *) 26 + Alcotest.(check string) "default knot" "git.recoil.org" (Config.knot config) 27 27 28 - let test_default_knot_no_dot () = 28 + let test_knot_required_in_config_file () = 29 + (* Config file must have [identity] knot = "..." — no guessing *) 29 30 let root = Fpath.v "/home/user/workspace" in 30 - let config = Config.v ~root ~handle:"localuser" () in 31 - (* Fallback when no dot in handle *) 32 - Alcotest.(check string) "fallback knot" "git.localuser" (Config.knot config) 31 + let config = Config.v ~root ~handle:"localuser" ~knot:"git.myserver.com" () in 32 + Alcotest.(check string) 33 + "explicit knot" "git.myserver.com" (Config.knot config) 33 34 34 35 (* Test paths *) 35 36 ··· 136 137 [ 137 138 Alcotest.test_case "basic" `Quick test_create_basic; 138 139 Alcotest.test_case "with knot" `Quick test_create_with_knot; 139 - Alcotest.test_case "default knot derivation" `Quick 140 - test_default_knot_derivation; 141 - Alcotest.test_case "default knot no dot" `Quick test_default_knot_no_dot; 140 + Alcotest.test_case "default knot derivation" `Quick test_default_knot; 141 + Alcotest.test_case "knot required in config" `Quick 142 + test_knot_required_in_config_file; 142 143 Alcotest.test_case "default paths" `Quick test_default_paths; 143 144 Alcotest.test_case "derived paths" `Quick test_derived_paths; 144 145 Alcotest.test_case "custom paths" `Quick test_custom_paths;