File tree 5 files changed +15
-1
lines changed
5 files changed +15
-1
lines changed Original file line number Diff line number Diff line change @@ -127,3 +127,5 @@ users)
127
127
## opam-format
128
128
129
129
## opam-core
130
+ * ` OpamConsole.log ` : does not keep log messages before initialization if the code is ran through a library [ #6487 @kit-ty-kate ]
131
+ * ` OpamCoreConfig.in_opam ` : was added [ #6487 @kit-ty-kate ]
Original file line number Diff line number Diff line change @@ -483,6 +483,7 @@ let json_out () =
483
483
(Printexc. to_string e)
484
484
485
485
let main () =
486
+ OpamCoreConfig. set_in_opam () ;
486
487
if Sys. win32 then begin
487
488
(* Disable the critical error handling dialog *)
488
489
ignore (OpamStubs. setErrorMode (1 lor OpamStubs. getErrorMode () ));
Original file line number Diff line number Diff line change @@ -562,7 +562,7 @@ let log section ?(level=1) fmt =
562
562
| None -> debug_level
563
563
| exception Not_found -> 0
564
564
in
565
- if not OpamCoreConfig. (! r.set) then
565
+ if not OpamCoreConfig. (! r.set) && OpamCoreConfig. ( ! r.in_opam) then
566
566
let b = Buffer. create 128 in
567
567
let timestamp = timestamp () ^ " " in
568
568
let k _ = Queue. push (level, timestamp, Buffer. contents b) pending in
Original file line number Diff line number Diff line change @@ -67,6 +67,7 @@ type t = {
67
67
cygbin : string option ;
68
68
git_location : string option ;
69
69
set : bool ;
70
+ in_opam : bool ;
70
71
}
71
72
72
73
type 'a options_fun =
@@ -109,6 +110,7 @@ let default = {
109
110
cygbin = None ;
110
111
git_location = None ;
111
112
set = false ;
113
+ in_opam = false ;
112
114
}
113
115
114
116
let setk k t
@@ -151,6 +153,7 @@ let setk k t
151
153
cygbin = (match cygbin with Some _ -> cygbin | None -> t.cygbin);
152
154
git_location = (match git_location with Some _ -> git_location | None -> t.git_location);
153
155
set = true ;
156
+ in_opam = t.in_opam;
154
157
}
155
158
156
159
let set t = setk (fun x () -> x) t
@@ -212,3 +215,5 @@ let answer_is_yes () =
212
215
| _ -> false
213
216
214
217
let developer = not (String. equal OpamCoreConfigDeveloper. value " " )
218
+
219
+ let set_in_opam () = r := {default with in_opam = true }
Original file line number Diff line number Diff line change @@ -78,6 +78,8 @@ type t = private {
78
78
(* * Windows specific: the full path of the git binary to use on Windows. *)
79
79
set : bool ;
80
80
(* * Options have not yet been initialised (i.e. defaults are active) *)
81
+ in_opam : bool ;
82
+ (* * Indicates that the code is running inside of opam and not as a library *)
81
83
}
82
84
83
85
type 'a options_fun =
@@ -136,3 +138,7 @@ val answer: unit -> OpamStd.Config.answer
136
138
137
139
(* * [true] if OPAM was compiled in developer mode *)
138
140
val developer : bool
141
+
142
+ (* * Indicates that the code currently runs inside opam, not a library.
143
+ Internal use only. *)
144
+ val set_in_opam : unit -> unit
You can’t perform that action at this time.
0 commit comments