Skip to content

Commit 463353e

Browse files
committed
Add support for opam x-maintenance-intent in dune-project
1 parent 30d209d commit 463353e

File tree

6 files changed

+70
-7
lines changed

6 files changed

+70
-7
lines changed

src/dune_config_file/dune_config_file.ml

+9-2
Original file line numberDiff line numberDiff line change
@@ -20,21 +20,27 @@ module Dune_config = struct
2020
type t =
2121
{ authors : string list option
2222
; maintainers : string list option
23+
; maintenance_intent : string list option
2324
; license : string list option
2425
}
2526

2627
let decode =
2728
fields
2829
(let+ authors = field_o "authors" (repeat string)
2930
and+ maintainers = field_o "maintainers" (repeat string)
31+
and+ maintenance_intent = field_o "maintenance_intent" (repeat string)
3032
and+ license = field_o "license" (repeat string) in
31-
{ authors; maintainers; license })
33+
{ authors; maintainers; maintenance_intent; license })
3234
;;
3335

3436
let to_dyn t =
3537
let f = Dyn.(option (list string)) in
3638
Dyn.record
37-
[ "authors", f t.authors; "maintainers", f t.maintainers; "license", f t.license ]
39+
[ "authors", f t.authors
40+
; "maintainers", f t.maintainers
41+
; "maintenance_intent", f t.maintenance_intent
42+
; "license", f t.license
43+
]
3844
;;
3945
end
4046

@@ -359,6 +365,7 @@ module Dune_config = struct
359365
; project_defaults =
360366
{ authors = Some [ "Author Name <[email protected]>" ]
361367
; maintainers = Some [ "Maintainer Name <[email protected]>" ]
368+
; maintenance_intent = Some [ "(latest)" ]
362369
; license = Some [ "LICENSE" ]
363370
}
364371
; experimental = []

src/dune_config_file/dune_config_file.mli

+1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ module Dune_config : sig
88
type t =
99
{ authors : string list option
1010
; maintainers : string list option
11+
; maintenance_intent : string list option
1112
; license : string list option
1213
}
1314

src/dune_lang/package_info.ml

+56-5
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ type t =
99
; bug_reports : string option
1010
; documentation : string option
1111
; maintainers : string list option
12+
; maintenance_intent : string list option
1213
}
1314

1415
let source t = t.source
@@ -29,6 +30,7 @@ let bug_reports t =
2930

3031
let documentation t = t.documentation
3132
let maintainers t = t.maintainers
33+
let maintenance_intent t = t.maintenance_intent
3234

3335
let empty =
3436
{ source = None
@@ -38,6 +40,7 @@ let empty =
3840
; bug_reports = None
3941
; documentation = None
4042
; maintainers = None
43+
; maintenance_intent = None
4144
}
4245
;;
4346

@@ -54,10 +57,20 @@ let example ~authors ~maintainers ~license =
5457
(* homepage and bug_reports are inferred from the source *)
5558
; homepage = None
5659
; bug_reports = None
60+
; maintenance_intent = None
5761
}
5862
;;
5963

60-
let to_dyn { source; license; authors; homepage; bug_reports; documentation; maintainers }
64+
let to_dyn
65+
{ source
66+
; license
67+
; authors
68+
; homepage
69+
; bug_reports
70+
; documentation
71+
; maintainers
72+
; maintenance_intent
73+
}
6174
=
6275
let open Dyn in
6376
record
@@ -67,18 +80,28 @@ let to_dyn { source; license; authors; homepage; bug_reports; documentation; mai
6780
; "documentation", (option string) documentation
6881
; "bug_reports", (option string) bug_reports
6982
; "maintainers", option (list string) maintainers
83+
; "maintenance_intent", option (list string) maintenance_intent
7084
; "authors", option (list string) authors
7185
]
7286
;;
7387

7488
let encode_fields
75-
{ source; authors; license; homepage; documentation; bug_reports; maintainers }
89+
{ source
90+
; authors
91+
; license
92+
; homepage
93+
; documentation
94+
; bug_reports
95+
; maintainers
96+
; maintenance_intent
97+
}
7698
=
7799
let open Encoder in
78100
record_fields
79101
[ field_o "source" Source_kind.encode source
80102
; field_l "authors" string (Option.value ~default:[] authors)
81103
; field_l "maintainers" string (Option.value ~default:[] maintainers)
104+
; field_l "maintenance_intent" string (Option.value ~default:[] maintenance_intent)
82105
; field_l "license" string (Option.value ~default:[] license)
83106
; field_o "homepage" string homepage
84107
; field_o "documentation" string documentation
@@ -109,8 +132,18 @@ let decode ?since () =
109132
field_o "bug_reports" (Syntax.since Stanza.syntax (v (1, 10)) >>> string)
110133
and+ maintainers =
111134
field_o "maintainers" (Syntax.since Stanza.syntax (v (1, 10)) >>> repeat string)
135+
and+ maintenance_intent =
136+
field_o "maintenance_intent" (Syntax.since Stanza.syntax (v (3, 18)) >>> repeat string)
112137
in
113-
{ source; authors; license; homepage; documentation; bug_reports; maintainers }
138+
{ source
139+
; authors
140+
; license
141+
; homepage
142+
; documentation
143+
; bug_reports
144+
; maintainers
145+
; maintenance_intent
146+
}
114147
;;
115148

116149
let superpose t1 t2 =
@@ -126,9 +159,27 @@ let superpose t1 t2 =
126159
; documentation = f t1.documentation t2.documentation
127160
; bug_reports = f t1.bug_reports t2.bug_reports
128161
; maintainers = f t1.maintainers t2.maintainers
162+
; maintenance_intent = f t1.maintenance_intent t2.maintenance_intent
129163
}
130164
;;
131165

132-
let create ~maintainers ~authors ~homepage ~bug_reports ~documentation ~license ~source =
133-
{ maintainers; authors; homepage; bug_reports; documentation; license; source }
166+
let create
167+
~maintainers
168+
~maintenance_intent
169+
~authors
170+
~homepage
171+
~bug_reports
172+
~documentation
173+
~license
174+
~source
175+
=
176+
{ maintainers
177+
; authors
178+
; homepage
179+
; bug_reports
180+
; documentation
181+
; license
182+
; source
183+
; maintenance_intent
184+
}
134185
;;

src/dune_lang/package_info.mli

+2
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ val homepage : t -> string option
77
val bug_reports : t -> string option
88
val documentation : t -> string option
99
val maintainers : t -> string list option
10+
val maintenance_intent : t -> string list option
1011

1112
(** example package info (used for project initialization ) *)
1213
val example
@@ -28,6 +29,7 @@ val superpose : t -> t -> t
2829

2930
val create
3031
: maintainers:string list option
32+
-> maintenance_intent:string list option
3133
-> authors:string list option
3234
-> homepage:string option
3335
-> bug_reports:string option

src/dune_pkg/opam_file.ml

+1
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,7 @@ let load_opam_file_with_contents ~contents:opam_file_string file name =
260260
let info =
261261
Dune_lang.Package_info.create
262262
~maintainers:(get_many "maintainer")
263+
~maintenance_intent:(get_many "x-maintenance-intent")
263264
~authors:(get_many "authors")
264265
~homepage:(get_one "homepage")
265266
~bug_reports:(get_one "bug-reports")

src/dune_rules/opam_create.ml

+1
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,7 @@ let opam_fields project (package : Package.t) =
228228
in
229229
let list_fields =
230230
[ "maintainer", Package_info.maintainers info
231+
; "x-maintenance-intent", Package_info.maintenance_intent info
231232
; "authors", Package_info.authors info
232233
; ( "license"
233234
, match Package_info.license info with

0 commit comments

Comments
 (0)