File tree Expand file tree Collapse file tree
test/blackbox-tests/test-cases/subst Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -141,8 +141,7 @@ let subst_file path ~map opam_package_files =
141141 try
142142 subst_string (" version: \" %%" ^ " VERSION_NUM" ^ " %%\" " ) ~map (Path. source path)
143143 with
144- | User_error. E e ->
145- raise (User_error. E { e with loc = Some (Loc. in_file (Path. source path)) }))
144+ | User_error. E _ -> None )
146145 else None
147146 in
148147 let path = Path. source path in
264263
265264let make_watermark_map ~commit ~version ~dune_project ~info =
266265 let dune_project = Dune_project. project dune_project in
266+ let version =
267+ match version with
268+ | Some _ -> version
269+ | None -> Option. map ~f: Package_version. to_string (Dune_project. version dune_project)
270+ in
267271 let version_num =
268272 let open Option.O in
269273 let + version = version in
Original file line number Diff line number Diff line change 1+ - fix: ` $ dune subst ` should not fail when adding the version field in opam
2+ files (#11801 , fixes #11045 , @btjorge )
3+
4+ - feature: ` $ dune subst ` use version from ` dune-project ` when no version control repository
5+ has been detected
Original file line number Diff line number Diff line change @@ -49,6 +49,7 @@ let equal : t -> t -> bool = phys_equal
4949let hash = Poly. hash
5050let packages t = t.packages
5151let name t = t.name
52+ let version t = t.version
5253let root t = t.root
5354let stanza_parser t = Dune_lang.Decoder. set key t t.stanza_parser
5455let file t = t.project_file
Original file line number Diff line number Diff line change 88val to_dyn : t -> Dyn .t
99val packages : t -> Package .t Package.Name.Map .t
1010val name : t -> Dune_project_name .t
11+ val version : t -> Package_version .t option
1112val root : t -> Path.Source .t
1213val stanza_parser : t -> Dune_lang.Stanza .t list Dune_lang.Decoder .t
1314val generate_opam_files : t -> bool
Original file line number Diff line number Diff line change 1+ dune subst should not fail when adding the version field in opam files
2+
3+ $ cat > dune-project << EOF
4+ > (lang dune 3.19 )
5+ > (name test)
6+ > (version 0.1 )
7+ > (generate_opam_files)
8+ > (package (name test) (allow_empty))
9+ > EOF
10+
11+ $ dune build
12+
13+ $ cat test. opam
14+ # This file is generated by dune, edit dune-project instead
15+ opam-version: " 2.0"
16+ version: " 0.1"
17+ depends: [
18+ " dune" {>= " 3.19" }
19+ " odoc" {with-doc}
20+ ]
21+ build: [
22+ [" dune" " subst" ] {dev}
23+ [
24+ " dune"
25+ " build"
26+ " -p"
27+ name
28+ " -j"
29+ jobs
30+ " @ install"
31+ " @ runtest" {with-test}
32+ " @ doc" {with-doc}
33+ ]
34+ ]
35+ x-maintenance-intent: [" (latest)" ]
36+
37+ $ dune subst
38+
39+ $ cat test. opam
40+ version: " 0.1"
41+ # This file is generated by dune, edit dune-project instead
42+ opam-version: " 2.0"
43+ version: " 0.1"
44+ depends: [
45+ " dune" {>= " 3.19" }
46+ " odoc" {with-doc}
47+ ]
48+ build: [
49+ [" dune" " subst" ] {dev}
50+ [
51+ " dune"
52+ " build"
53+ " -p"
54+ name
55+ " -j"
56+ jobs
57+ " @ install"
58+ " @ runtest" {with-test}
59+ " @ doc" {with-doc}
60+ ]
61+ ]
62+ x-maintenance-intent: [" (latest)" ]
Original file line number Diff line number Diff line change @@ -11,3 +11,19 @@ Demonstrate $ dune subst without a git repository
1111
1212 $ cat README. md
1313 test
14+
15+ dune subst should take the project version from the dune-project file when
16+ there is no vcs
17+
18+ $ cat > dune-project << EOF
19+ > (lang dune 3.19 )
20+ > (name test)
21+ > (version 0.1 )
22+ > EOF
23+
24+ $ echo " %% VERSION %%" > README. md
25+
26+ $ dune subst
27+
28+ $ cat README. md
29+ 0.1
You can’t perform that action at this time.
0 commit comments