src/share/pin.bend
ezx@1.11.0.0 · 55 lines · 4 definitions
1
2
3
4
5import Base
6import ezx@1.11.0.0/src/ledger/manifest.bend as M
7
8
9
10
11
12def gap.git(no_rev: Bool, no_nar: Bool, +name: String) -> String:
13 match no_rev:
14 case True{}:
15 "ez: tools." ++ name ++ " has no rev; run `ez lock --upgrade --package " ++
16 name ++ "` to pin it"
17 case False{}:
18 match no_nar:
19 case True{}:
20 "ez: tools." ++ name ++ " has no narHash; run `ez lock --upgrade --package " ++
21 name ++ "` to pin it"
22 case False{}:
23 ""
24
25
26
27def gap(pin: M.Tool) -> String:
28 M.Tool{n, _e, _b, s} = pin
29 match s:
30 case M.Hub{_named}:
31 "ez: tools." ++ n ++ " has no git"
32 case M.Git{_url, rev, _tag, _root, nar, _vend}:
33 gap.git(String.is_empty(rev), String.is_empty(nar), n)
34 case M.Member{_path, _named}:
35 "ez: tools." ++ n ++ " has no git"
36
37
38
39
40def gaps.step(none: Bool, here: String, rest: Unit -> String) -> String:
41 match none:
42 case True{}:
43 rest(Unit{})
44 case False{}:
45 here
46
47
48
49def gaps(ts: List<&2, M.Tool>) -> String:
50 match ts:
51 case []:
52 ""
53 case h <> t:
54 +here = gap(h)
55 gaps.step(String.is_empty(here), here, _u => gaps(t))