-
Notifications
You must be signed in to change notification settings - Fork 407
Internal repos-config new syntax
#6393
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
rjbou
wants to merge
5
commits into
ocaml:master
Choose a base branch
from
rjbou:new-repos-config
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
7f11e10
global state: add global lock to the record in order to retrieve it w…
rjbou e708dee
format upgrade: Use already created global lock instead of recreating…
rjbou 41032ac
Add some documentation in format upgrade about repo & switch upgrades
rjbou 6608f37
opam root version: make seds on root version more robust
rjbou e9cf578
Change repos-config file format
rjbou File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1395,7 +1395,7 @@ module ConfigSyntax = struct | |
| let internal = "config" | ||
| let format_version = OpamVersion.of_string "2.1" | ||
| let file_format_version = OpamVersion.of_string "2.0" | ||
| let root_version = OpamVersion.of_string "2.2" | ||
| let root_version = OpamVersion.of_string "2.6~alpha1" | ||
|
|
||
| let default_old_root_version = OpamVersion.of_string "2.1~~previous" | ||
|
|
||
|
|
@@ -1966,7 +1966,9 @@ module InitConfig = struct | |
| include SyntaxFile(InitConfigSyntax) | ||
| end | ||
|
|
||
| module Repos_configSyntax = struct | ||
| (** Repositories configuration *) | ||
|
|
||
| module Repos_config_LegacySyntax = struct | ||
|
|
||
| let internal = "repos-config" | ||
| let format_version = OpamVersion.of_string "2.0" | ||
|
|
@@ -2000,6 +2002,145 @@ module Repos_configSyntax = struct | |
| let pp = pp_cond () | ||
|
|
||
| end | ||
|
|
||
| module Repos_config_Legacy = struct | ||
| include Repos_config_LegacySyntax | ||
| include SyntaxFile(Repos_config_LegacySyntax) | ||
| module BestEffort = MakeBestEffort(Repos_config_LegacySyntax) | ||
| end | ||
|
|
||
| (* A repository configuration section "repo" in <repos/reposèconfig> file *) | ||
|
|
||
| module Repo_configSyntax = struct | ||
| let internal = "repo-config" | ||
| let format_version = OpamVersion.of_string "2.6" | ||
|
|
||
| type t = { | ||
| url: url; | ||
| trust: trust_anchors option; | ||
| errors: (string * Pp.bad_format) list; | ||
| } | ||
|
|
||
| let empty = { | ||
| url = OpamUrl.empty; | ||
| trust = None; | ||
| errors = []; | ||
| } | ||
|
|
||
| let create ?trust url = { url; trust; errors = [] } | ||
|
|
||
| let url t = t.url | ||
| let trust t = t.trust | ||
|
|
||
| let fields = [ | ||
| "url", Pp.ppacc | ||
| (fun url t -> { t with url }) | ||
| (fun { url; _ } -> url) | ||
| Pp.V.url; | ||
| "fingerprint", Pp.ppacc_opt | ||
| (fun fingerprints t -> | ||
| match t.trust with | ||
| | Some x -> { t with trust = Some { x with fingerprints }} | ||
| | None -> { t with trust = Some { fingerprints; quorum = 1}}) | ||
| (fun t -> | ||
| match t.trust with | ||
| | Some {fingerprints; _} -> Some fingerprints | ||
| | None -> None) | ||
| (Pp.V.map_list ~depth:1 Pp.V.string); | ||
| "quorum", | ||
| Pp.ppacc_opt | ||
| (fun quorum t -> | ||
| match t.trust with | ||
| | Some x -> { t with trust = Some { x with quorum }} | ||
| | None -> { t with trust = Some { quorum; fingerprints = []}}) | ||
| (fun t -> | ||
| match t.trust with | ||
| | Some {quorum; _} -> Some quorum | ||
| | None -> None) | ||
| Pp.V.int; | ||
| ] | ||
|
|
||
| let pp_contents : (opamfile_item list, t) OpamPp.t = | ||
| let name = internal in | ||
| Pp.I.fields ~name ~empty fields | ||
| -| Pp.I.on_errors ~name (fun t e -> {t with errors = e::t.errors}) | ||
| -| Pp.pp ~name | ||
| (fun ~pos t -> | ||
| if t.url = OpamUrl.empty then | ||
| OpamPp.bad_format ~pos "missing URL in repo field" | ||
| else t) | ||
| (fun x -> x) | ||
|
|
||
| let pp = Pp.I.map_file pp_contents | ||
|
|
||
| end | ||
|
|
||
| module Repo_config = struct | ||
| include Repo_configSyntax | ||
| include SyntaxFile(Repo_configSyntax) | ||
| end | ||
|
|
||
| (* Repositories configuration <repos/repos-config> *) | ||
|
|
||
| module Repos_configSyntax = struct | ||
|
|
||
| let internal = "repos-config" | ||
| let format_version = OpamVersion.of_string "2.6" | ||
| let file_format_version = OpamVersion.of_string "2.0" | ||
|
|
||
| type repo = Repo_config.t | ||
| type t = { | ||
| opam_version: opam_version; | ||
| repos : repo OpamRepositoryName.Map.t; | ||
| } | ||
|
|
||
| let empty = { | ||
| opam_version = file_format_version; | ||
| repos = OpamRepositoryName.Map.empty; | ||
| } | ||
|
|
||
| let create ?opam_version repos = { | ||
| opam_version = OpamStd.Option.default file_format_version opam_version; | ||
| repos; | ||
| } | ||
|
|
||
| let opam_version t = t.opam_version | ||
| let repos t = t.repos | ||
| let with_opam_version opam_version t = { t with opam_version } | ||
| let with_repos repos t = { t with repos } | ||
|
|
||
| let fields = [ | ||
| "opam-version", Pp.ppacc with_opam_version opam_version | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. shouldn't opam-version kept at 2.0 but a new field be added similar to opam-root-version in /config? |
||
| (Pp.V.string -| Pp.of_module "opam-version" (module OpamVersion)); | ||
| ] | ||
|
|
||
| let sections = [ | ||
| "repo", Pp.ppacc with_repos repos | ||
| ((Pp.map_list | ||
| (Pp.map_pair | ||
| (Pp.pp | ||
| (fun ~pos -> function | ||
| | Some o -> OpamRepositoryName.of_string o | ||
| | None -> Pp.bad_format ~pos "missing repo name") | ||
| (fun b -> Some (OpamRepositoryName.to_string b))) | ||
| Repo_config.pp_contents)) | ||
| -| Pp.of_pair "RepositoryNameMap" | ||
| OpamRepositoryName.Map.(of_list, bindings)) | ||
| ] | ||
|
|
||
| let pp_cond ?f ?condition () = | ||
| let name = internal in | ||
| let format_version = file_format_version in | ||
| Pp.I.map_file @@ | ||
| Pp.I.check_opam_version ?f ~format_version () | ||
| -| Pp.I.opam_version ~format_version () | ||
| -| Pp.I.fields ~name ~empty ~sections fields | ||
| -| Pp.I.show_errors ~name ?condition () | ||
|
|
||
| let pp = pp_cond () | ||
|
|
||
| end | ||
|
|
||
| module Repos_config = struct | ||
| include Repos_configSyntax | ||
| include SyntaxFile(Repos_configSyntax) | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.