@yaks/git 0.0.0-stage → 0.2.36
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +202 -0
- package/README.md +754 -2
- package/_dist/address.d.ts +6 -0
- package/_dist/address.d.ts.map +1 -0
- package/_dist/checkout_vocab.d.ts +3 -0
- package/_dist/checkout_vocab.d.ts.map +1 -0
- package/_dist/cites.d.ts +48 -0
- package/_dist/cites.d.ts.map +1 -0
- package/_dist/commit.d.ts +36 -0
- package/_dist/commit.d.ts.map +1 -0
- package/_dist/comp.d.ts +29 -0
- package/_dist/comp.d.ts.map +1 -0
- package/_dist/door.d.ts +29 -0
- package/_dist/door.d.ts.map +1 -0
- package/_dist/format.d.ts +2 -0
- package/_dist/format.d.ts.map +1 -0
- package/_dist/hold.d.ts +6 -0
- package/_dist/hold.d.ts.map +1 -0
- package/_dist/host.d.ts +126 -0
- package/_dist/host.d.ts.map +1 -0
- package/_dist/http.d.ts +33 -0
- package/_dist/http.d.ts.map +1 -0
- package/_dist/import.d.ts +13 -0
- package/_dist/import.d.ts.map +1 -0
- package/_dist/index.d.ts +80 -0
- package/_dist/index.d.ts.map +1 -0
- package/_dist/land.d.ts +77 -0
- package/_dist/land.d.ts.map +1 -0
- package/_dist/mod.d.ts +73 -0
- package/_dist/mod.d.ts.map +1 -0
- package/_dist/objects.d.ts +40 -0
- package/_dist/objects.d.ts.map +1 -0
- package/_dist/oid.d.ts +24 -0
- package/_dist/oid.d.ts.map +1 -0
- package/_dist/pack-store.d.ts +9 -0
- package/_dist/pack-store.d.ts.map +1 -0
- package/_dist/pack.d.ts +26 -0
- package/_dist/pack.d.ts.map +1 -0
- package/_dist/pkt.d.ts +14 -0
- package/_dist/pkt.d.ts.map +1 -0
- package/_dist/placement.d.ts +4 -0
- package/_dist/placement.d.ts.map +1 -0
- package/_dist/plugin.d.ts +43 -0
- package/_dist/plugin.d.ts.map +1 -0
- package/_dist/project.d.ts +20 -0
- package/_dist/project.d.ts.map +1 -0
- package/_dist/push.d.ts +42 -0
- package/_dist/push.d.ts.map +1 -0
- package/_dist/refs.d.ts +81 -0
- package/_dist/refs.d.ts.map +1 -0
- package/_dist/rewrite.d.ts +35 -0
- package/_dist/rewrite.d.ts.map +1 -0
- package/_dist/service.d.ts +35 -0
- package/_dist/service.d.ts.map +1 -0
- package/_dist/sha1.d.ts +11 -0
- package/_dist/sha1.d.ts.map +1 -0
- package/_dist/source.d.ts +12 -0
- package/_dist/source.d.ts.map +1 -0
- package/_dist/tools.d.ts +11 -0
- package/_dist/tools.d.ts.map +1 -0
- package/_dist/tree.d.ts +28 -0
- package/_dist/tree.d.ts.map +1 -0
- package/_dist/unpack.d.ts +5 -0
- package/_dist/unpack.d.ts.map +1 -0
- package/_dist/vocab.d.ts +8 -0
- package/_dist/vocab.d.ts.map +1 -0
- package/_dist/workspace.d.ts +17 -0
- package/_dist/workspace.d.ts.map +1 -0
- package/address.js +9 -0
- package/address.js.map +1 -0
- package/address.ts +15 -0
- package/cache.js +9 -0
- package/cache.js.map +1 -0
- package/cache.ts +6 -0
- package/checkout.js +18 -0
- package/checkout.js.map +1 -0
- package/checkout.ts +24 -0
- package/checkout_vocab.js +14 -0
- package/checkout_vocab.js.map +1 -0
- package/checkout_vocab.ts +11 -0
- package/cites.js +189 -0
- package/cites.js.map +1 -0
- package/cites.ts +206 -0
- package/commit.js +128 -0
- package/commit.js.map +1 -0
- package/commit.ts +183 -0
- package/comp.js +94 -0
- package/comp.js.map +1 -0
- package/comp.ts +111 -0
- package/deno.json +1 -0
- package/door.js +88 -0
- package/door.js.map +1 -0
- package/door.ts +142 -0
- package/format.js +43 -0
- package/format.js.map +1 -0
- package/format.ts +49 -0
- package/hold.js +17 -0
- package/hold.js.map +1 -0
- package/hold.ts +21 -0
- package/host.js +1024 -0
- package/host.js.map +1 -0
- package/host.ts +1140 -0
- package/http.js +268 -0
- package/http.js.map +1 -0
- package/http.ts +329 -0
- package/import.js +141 -0
- package/import.js.map +1 -0
- package/import.ts +128 -0
- package/index.js +496 -0
- package/index.js.map +1 -0
- package/index.ts +634 -0
- package/land.js +788 -0
- package/land.js.map +1 -0
- package/land.ts +871 -0
- package/mod.js +73 -0
- package/mod.js.map +1 -0
- package/mod.ts +74 -0
- package/objects.js +331 -0
- package/objects.js.map +1 -0
- package/objects.ts +390 -0
- package/oid.js +50 -0
- package/oid.js.map +1 -0
- package/oid.ts +83 -0
- package/pack-index.js +103 -0
- package/pack-index.js.map +1 -0
- package/pack-index.ts +104 -0
- package/pack-store.js +216 -0
- package/pack-store.js.map +1 -0
- package/pack-store.ts +292 -0
- package/pack.js +121 -0
- package/pack.js.map +1 -0
- package/pack.ts +146 -0
- package/package.json +78 -4
- package/pkt.js +73 -0
- package/pkt.js.map +1 -0
- package/pkt.ts +93 -0
- package/placement.js +44 -0
- package/placement.js.map +1 -0
- package/placement.ts +38 -0
- package/plugin.js +66 -0
- package/plugin.js.map +1 -0
- package/plugin.ts +88 -0
- package/process-cwd.py +57 -0
- package/project.js +142 -0
- package/project.js.map +1 -0
- package/project.ts +151 -0
- package/push.js +401 -0
- package/push.js.map +1 -0
- package/push.ts +451 -0
- package/refs.js +176 -0
- package/refs.js.map +1 -0
- package/refs.ts +285 -0
- package/rewrite.js +176 -0
- package/rewrite.js.map +1 -0
- package/rewrite.ts +173 -0
- package/service.js +104 -0
- package/service.js.map +1 -0
- package/service.ts +194 -0
- package/sha1.js +115 -0
- package/sha1.js.map +1 -0
- package/sha1.ts +146 -0
- package/source.js +100 -0
- package/source.js.map +1 -0
- package/source.ts +116 -0
- package/spare.js +108 -0
- package/spare.js.map +1 -0
- package/spare.ts +94 -0
- package/tools.js +278 -0
- package/tools.js.map +1 -0
- package/tools.ts +310 -0
- package/tree.js +105 -0
- package/tree.js.map +1 -0
- package/tree.ts +132 -0
- package/unpack.js +207 -0
- package/unpack.js.map +1 -0
- package/unpack.ts +210 -0
- package/vocab.js +20 -0
- package/vocab.js.map +1 -0
- package/vocab.json +386 -0
- package/vocab.ts +22 -0
- package/workspace.js +449 -0
- package/workspace.js.map +1 -0
- package/workspace.ts +445 -0
package/door.ts
ADDED
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
// A repository's door: what a clone or a fetch at a repository's address is
|
|
2
|
+
// answered with, over repositories its host finds by name. The wire is
|
|
3
|
+
// ./http.ts; this decides which address is which door, how a clone is asked
|
|
4
|
+
// for its credential, and what it hears when it is not getting one. Where the
|
|
5
|
+
// refs and the objects are kept, and who may read them, are the host's.
|
|
6
|
+
//
|
|
7
|
+
// A repository is `<name>.git`, and smart HTTP knocks on two addresses under
|
|
8
|
+
// it (`DOORS`). A name holds no dot of its own, so the split is unambiguous.
|
|
9
|
+
// A clone of `<name>/`, the address a browser shows, asks for the
|
|
10
|
+
// advertisement there (`BARE`) and is sent to `<name>.git` by a 301, which git
|
|
11
|
+
// follows and posts its fetch to where it landed
|
|
12
|
+
// (`http.followRedirects=initial`, git's default since 2.11). So the detector
|
|
13
|
+
// is the query, never the user agent: `?service=git-upload-pack` is something
|
|
14
|
+
// no browser asks for, and a site that serves a static `info/refs` serves it
|
|
15
|
+
// to a browser as before.
|
|
16
|
+
//
|
|
17
|
+
// A clone has to be asked for its credential: git sends none unprompted, so a
|
|
18
|
+
// private repository that said 404 would be a 404 to its own owner. So a
|
|
19
|
+
// repository the request may not read answers `401 WWW-Authenticate: Basic`
|
|
20
|
+
// while nobody has proved anything, and git comes back with a password. Once
|
|
21
|
+
// somebody has, the answer is 403, which is terminal: 401 would send git
|
|
22
|
+
// round to ask for the password they already gave correctly. A repository
|
|
23
|
+
// the host does not find is 404 to everyone, credential or not.
|
|
24
|
+
import { advertise, type Refs, SERVICE, uploadPack } from './http.js'
|
|
25
|
+
import type { Objects } from './objects.ts'
|
|
26
|
+
import { RECEIVE } from './http.js'
|
|
27
|
+
import { BARE, DOORS } from './address.js'
|
|
28
|
+
import type { Receiver } from './push.js'
|
|
29
|
+
|
|
30
|
+
export { BARE, DOORS, knocks } from './address.js'
|
|
31
|
+
|
|
32
|
+
/** A repository a request may be answered from: its refs and its objects. */
|
|
33
|
+
export type Repository = { refs: Refs; objects: Objects }
|
|
34
|
+
|
|
35
|
+
/** A repository as its host found it for one request. */
|
|
36
|
+
export type Found = Repository & {
|
|
37
|
+
/** whether this request may read it */
|
|
38
|
+
reads: boolean
|
|
39
|
+
/** whether the request proved who sent it, which makes a refusal final */
|
|
40
|
+
proven: boolean
|
|
41
|
+
receive?: Receiver
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/** What a door is given by its host. */
|
|
45
|
+
export type Host = {
|
|
46
|
+
/** The repository called `name`, as `req` may see it, or null where there
|
|
47
|
+
* is none. `password` is what a Basic credential carried, the one scheme
|
|
48
|
+
* git offers once challenged; null where the request carried none. */
|
|
49
|
+
find: (
|
|
50
|
+
name: string,
|
|
51
|
+
req: Request,
|
|
52
|
+
password: string | null,
|
|
53
|
+
) => Promise<Found | null>
|
|
54
|
+
/** what git prints above its password prompt */
|
|
55
|
+
realm: string
|
|
56
|
+
failed?: (reason: unknown) => void
|
|
57
|
+
/** Keeps `work` running after the answer is sent (a Worker's
|
|
58
|
+
* `waitUntil`), and hears its failure: what a push will read, read while
|
|
59
|
+
* its client packs. */
|
|
60
|
+
hold?: (work: Promise<void>) => void
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
// What a clone hears when it is not getting one. Plain text, because the
|
|
64
|
+
// thing reading it is git and not a browser.
|
|
65
|
+
let refusal = (status: number, say: string, more: HeadersInit = {}) =>
|
|
66
|
+
new Response(`git: ${say}\n`, {
|
|
67
|
+
status,
|
|
68
|
+
headers: { 'content-type': 'text/plain; charset=utf-8', ...more },
|
|
69
|
+
})
|
|
70
|
+
|
|
71
|
+
/// password(new Request('http://x', { headers: { authorization: 'Basic ' + btoa('x:tok') } })) -> 'tok'
|
|
72
|
+
/// password(new Request('http://x', { headers: { authorization: 'Basic ' + btoa('x:') } })) -> null
|
|
73
|
+
/// password(new Request('http://x', { headers: { authorization: 'Bearer tok' } })) -> null
|
|
74
|
+
/// password(new Request('http://x')) -> null
|
|
75
|
+
/** The password of a request's Basic credential. Its username is whatever
|
|
76
|
+
* the person typed in front of it, which a token that says whose it is makes
|
|
77
|
+
* decoration. */
|
|
78
|
+
export let password = (req: Request): string | null => {
|
|
79
|
+
let said = /^Basic +(\S+)$/i.exec(req.headers.get('authorization') ?? '')
|
|
80
|
+
if (!said) return null
|
|
81
|
+
let pair
|
|
82
|
+
try {
|
|
83
|
+
pair = atob(said[1])
|
|
84
|
+
} catch {
|
|
85
|
+
return null
|
|
86
|
+
}
|
|
87
|
+
let colon = pair.indexOf(':')
|
|
88
|
+
return colon < 0 ? null : pair.slice(colon + 1) || null
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
// The browser's address, sent to the repository's own with its query.
|
|
92
|
+
let redirect = (req: Request, path: string): Response | null => {
|
|
93
|
+
let bare = BARE.exec(path)
|
|
94
|
+
let url = new URL(req.url)
|
|
95
|
+
if (req.method != 'GET' || !bare) return null
|
|
96
|
+
if (url.searchParams.get('service') != SERVICE) return null
|
|
97
|
+
url.pathname = `/${bare[1]}.git/info/refs`
|
|
98
|
+
return Response.redirect(url, 301)
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
/** The door: a `Response` for a repository's address, `null` for any other,
|
|
102
|
+
* which its host answers as it would without one. */
|
|
103
|
+
export let door =
|
|
104
|
+
(host: Host) => async (req: Request): Promise<Response | null> => {
|
|
105
|
+
let path = new URL(req.url).pathname
|
|
106
|
+
let asked = DOORS.exec(path)
|
|
107
|
+
if (!asked) return redirect(req, path)
|
|
108
|
+
let [, name, at] = asked
|
|
109
|
+
let found = await host.find(name, req, password(req))
|
|
110
|
+
if (!found) return refusal(404, 'no such repository')
|
|
111
|
+
let pushing = at == RECEIVE || at == 'info/refs' &&
|
|
112
|
+
new URL(req.url).searchParams.get('service') == RECEIVE
|
|
113
|
+
if (!found.reads) {
|
|
114
|
+
return found.proven ? refusal(403, 'not your repository') : refusal(
|
|
115
|
+
401,
|
|
116
|
+
pushing
|
|
117
|
+
? 'sign in to push to this repository'
|
|
118
|
+
: 'sign in to clone this repository',
|
|
119
|
+
{
|
|
120
|
+
'www-authenticate': `Basic realm="${host.realm}"`,
|
|
121
|
+
},
|
|
122
|
+
)
|
|
123
|
+
}
|
|
124
|
+
if (pushing && found.receive) {
|
|
125
|
+
let { advertiseReceive, receivePack, warm } = await import('./push.js')
|
|
126
|
+
let hold = host.hold
|
|
127
|
+
return at == 'info/refs'
|
|
128
|
+
? req.method == 'GET'
|
|
129
|
+
? advertiseReceive(
|
|
130
|
+
found.refs,
|
|
131
|
+
hold && ((refs) => hold(warm(refs, found.objects))),
|
|
132
|
+
)
|
|
133
|
+
: refusal(405, 'use GET')
|
|
134
|
+
: receivePack(req, found.refs, found.objects, found.receive)
|
|
135
|
+
}
|
|
136
|
+
if (at == RECEIVE) {
|
|
137
|
+
return refusal(403, 'push is unavailable for this repository')
|
|
138
|
+
}
|
|
139
|
+
return at == 'info/refs'
|
|
140
|
+
? advertise(req)
|
|
141
|
+
: uploadPack(req, found.refs, found.objects, host.failed)
|
|
142
|
+
}
|
package/format.js
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
// Deno's explicit file arguments override configuration exclusions unless the
|
|
2
|
+
// exclusions are supplied through --ignore. Deno retains ownership of glob
|
|
3
|
+
// matching, file-type support and all formatting options. A checkout without
|
|
4
|
+
// a Deno config never chose Deno's formatter, so it is not formatted: Deno's
|
|
5
|
+
// defaults would rewrite a Rails app's Markdown and YAML it never authored.
|
|
6
|
+
import { parse } from "@jsr/std__jsonc";
|
|
7
|
+
import * as disk from "@yaks/file/io";
|
|
8
|
+
let object = (value)=>value != null && typeof value == 'object' && !Array.isArray(value);
|
|
9
|
+
let paths = (value)=>Array.isArray(value) ? value.filter((path)=>typeof path == 'string') : [];
|
|
10
|
+
export let formatting = (files, config, file = 'deno.json')=>{
|
|
11
|
+
let root = object(config) ? config : {};
|
|
12
|
+
let fmt = object(root.fmt) ? root.fmt : {};
|
|
13
|
+
return [
|
|
14
|
+
'fmt',
|
|
15
|
+
'--config',
|
|
16
|
+
file,
|
|
17
|
+
'--permit-no-files',
|
|
18
|
+
...[
|
|
19
|
+
...new Set([
|
|
20
|
+
...paths(root.exclude),
|
|
21
|
+
...paths(fmt.exclude)
|
|
22
|
+
])
|
|
23
|
+
].map((path)=>'--ignore=' + path),
|
|
24
|
+
...files
|
|
25
|
+
];
|
|
26
|
+
};
|
|
27
|
+
let read = (path)=>disk.readTextFile(path).catch((e)=>{
|
|
28
|
+
if (disk.isNotFound(e)) return undefined;
|
|
29
|
+
throw e;
|
|
30
|
+
});
|
|
31
|
+
/** The checkout's Deno config, or undefined when it has none. */ export let formatConfig = async (cwd, source = read)=>{
|
|
32
|
+
for (let file of [
|
|
33
|
+
'deno.json',
|
|
34
|
+
'deno.jsonc'
|
|
35
|
+
]){
|
|
36
|
+
let text = await source(disk.join(cwd, file));
|
|
37
|
+
if (text != null) return {
|
|
38
|
+
file,
|
|
39
|
+
config: parse(text) ?? {}
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
//# sourceMappingURL=format.js.map
|
package/format.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"format.js","sources":["./format.ts"],"names":[],"mappings":"AAAA,8EAA8E;AAC9E,2EAA2E;AAC3E,6EAA6E;AAC7E,6EAA6E;AAC7E,4EAA4E;AAC5E,SAAS,KAAK,0BAA8B;AAC5C,YAAY,+BAAoC;AAEhD,IAAI,SAAS,CAAC,QACZ,SAAS,QAAQ,OAAO,SAAS,YAAY,CAAC,MAAM,OAAO,CAAC;AAC9D,IAAI,QAAQ,CAAC,QACX,MAAM,OAAO,CAAC,SACV,MAAM,MAAM,CAAC,CAAC,OAAyB,OAAO,QAAQ,YACtD,EAAE;AAER,OAAO,IAAI,aAAa,CACtB,OACA,QACA,OAAO,WAAW;EAElB,IAAI,OAAO,OAAO,UAAU,SAAS,CAAC;EACtC,IAAI,MAAM,OAAO,KAAK,GAAG,IAAI,KAAK,GAAG,GAAG,CAAC;EACzC,OAAO;IACL;IACA;IACA;IACA;OACG;SAAI,IAAI,IAAI;WAAI,MAAM,KAAK,OAAO;WAAM,MAAM,IAAI,OAAO;OAAE;KAAE,CAC7D,GAAG,CAAC,CAAC,OAAS,cAAc;OAC5B;GACJ;AACH,EAAC;AAED,IAAI,OAAO,CAAC,OACV,KAAK,YAAY,CAAC,MAAM,KAAK,CAAC,CAAC;IAC7B,IAAI,KAAK,UAAU,CAAC,IAAI,OAAO;IAC/B,MAAM;EACR;AAEF,+DAA+D,GAC/D,OAAO,IAAI,eAAe,OACxB,KACA,SAAwD,IAAI;EAE5D,KAAK,IAAI,QAAQ;IAAC;IAAa;GAAa,CAAE;IAC5C,IAAI,OAAO,MAAM,OAAO,KAAK,IAAI,CAAC,KAAK;IACvC,IAAI,QAAQ,MAAM,OAAO;MAAE;MAAM,QAAQ,MAAM,SAAS,CAAC;IAAE;EAC7D;AACF,EAAC"}
|
package/format.ts
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
// Deno's explicit file arguments override configuration exclusions unless the
|
|
2
|
+
// exclusions are supplied through --ignore. Deno retains ownership of glob
|
|
3
|
+
// matching, file-type support and all formatting options. A checkout without
|
|
4
|
+
// a Deno config never chose Deno's formatter, so it is not formatted: Deno's
|
|
5
|
+
// defaults would rewrite a Rails app's Markdown and YAML it never authored.
|
|
6
|
+
import { parse } from '@jsr/std__jsonc'
|
|
7
|
+
import * as disk from '@yaks/file/io'
|
|
8
|
+
|
|
9
|
+
let object = (value: unknown): value is Record<string, unknown> =>
|
|
10
|
+
value != null && typeof value == 'object' && !Array.isArray(value)
|
|
11
|
+
let paths = (value: unknown): string[] =>
|
|
12
|
+
Array.isArray(value)
|
|
13
|
+
? value.filter((path): path is string => typeof path == 'string')
|
|
14
|
+
: []
|
|
15
|
+
|
|
16
|
+
export let formatting = (
|
|
17
|
+
files: string[],
|
|
18
|
+
config: unknown,
|
|
19
|
+
file = 'deno.json',
|
|
20
|
+
): string[] => {
|
|
21
|
+
let root = object(config) ? config : {}
|
|
22
|
+
let fmt = object(root.fmt) ? root.fmt : {}
|
|
23
|
+
return [
|
|
24
|
+
'fmt',
|
|
25
|
+
'--config',
|
|
26
|
+
file,
|
|
27
|
+
'--permit-no-files',
|
|
28
|
+
...[...new Set([...paths(root.exclude), ...paths(fmt.exclude)])]
|
|
29
|
+
.map((path) => '--ignore=' + path),
|
|
30
|
+
...files,
|
|
31
|
+
]
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
let read = (path: string) =>
|
|
35
|
+
disk.readTextFile(path).catch((e) => {
|
|
36
|
+
if (disk.isNotFound(e)) return undefined
|
|
37
|
+
throw e
|
|
38
|
+
})
|
|
39
|
+
|
|
40
|
+
/** The checkout's Deno config, or undefined when it has none. */
|
|
41
|
+
export let formatConfig = async (
|
|
42
|
+
cwd: string,
|
|
43
|
+
source: (path: string) => Promise<string | undefined> = read,
|
|
44
|
+
): Promise<{ file: string; config: unknown } | undefined> => {
|
|
45
|
+
for (let file of ['deno.json', 'deno.jsonc']) {
|
|
46
|
+
let text = await source(disk.join(cwd, file))
|
|
47
|
+
if (text != null) return { file, config: parse(text) ?? {} }
|
|
48
|
+
}
|
|
49
|
+
}
|
package/hold.js
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import * as io from "@yaks/file/io";
|
|
2
|
+
// The land lock of a checkout, a module of its own that imports nothing else
|
|
3
|
+
// from the workspace: a `yak` command takes it before it loads any module of
|
|
4
|
+
// the checkout it may land under (@yaks/cli/yak).
|
|
5
|
+
/** Hold the land lock of the checkout whose Git directory is `gitdir` until
|
|
6
|
+
* the returned release: exclusive for the landing that writes the checkout,
|
|
7
|
+
* shared for a reader that needs it whole. Git's own `index.lock` refuses a
|
|
8
|
+
* second writer instead of waiting for it, so whatever writes the shared
|
|
9
|
+
* checkout's index waits here first. */ export let hold = async (gitdir, exclusive)=>{
|
|
10
|
+
let file = await io.open(`${gitdir}/land.lock`, {
|
|
11
|
+
create: true,
|
|
12
|
+
write: true
|
|
13
|
+
});
|
|
14
|
+
await file.lock(exclusive);
|
|
15
|
+
return ()=>file.close();
|
|
16
|
+
};
|
|
17
|
+
//# sourceMappingURL=hold.js.map
|
package/hold.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hold.js","sources":["./hold.ts"],"names":[],"mappings":"AAAA,YAAY,6BAAkC;AAC9C,6EAA6E;AAC7E,6EAA6E;AAC7E,kDAAkD;AAElD;;;;sCAIsC,GACtC,OAAO,IAAI,OAAO,OAChB,QACA;EAEA,IAAI,OAAO,MAAM,GAAG,IAAI,CAAC,GAAG,OAAO,UAAU,CAAC,EAAE;IAC9C,QAAQ;IACR,OAAO;EACT;EACA,MAAM,KAAK,IAAI,CAAC;EAChB,OAAO,IAAM,KAAK,KAAK;AACzB,EAAC"}
|
package/hold.ts
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import * as io from '@yaks/file/io'
|
|
2
|
+
// The land lock of a checkout, a module of its own that imports nothing else
|
|
3
|
+
// from the workspace: a `yak` command takes it before it loads any module of
|
|
4
|
+
// the checkout it may land under (@yaks/cli/yak).
|
|
5
|
+
|
|
6
|
+
/** Hold the land lock of the checkout whose Git directory is `gitdir` until
|
|
7
|
+
* the returned release: exclusive for the landing that writes the checkout,
|
|
8
|
+
* shared for a reader that needs it whole. Git's own `index.lock` refuses a
|
|
9
|
+
* second writer instead of waiting for it, so whatever writes the shared
|
|
10
|
+
* checkout's index waits here first. */
|
|
11
|
+
export let hold = async (
|
|
12
|
+
gitdir: string,
|
|
13
|
+
exclusive: boolean,
|
|
14
|
+
): Promise<() => void> => {
|
|
15
|
+
let file = await io.open(`${gitdir}/land.lock`, {
|
|
16
|
+
create: true,
|
|
17
|
+
write: true,
|
|
18
|
+
})
|
|
19
|
+
await file.lock(exclusive)
|
|
20
|
+
return () => file.close()
|
|
21
|
+
}
|