@aeilab/s3ag 0.0.0-stage → 0.1.0
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 +201 -0
- package/dist/api.d.ts +156 -0
- package/dist/api.d.ts.map +1 -0
- package/dist/api.js +195 -0
- package/dist/api.js.map +1 -0
- package/dist/aws.d.ts +144 -0
- package/dist/aws.d.ts.map +1 -0
- package/dist/aws.js +357 -0
- package/dist/aws.js.map +1 -0
- package/dist/cli/git-lfs-s3ag.d.ts +3 -0
- package/dist/cli/git-lfs-s3ag.d.ts.map +1 -0
- package/dist/cli/git-lfs-s3ag.js +14 -0
- package/dist/cli/git-lfs-s3ag.js.map +1 -0
- package/dist/cli/git-remote-s3ag.d.ts +3 -0
- package/dist/cli/git-remote-s3ag.d.ts.map +1 -0
- package/dist/cli/git-remote-s3ag.js +7 -0
- package/dist/cli/git-remote-s3ag.js.map +1 -0
- package/dist/cli/s3ag.d.ts +3 -0
- package/dist/cli/s3ag.d.ts.map +1 -0
- package/dist/cli/s3ag.js +153 -0
- package/dist/cli/s3ag.js.map +1 -0
- package/dist/commits.d.ts +17 -0
- package/dist/commits.d.ts.map +1 -0
- package/dist/commits.js +82 -0
- package/dist/commits.js.map +1 -0
- package/dist/common.d.ts +55 -0
- package/dist/common.d.ts.map +1 -0
- package/dist/common.js +114 -0
- package/dist/common.js.map +1 -0
- package/dist/config.d.ts +17 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +50 -0
- package/dist/config.js.map +1 -0
- package/dist/enums.d.ts +10 -0
- package/dist/enums.d.ts.map +1 -0
- package/dist/enums.js +14 -0
- package/dist/enums.js.map +1 -0
- package/dist/exit.d.ts +10 -0
- package/dist/exit.d.ts.map +1 -0
- package/dist/exit.js +17 -0
- package/dist/exit.js.map +1 -0
- package/dist/git.d.ts +44 -0
- package/dist/git.d.ts.map +1 -0
- package/dist/git.js +131 -0
- package/dist/git.js.map +1 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +12 -0
- package/dist/index.js.map +1 -0
- package/dist/lfs.d.ts +38 -0
- package/dist/lfs.d.ts.map +1 -0
- package/dist/lfs.js +426 -0
- package/dist/lfs.js.map +1 -0
- package/dist/logger.d.ts +27 -0
- package/dist/logger.d.ts.map +1 -0
- package/dist/logger.js +93 -0
- package/dist/logger.js.map +1 -0
- package/dist/manage.d.ts +20 -0
- package/dist/manage.d.ts.map +1 -0
- package/dist/manage.js +164 -0
- package/dist/manage.js.map +1 -0
- package/dist/process.d.ts +21 -0
- package/dist/process.d.ts.map +1 -0
- package/dist/process.js +32 -0
- package/dist/process.js.map +1 -0
- package/dist/prompt.d.ts +9 -0
- package/dist/prompt.d.ts.map +1 -0
- package/dist/prompt.js +26 -0
- package/dist/prompt.js.map +1 -0
- package/dist/remote.d.ts +38 -0
- package/dist/remote.d.ts.map +1 -0
- package/dist/remote.js +446 -0
- package/dist/remote.js.map +1 -0
- package/package.json +31 -3
- package/README.md +0 -3
package/dist/cli/s3ag.js
ADDED
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// SPDX-FileCopyrightText: 2024-present s3ag contributors
|
|
3
|
+
//
|
|
4
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
import { load_config, save_config } from "../config.js";
|
|
6
|
+
import { SystemExit } from "../exit.js";
|
|
7
|
+
import * as lfs from "../lfs.js";
|
|
8
|
+
import * as manage from "../manage.js";
|
|
9
|
+
const USAGE = `Usage: s3ag <command> [options]
|
|
10
|
+
|
|
11
|
+
Commands:
|
|
12
|
+
set-server <url> [options] Configure the s3ag server endpoint
|
|
13
|
+
--allow-insecure-http Allow a cleartext http:// server URL
|
|
14
|
+
set-auth [token] [options] Configure the login credential
|
|
15
|
+
--sandbox-network-interception Enable sandbox network-layer auth injection
|
|
16
|
+
--sandbox-network-interception-ca-root <p> CA root used by the sandbox interceptor
|
|
17
|
+
doctor <remote> [options] Inspect and repair a remote
|
|
18
|
+
--lock-ttl <seconds> Lock staleness threshold (default: 60)
|
|
19
|
+
--delete-stale-locks Delete stale locks found during doctor
|
|
20
|
+
-d, --delete-bundle Delete duplicate bundles instead of moving them
|
|
21
|
+
delete-branch <remote> -b <branch> Delete a remote branch
|
|
22
|
+
protect <remote> -b <branch> Protect a remote branch
|
|
23
|
+
unprotect <remote> -b <branch> Unprotect a remote branch
|
|
24
|
+
lfs install [--remote <name>] Install the git-lfs custom transfer agent
|
|
25
|
+
help Show this help
|
|
26
|
+
`;
|
|
27
|
+
async function main(argv = process.argv) {
|
|
28
|
+
const args = argv.slice(2);
|
|
29
|
+
const command = args.shift();
|
|
30
|
+
if (command === undefined || command === "help" || command === "--help") {
|
|
31
|
+
process.stdout.write(USAGE);
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
if (command === "set-server") {
|
|
35
|
+
let server;
|
|
36
|
+
let allowInsecureHttp = false;
|
|
37
|
+
for (let i = 0; i < args.length; i += 1) {
|
|
38
|
+
const arg = args[i];
|
|
39
|
+
if (arg === "--allow-insecure-http") {
|
|
40
|
+
allowInsecureHttp = true;
|
|
41
|
+
}
|
|
42
|
+
else if (arg.startsWith("-")) {
|
|
43
|
+
process.stderr.write(`fatal: unknown option ${arg}\n`);
|
|
44
|
+
throw new SystemExit(2);
|
|
45
|
+
}
|
|
46
|
+
else if (server === undefined) {
|
|
47
|
+
server = arg;
|
|
48
|
+
}
|
|
49
|
+
else {
|
|
50
|
+
process.stderr.write(`fatal: unexpected argument ${arg}\n`);
|
|
51
|
+
throw new SystemExit(2);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
if (server === undefined) {
|
|
55
|
+
process.stderr.write("fatal: set-server requires a URL\n");
|
|
56
|
+
throw new SystemExit(1);
|
|
57
|
+
}
|
|
58
|
+
let parsed;
|
|
59
|
+
try {
|
|
60
|
+
parsed = new URL(server);
|
|
61
|
+
}
|
|
62
|
+
catch {
|
|
63
|
+
process.stderr.write(`fatal: invalid server URL: ${server}\n`);
|
|
64
|
+
throw new SystemExit(2);
|
|
65
|
+
}
|
|
66
|
+
if (parsed.protocol !== "http:" && parsed.protocol !== "https:") {
|
|
67
|
+
process.stderr.write(`fatal: unsupported server URL scheme "${parsed.protocol}"; use https\n`);
|
|
68
|
+
throw new SystemExit(2);
|
|
69
|
+
}
|
|
70
|
+
if (parsed.protocol === "http:" && !allowInsecureHttp) {
|
|
71
|
+
process.stderr.write("fatal: insecure http server URL rejected; use https or pass --allow-insecure-http\n");
|
|
72
|
+
throw new SystemExit(1);
|
|
73
|
+
}
|
|
74
|
+
const config = load_config();
|
|
75
|
+
config.server = server;
|
|
76
|
+
if (allowInsecureHttp) {
|
|
77
|
+
config.allowInsecureHttp = true;
|
|
78
|
+
}
|
|
79
|
+
else {
|
|
80
|
+
// Drop any previous opt-in when switching back to https.
|
|
81
|
+
delete config.allowInsecureHttp;
|
|
82
|
+
}
|
|
83
|
+
save_config(config);
|
|
84
|
+
process.stdout.write(`server set to ${server}\n`);
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
if (command === "set-auth") {
|
|
88
|
+
const config = load_config();
|
|
89
|
+
const auth = config.auth ?? {};
|
|
90
|
+
let token;
|
|
91
|
+
for (let i = 0; i < args.length; i += 1) {
|
|
92
|
+
const arg = args[i];
|
|
93
|
+
if (arg === "--sandbox-network-interception") {
|
|
94
|
+
auth.sandboxNetworkInterception = true;
|
|
95
|
+
}
|
|
96
|
+
else if (arg === "--sandbox-network-interception-ca-root") {
|
|
97
|
+
auth.sandboxNetworkInterceptionCaRoot = args[++i];
|
|
98
|
+
}
|
|
99
|
+
else if (arg.startsWith("-")) {
|
|
100
|
+
process.stderr.write(`fatal: unknown option ${arg}\n`);
|
|
101
|
+
throw new SystemExit(2);
|
|
102
|
+
}
|
|
103
|
+
else if (token === undefined) {
|
|
104
|
+
token = arg;
|
|
105
|
+
}
|
|
106
|
+
else {
|
|
107
|
+
process.stderr.write(`fatal: unexpected argument ${arg}\n`);
|
|
108
|
+
throw new SystemExit(2);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
if (token !== undefined) {
|
|
112
|
+
auth.token = token;
|
|
113
|
+
}
|
|
114
|
+
if (auth.token === undefined &&
|
|
115
|
+
!auth.sandboxNetworkInterception) {
|
|
116
|
+
process.stderr.write("fatal: set-auth requires a token or --sandbox-network-interception\n");
|
|
117
|
+
throw new SystemExit(2);
|
|
118
|
+
}
|
|
119
|
+
config.auth = auth;
|
|
120
|
+
save_config(config);
|
|
121
|
+
process.stdout.write("auth configured\n");
|
|
122
|
+
return;
|
|
123
|
+
}
|
|
124
|
+
if (command === "lfs") {
|
|
125
|
+
const sub = args.shift();
|
|
126
|
+
if (sub !== "install") {
|
|
127
|
+
process.stderr.write("fatal: expected 's3ag lfs install'\n");
|
|
128
|
+
throw new SystemExit(2);
|
|
129
|
+
}
|
|
130
|
+
let remoteName = null;
|
|
131
|
+
for (let i = 0; i < args.length; i += 1) {
|
|
132
|
+
if (args[i] === "--remote") {
|
|
133
|
+
remoteName = args[++i] ?? null;
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
lfs.install({ remote_name: remoteName });
|
|
137
|
+
return;
|
|
138
|
+
}
|
|
139
|
+
if (["doctor", "delete-branch", "protect", "unprotect"].includes(command)) {
|
|
140
|
+
await manage.main([...argv.slice(0, 2), command, ...args]);
|
|
141
|
+
return;
|
|
142
|
+
}
|
|
143
|
+
process.stderr.write(`fatal: unknown command ${command}\n\n${USAGE}`);
|
|
144
|
+
throw new SystemExit(2);
|
|
145
|
+
}
|
|
146
|
+
main().catch((error) => {
|
|
147
|
+
if (error instanceof SystemExit) {
|
|
148
|
+
process.exit(error.code);
|
|
149
|
+
}
|
|
150
|
+
process.stderr.write(`fatal: ${error instanceof Error ? error.message : String(error)}\n`);
|
|
151
|
+
process.exit(1);
|
|
152
|
+
});
|
|
153
|
+
//# sourceMappingURL=s3ag.js.map
|
|
@@ -0,0 +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IAED,IAAI,CAAC,QAAQ,EAAE,eAAe,EAAE,SAAS,EAAE,WAAW,CAAC,CAAC,QAAQ,CAAC,OAAO,CAAC,EAAE,CAAC;QAC1E,MAAM,MAAM,CAAC,IAAI,CAAC,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,OAAO,EAAE,GAAG,IAAI,CAAC,CAAC,CAAC;QAC3D,OAAO;IACT,CAAC;IAED,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,0BAA0B,OAAO,OAAO,KAAK,EAAE,CAAC,CAAC;IACtE,MAAM,IAAI,UAAU,CAAC,CAAC,CAAC,CAAC;AAC1B,CAAC;AAED,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE;IACrB,IAAI,KAAK,YAAY,UAAU,EAAE,CAAC;QAChC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IAC3B,CAAC;IACD,OAAO,CAAC,MAAM,CAAC,KAAK,CAClB,UAAU,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CACrE,CAAC;IACF,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { CommitsManifest, CommitsPushInput } from "./api.js";
|
|
2
|
+
export declare const COMMITS_PAGE_SIZE = 50;
|
|
3
|
+
export type BuiltCommits = {
|
|
4
|
+
input: CommitsPushInput;
|
|
5
|
+
manifest: CommitsManifest;
|
|
6
|
+
manifestBody: string;
|
|
7
|
+
pages: Array<{
|
|
8
|
+
boundarySha: string;
|
|
9
|
+
body: string;
|
|
10
|
+
}>;
|
|
11
|
+
};
|
|
12
|
+
export declare function buildCommits(opts: {
|
|
13
|
+
newSha: string;
|
|
14
|
+
parentSha: string | null;
|
|
15
|
+
existing: CommitsManifest | null;
|
|
16
|
+
}): BuiltCommits | null;
|
|
17
|
+
//# sourceMappingURL=commits.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"commits.d.ts","sourceRoot":"","sources":["../src/commits.ts"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EAEV,eAAe,EAEf,gBAAgB,EACjB,MAAM,UAAU,CAAC;AAElB,eAAO,MAAM,iBAAiB,KAAK,CAAC;AAGpC,MAAM,MAAM,YAAY,GAAG;IACzB,KAAK,EAAE,gBAAgB,CAAC;IACxB,QAAQ,EAAE,eAAe,CAAC;IAC1B,YAAY,EAAE,MAAM,CAAC;IACrB,KAAK,EAAE,KAAK,CAAC;QAAE,WAAW,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;CACrD,CAAC;AAcF,wBAAgB,YAAY,CAAC,IAAI,EAAE;IACjC,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,QAAQ,EAAE,eAAe,GAAG,IAAI,CAAC;CAClC,GAAG,YAAY,GAAG,IAAI,CA+DtB"}
|
package/dist/commits.js
ADDED
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
// SPDX-FileCopyrightText: 2024-present s3ag contributors
|
|
2
|
+
//
|
|
3
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
/**
|
|
5
|
+
* Builds the client-generated commit index uploaded with each push.
|
|
6
|
+
*
|
|
7
|
+
* Layout:
|
|
8
|
+
* commits/index.json mutable manifest (written last)
|
|
9
|
+
* commits/pages/<oldestSha>.json immutable page (newest → oldest within)
|
|
10
|
+
*
|
|
11
|
+
* Pages already present in the previous manifest are reused as-is; only pages
|
|
12
|
+
* for the new commits are uploaded. This keeps each push O(new commits).
|
|
13
|
+
*/
|
|
14
|
+
import * as git from "./git.js";
|
|
15
|
+
export const COMMITS_PAGE_SIZE = 50;
|
|
16
|
+
const RECENT_LIMIT = 20;
|
|
17
|
+
function chunkNewestFirst(entries, size) {
|
|
18
|
+
const out = [];
|
|
19
|
+
for (let i = 0; i < entries.length; i += size) {
|
|
20
|
+
out.push(entries.slice(i, i + size));
|
|
21
|
+
}
|
|
22
|
+
return out;
|
|
23
|
+
}
|
|
24
|
+
function byteLength(value) {
|
|
25
|
+
return Buffer.byteLength(value, "utf8");
|
|
26
|
+
}
|
|
27
|
+
export function buildCommits(opts) {
|
|
28
|
+
const { newSha, parentSha, existing } = opts;
|
|
29
|
+
const newCommits = parentSha
|
|
30
|
+
? git.log_commits(newSha, parentSha)
|
|
31
|
+
: git.log_commits(newSha, null);
|
|
32
|
+
// Nothing new and no prior index: skip the commit index entirely.
|
|
33
|
+
if (newCommits.length === 0) {
|
|
34
|
+
return null;
|
|
35
|
+
}
|
|
36
|
+
const reused = existing ? existing.pages : [];
|
|
37
|
+
const chunks = chunkNewestFirst(newCommits, COMMITS_PAGE_SIZE);
|
|
38
|
+
const pages = [];
|
|
39
|
+
const pageBodies = [];
|
|
40
|
+
let offset = 0;
|
|
41
|
+
for (const chunk of chunks) {
|
|
42
|
+
const newest = chunk[0].sha;
|
|
43
|
+
const oldest = chunk[chunk.length - 1].sha;
|
|
44
|
+
const key = `commits/pages/${oldest}.json`;
|
|
45
|
+
const body = JSON.stringify({ commits: chunk });
|
|
46
|
+
pages.push({ key, from: offset, count: chunk.length, newest, oldest });
|
|
47
|
+
pageBodies.push({ boundarySha: oldest, body });
|
|
48
|
+
offset += chunk.length;
|
|
49
|
+
}
|
|
50
|
+
for (const page of reused) {
|
|
51
|
+
pages.push({ ...page, from: offset });
|
|
52
|
+
offset += page.count;
|
|
53
|
+
}
|
|
54
|
+
const recent = newCommits.slice(0, RECENT_LIMIT).map((entry) => ({
|
|
55
|
+
sha: entry.sha,
|
|
56
|
+
message: entry.message,
|
|
57
|
+
authorName: entry.authorName,
|
|
58
|
+
authoredAt: entry.authoredAt,
|
|
59
|
+
}));
|
|
60
|
+
const manifest = {
|
|
61
|
+
version: 1,
|
|
62
|
+
tip: newSha,
|
|
63
|
+
total: offset,
|
|
64
|
+
pageSize: COMMITS_PAGE_SIZE,
|
|
65
|
+
recent,
|
|
66
|
+
pages,
|
|
67
|
+
};
|
|
68
|
+
const manifestBody = JSON.stringify(manifest);
|
|
69
|
+
return {
|
|
70
|
+
input: {
|
|
71
|
+
manifestSize: byteLength(manifestBody),
|
|
72
|
+
pages: pageBodies.map((p) => ({
|
|
73
|
+
boundarySha: p.boundarySha,
|
|
74
|
+
size: byteLength(p.body),
|
|
75
|
+
})),
|
|
76
|
+
},
|
|
77
|
+
manifest,
|
|
78
|
+
manifestBody,
|
|
79
|
+
pages: pageBodies,
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
//# sourceMappingURL=commits.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"commits.js","sourceRoot":"","sources":["../src/commits.ts"],"names":[],"mappings":"AAAA,yDAAyD;AACzD,EAAE;AACF,sCAAsC;AAEtC;;;;;;;;;GASG;AAEH,OAAO,KAAK,GAAG,MAAM,UAAU,CAAC;AAQhC,MAAM,CAAC,MAAM,iBAAiB,GAAG,EAAE,CAAC;AACpC,MAAM,YAAY,GAAG,EAAE,CAAC;AASxB,SAAS,gBAAgB,CAAC,OAAyB,EAAE,IAAY;IAC/D,MAAM,GAAG,GAAuB,EAAE,CAAC;IACnC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,IAAI,IAAI,EAAE,CAAC;QAC9C,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC;IACvC,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC;AAED,SAAS,UAAU,CAAC,KAAa;IAC/B,OAAO,MAAM,CAAC,UAAU,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;AAC1C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rl = [
|
|
3
|
+
UriScheme | null,
|
|
4
|
+
string | null,
|
|
5
|
+
string | null,
|
|
6
|
+
string | null
|
|
7
|
+
];
|
|
8
|
+
/**
|
|
9
|
+
* Parses the elements in an s3ag:// remote origin URI.
|
|
10
|
+
*
|
|
11
|
+
* The URI shape is inherited from git-remote-s3, with one deliberate change:
|
|
12
|
+
*
|
|
13
|
+
* s3ag://owner/repo
|
|
14
|
+
* s3ag+zip://owner/repo
|
|
15
|
+
* s3://[profile@]bucket/prefix
|
|
16
|
+
* s3+zip://[profile@]bucket/prefix
|
|
17
|
+
*
|
|
18
|
+
* s3ag:// treats the first path segment as the owner, so usernames containing
|
|
19
|
+
* "@" (for example an email address) remain addressable. Profile syntax is
|
|
20
|
+
* accepted only on the legacy s3:// and s3+zip:// schemes.
|
|
21
|
+
*/
|
|
22
|
+
export declare function parse_git_url(url: string | null | undefined): ParsedGitUrl;
|
|
23
|
+
/**
|
|
24
|
+
* Returns true if the value is a full git object id (40 lowercase hex chars).
|
|
25
|
+
*
|
|
26
|
+
* Identifiers that reach us from a remote must be checked before being used
|
|
27
|
+
* in a filesystem path or passed to git — otherwise a malicious server could
|
|
28
|
+
* inject `../` segments.
|
|
29
|
+
*/
|
|
30
|
+
export declare function is_git_object_id(value: unknown): value is string;
|
|
31
|
+
/** Returns true if the value is a git-lfs object id (64 lowercase hex chars). */
|
|
32
|
+
export declare function is_lfs_oid(value: unknown): value is string;
|
|
33
|
+
/**
|
|
34
|
+
* Light validation for a refname that came from the remote helper protocol.
|
|
35
|
+
*
|
|
36
|
+
* Rejects empty strings, leading dashes (option injection) and control
|
|
37
|
+
* characters. Valid git refnames are unaffected.
|
|
38
|
+
*/
|
|
39
|
+
export declare function is_safe_ref_name(value: unknown): value is string;
|
|
40
|
+
export declare const LFS_ALIAS_HOST = "lfs-alias.s3ag.test";
|
|
41
|
+
/**
|
|
42
|
+
* Builds the synthetic LFS endpoint URL for a given bucket and prefix.
|
|
43
|
+
*
|
|
44
|
+
* The URL is never contacted; it is purely a stable match key so that
|
|
45
|
+
* lfs.<url>.standalonetransferagent can be scoped per remote, and so
|
|
46
|
+
* git-lfs's HTTPS-shaped endpoint resolution short-circuits its SSH-style
|
|
47
|
+
* discovery for s3ag:// URLs. The hostname uses the RFC 6761-reserved .test
|
|
48
|
+
* TLD to guarantee non-collision with any real host.
|
|
49
|
+
*
|
|
50
|
+
* Prefix segments are percent-encoded: an unencoded % (e.g. repo%zz) makes
|
|
51
|
+
* git-lfs resolve the endpoint as <unknown>. The owner/bucket segment is
|
|
52
|
+
* encoded as well, because s3ag owners may contain URL-reserved characters.
|
|
53
|
+
*/
|
|
54
|
+
export declare function synthetic_lfs_url(bucket: string, prefix: string): string;
|
|
55
|
+
//# sourceMappingURL=common.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"common.d.ts","sourceRoot":"","sources":["../src/common.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAEvC,MAAM,MAAM,YAAY,GAAG;IACzB,SAAS,GAAG,IAAI;IAChB,MAAM,GAAG,IAAI;IACb,MAAM,GAAG,IAAI;IACb,MAAM,GAAG,IAAI;CACd,CAAC;AAMF;;;;;;;;;;;;;GAaG;AACH,wBAAgB,aAAa,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GAAG,YAAY,CA2C1E;AAMD;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,MAAM,CAEhE;AAED,iFAAiF;AACjF,wBAAgB,UAAU,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,MAAM,CAE1D;AAED;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,MAAM,CAOhE;AAED,eAAO,MAAM,cAAc,wBAAwB,CAAC;AAEpD;;;;;;;;;;;;GAYG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAOxE"}
|
package/dist/common.js
ADDED
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
// SPDX-FileCopyrightText: 2023-present Amazon.com, Inc. or its affiliates
|
|
2
|
+
//
|
|
3
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
import { UriScheme } from "./enums.js";
|
|
5
|
+
const LEGACY_GIT_URL_RE = /^(s3\+zip|s3):\/\/([^@]+@)?([a-z0-9][a-z0-9.-]{2,62})\/?(.+)?$/;
|
|
6
|
+
const S3AG_GIT_URL_RE = /^(s3ag\+zip|s3ag):\/\/([^/]+)\/?(.+)?$/;
|
|
7
|
+
/**
|
|
8
|
+
* Parses the elements in an s3ag:// remote origin URI.
|
|
9
|
+
*
|
|
10
|
+
* The URI shape is inherited from git-remote-s3, with one deliberate change:
|
|
11
|
+
*
|
|
12
|
+
* s3ag://owner/repo
|
|
13
|
+
* s3ag+zip://owner/repo
|
|
14
|
+
* s3://[profile@]bucket/prefix
|
|
15
|
+
* s3+zip://[profile@]bucket/prefix
|
|
16
|
+
*
|
|
17
|
+
* s3ag:// treats the first path segment as the owner, so usernames containing
|
|
18
|
+
* "@" (for example an email address) remain addressable. Profile syntax is
|
|
19
|
+
* accepted only on the legacy s3:// and s3+zip:// schemes.
|
|
20
|
+
*/
|
|
21
|
+
export function parse_git_url(url) {
|
|
22
|
+
if (url === null || url === undefined) {
|
|
23
|
+
return [null, null, null, null];
|
|
24
|
+
}
|
|
25
|
+
const s3agMatch = S3AG_GIT_URL_RE.exec(url);
|
|
26
|
+
if (s3agMatch !== null) {
|
|
27
|
+
const scheme = s3agMatch[1];
|
|
28
|
+
const owner = s3agMatch[2] ?? null;
|
|
29
|
+
let prefix = s3agMatch[3] ?? null;
|
|
30
|
+
if (prefix !== null) {
|
|
31
|
+
prefix = prefix.replace(/^\/+/, "").replace(/\/+$/, "");
|
|
32
|
+
if (prefix === "")
|
|
33
|
+
prefix = null;
|
|
34
|
+
}
|
|
35
|
+
const uriScheme = scheme === "s3ag+zip" ? UriScheme.S3_ZIP : UriScheme.S3;
|
|
36
|
+
// s3ag:// has no legacy profile component: the first path segment is the
|
|
37
|
+
// owner. This keeps usernames such as alice@example.com addressable.
|
|
38
|
+
return [uriScheme, null, owner, prefix];
|
|
39
|
+
}
|
|
40
|
+
const legacyMatch = LEGACY_GIT_URL_RE.exec(url);
|
|
41
|
+
if (legacyMatch === null) {
|
|
42
|
+
return [null, null, null, null];
|
|
43
|
+
}
|
|
44
|
+
const scheme = legacyMatch[1];
|
|
45
|
+
const profileGroup = legacyMatch[2];
|
|
46
|
+
const bucket = legacyMatch[3] ?? null;
|
|
47
|
+
let prefix = legacyMatch[4] ?? null;
|
|
48
|
+
let profile = null;
|
|
49
|
+
if (profileGroup !== undefined) {
|
|
50
|
+
profile = profileGroup.slice(0, -1);
|
|
51
|
+
}
|
|
52
|
+
if (prefix !== null) {
|
|
53
|
+
prefix = prefix.replace(/^\/+/, "").replace(/\/+$/, "");
|
|
54
|
+
if (prefix === "")
|
|
55
|
+
prefix = null;
|
|
56
|
+
}
|
|
57
|
+
const uriScheme = scheme === "s3+zip" ? UriScheme.S3_ZIP : UriScheme.S3;
|
|
58
|
+
return [uriScheme, profile, bucket, prefix];
|
|
59
|
+
}
|
|
60
|
+
const GIT_OBJECT_ID_RE = /^[0-9a-f]{40}$/;
|
|
61
|
+
const LFS_OID_RE = /^[0-9a-f]{64}$/;
|
|
62
|
+
const CONTROL_CHARS_RE = /[\u0000-\u001f\u007f]/;
|
|
63
|
+
/**
|
|
64
|
+
* Returns true if the value is a full git object id (40 lowercase hex chars).
|
|
65
|
+
*
|
|
66
|
+
* Identifiers that reach us from a remote must be checked before being used
|
|
67
|
+
* in a filesystem path or passed to git — otherwise a malicious server could
|
|
68
|
+
* inject `../` segments.
|
|
69
|
+
*/
|
|
70
|
+
export function is_git_object_id(value) {
|
|
71
|
+
return typeof value === "string" && GIT_OBJECT_ID_RE.test(value);
|
|
72
|
+
}
|
|
73
|
+
/** Returns true if the value is a git-lfs object id (64 lowercase hex chars). */
|
|
74
|
+
export function is_lfs_oid(value) {
|
|
75
|
+
return typeof value === "string" && LFS_OID_RE.test(value);
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Light validation for a refname that came from the remote helper protocol.
|
|
79
|
+
*
|
|
80
|
+
* Rejects empty strings, leading dashes (option injection) and control
|
|
81
|
+
* characters. Valid git refnames are unaffected.
|
|
82
|
+
*/
|
|
83
|
+
export function is_safe_ref_name(value) {
|
|
84
|
+
return (typeof value === "string" &&
|
|
85
|
+
value.length > 0 &&
|
|
86
|
+
!value.startsWith("-") &&
|
|
87
|
+
!CONTROL_CHARS_RE.test(value));
|
|
88
|
+
}
|
|
89
|
+
export const LFS_ALIAS_HOST = "lfs-alias.s3ag.test";
|
|
90
|
+
/**
|
|
91
|
+
* Builds the synthetic LFS endpoint URL for a given bucket and prefix.
|
|
92
|
+
*
|
|
93
|
+
* The URL is never contacted; it is purely a stable match key so that
|
|
94
|
+
* lfs.<url>.standalonetransferagent can be scoped per remote, and so
|
|
95
|
+
* git-lfs's HTTPS-shaped endpoint resolution short-circuits its SSH-style
|
|
96
|
+
* discovery for s3ag:// URLs. The hostname uses the RFC 6761-reserved .test
|
|
97
|
+
* TLD to guarantee non-collision with any real host.
|
|
98
|
+
*
|
|
99
|
+
* Prefix segments are percent-encoded: an unencoded % (e.g. repo%zz) makes
|
|
100
|
+
* git-lfs resolve the endpoint as <unknown>. The owner/bucket segment is
|
|
101
|
+
* encoded as well, because s3ag owners may contain URL-reserved characters.
|
|
102
|
+
*/
|
|
103
|
+
export function synthetic_lfs_url(bucket, prefix) {
|
|
104
|
+
const quotedBucket = encodeURIComponent(bucket);
|
|
105
|
+
const quotedPrefix = prefix
|
|
106
|
+
.split("/")
|
|
107
|
+
.map((segment) => encodeURIComponent(segment).replace(/[!'()*]/g, percent))
|
|
108
|
+
.join("/");
|
|
109
|
+
return `https://${LFS_ALIAS_HOST}/${quotedBucket}/${quotedPrefix}`;
|
|
110
|
+
}
|
|
111
|
+
function percent(char) {
|
|
112
|
+
return `%${char.charCodeAt(0).toString(16).toUpperCase()}`;
|
|
113
|
+
}
|
|
114
|
+
//# sourceMappingURL=common.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"common.js","sourceRoot":"","sources":["../src/common.ts"],"names":[],"mappings":"AAAA,0EAA0E;AAC1E,EAAE;AACF,sCAAsC;AAEtC,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AASvC,MAAM,iBAAiB,GACrB,gEAAgE,CAAC;AACnE,MAAM,eAAe,GAAG,wCAAwC,CAAC;AAEjE;;;;;;;;;;;;;GAaG;AACH,MAAM,UAAU,aAAa,CAAC,GAA8B;IAC1D,IAAI,GAAG,KAAK,IAAI,IAAI,GAAG,KAAK,SAAS,EAAE,CAAC;QACtC,OAAO,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;IAClC,CAAC;IAED,MAAM,SAAS,GAAG,eAAe,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAC5C,IAAI,SAAS,KAAK,IAAI,EAAE,CAAC;QACvB,MAAM,MAAM,GAAG,SAAS,CAAC,CAAC,CAAC,CAAC;QAC5B,MAAM,KAAK,GAAG,SAAS,CAAC,CAAC,CAAC,IAAI,IAAI,CAAC;QACnC,IAAI,MAAM,GAAkB,SAAS,CAAC,CAAC,CAAC,IAAI,IAAI,CAAC;QACjD,IAAI,MAAM,KAAK,IAAI,EAAE,CAAC;YACpB,MAAM,GAAG,MAAM,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;YACxD,IAAI,MAAM,KAAK,EAAE;gBAAE,MAAM,GAAG,IAAI,CAAC;QACnC,CAAC;QACD,MAAM,SAAS,GACb,MAAM,KAAK,UAAU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AC,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,WAAW,EAAE,EAAE,CAAC;AAC7D,CAAC"}
|
package/dist/config.d.ts
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export type AuthConfig = {
|
|
2
|
+
token?: string;
|
|
3
|
+
sandboxNetworkInterception?: boolean;
|
|
4
|
+
sandboxNetworkInterceptionCaRoot?: string;
|
|
5
|
+
};
|
|
6
|
+
export type S3AgConfig = {
|
|
7
|
+
server?: string;
|
|
8
|
+
auth?: AuthConfig;
|
|
9
|
+
/**
|
|
10
|
+
* Explicitly opt in to sending credentials over cleartext HTTP.
|
|
11
|
+
* Required when `server` uses the `http:` scheme.
|
|
12
|
+
*/
|
|
13
|
+
allowInsecureHttp?: boolean;
|
|
14
|
+
};
|
|
15
|
+
export declare function load_config(): S3AgConfig;
|
|
16
|
+
export declare function save_config(config: S3AgConfig): void;
|
|
17
|
+
//# sourceMappingURL=config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAQA,MAAM,MAAM,UAAU,GAAG;IACvB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,0BAA0B,CAAC,EAAE,OAAO,CAAC;IACrC,gCAAgC,CAAC,EAAE,MAAM,CAAC;CAC3C,CAAC;AAEF,MAAM,MAAM,UAAU,GAAG;IACvB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,UAAU,CAAC;IAClB;;;OAGG;IACH,iBAAiB,CAAC,EAAE,OAAO,CAAC;CAC7B,CAAC;AAUF,wBAAgB,WAAW,IAAI,UAAU,CAWxC;AAED,wBAAgB,WAAW,CAAC,MAAM,EAAE,UAAU,GAAG,IAAI,CAqBpD"}
|
package/dist/config.js
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
// SPDX-FileCopyrightText: 2024-present s3ag contributors
|
|
2
|
+
//
|
|
3
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
import * as fs from "node:fs";
|
|
5
|
+
import * as os from "node:os";
|
|
6
|
+
import * as path from "node:path";
|
|
7
|
+
function configDir() {
|
|
8
|
+
return process.env.S3AG_CONFIG_DIR ?? path.join(os.homedir(), ".s3ag");
|
|
9
|
+
}
|
|
10
|
+
function configPath() {
|
|
11
|
+
return path.join(configDir(), "config.json");
|
|
12
|
+
}
|
|
13
|
+
export function load_config() {
|
|
14
|
+
const p = configPath();
|
|
15
|
+
if (!fs.existsSync(p)) {
|
|
16
|
+
return {};
|
|
17
|
+
}
|
|
18
|
+
try {
|
|
19
|
+
const raw = fs.readFileSync(p, "utf8");
|
|
20
|
+
return JSON.parse(raw);
|
|
21
|
+
}
|
|
22
|
+
catch {
|
|
23
|
+
return {};
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
export function save_config(config) {
|
|
27
|
+
const dir = configDir();
|
|
28
|
+
fs.mkdirSync(dir, { recursive: true, mode: 0o700 });
|
|
29
|
+
try {
|
|
30
|
+
// mkdir's mode is subject to the umask and is ignored for an existing
|
|
31
|
+
// directory, so tighten it explicitly where the platform supports it.
|
|
32
|
+
fs.chmodSync(dir, 0o700);
|
|
33
|
+
}
|
|
34
|
+
catch {
|
|
35
|
+
// Windows and some filesystems do not support POSIX modes.
|
|
36
|
+
}
|
|
37
|
+
const p = configPath();
|
|
38
|
+
fs.writeFileSync(p, JSON.stringify(config, null, 2), {
|
|
39
|
+
encoding: "utf8",
|
|
40
|
+
mode: 0o600,
|
|
41
|
+
});
|
|
42
|
+
try {
|
|
43
|
+
// writeFileSync only applies mode on creation; fix an existing file too.
|
|
44
|
+
fs.chmodSync(p, 0o600);
|
|
45
|
+
}
|
|
46
|
+
catch {
|
|
47
|
+
// Windows and some filesystems do not support POSIX modes.
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
//# sourceMappingURL=config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{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,CAAC,GAAG,UAAU,EAAE,CAAC;IACvB,EAAE,CAAC,aAAa,CAAC,CAAC,EAAE,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,EAAE;QACnD,QAAQ,EAAE,MAAM;QAChB,IAAI,EAAE,KAAK;KACZ,CAAC,CAAC;IACH,IAAI,CAAC;QACH,yEAAyE;QACzE,EAAE,CAAC,SAAS,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC;IACzB,CAAC;IAAC,MAAM,CAAC;QACP,2DAA2D;IAC7D,CAAC;AACH,CAAC"}
|
package/dist/enums.d.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export declare enum UriScheme {
|
|
2
|
+
S3 = "s3ag",
|
|
3
|
+
S3_ZIP = "s3ag+zip"
|
|
4
|
+
}
|
|
5
|
+
/**
|
|
6
|
+
* Legacy schemes accepted for backwards compatibility with the original
|
|
7
|
+
* git-remote-s3 transport. New remotes should use the s3ag:// scheme.
|
|
8
|
+
*/
|
|
9
|
+
export declare const LEGACY_URI_SCHEMES: readonly ["s3", "s3+zip"];
|
|
10
|
+
//# sourceMappingURL=enums.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"enums.d.ts","sourceRoot":"","sources":["../src/enums.ts"],"names":[],"mappings":"AAIA,oBAAY,SAAS;IACnB,EAAE,SAAS;IACX,MAAM,aAAa;CACpB;AAED;;;GAGG;AACH,eAAO,MAAM,kBAAkB,2BAA4B,CAAC"}
|
package/dist/enums.js
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
// SPDX-FileCopyrightText: 2023-present Amazon.com, Inc. or its affiliates
|
|
2
|
+
//
|
|
3
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
export var UriScheme;
|
|
5
|
+
(function (UriScheme) {
|
|
6
|
+
UriScheme["S3"] = "s3ag";
|
|
7
|
+
UriScheme["S3_ZIP"] = "s3ag+zip";
|
|
8
|
+
})(UriScheme || (UriScheme = {}));
|
|
9
|
+
/**
|
|
10
|
+
* Legacy schemes accepted for backwards compatibility with the original
|
|
11
|
+
* git-remote-s3 transport. New remotes should use the s3ag:// scheme.
|
|
12
|
+
*/
|
|
13
|
+
export const LEGACY_URI_SCHEMES = ["s3", "s3+zip"];
|
|
14
|
+
//# sourceMappingURL=enums.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"enums.js","sourceRoot":"","sources":["../src/enums.ts"],"names":[],"mappings":"AAAA,0EAA0E;AAC1E,EAAE;AACF,sCAAsC;AAEtC,MAAM,CAAN,IAAY,SAGX;AAHD,WAAY,SAAS;IACnB,wBAAW,CAAA;IACX,gCAAmB,CAAA;AACrB,CAAC,EAHW,SAAS,KAAT,SAAS,QAGpB;AAED;;;GAGG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,IAAI,EAAE,QAAQ,CAAU,CAAC"}
|
package/dist/exit.d.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Thrown where the original Python implementation called sys.exit(). Keeping
|
|
3
|
+
* this as an exception makes the library functions testable while the CLI
|
|
4
|
+
* entry points translate it into a real process exit code.
|
|
5
|
+
*/
|
|
6
|
+
export declare class SystemExit extends Error {
|
|
7
|
+
readonly code: number;
|
|
8
|
+
constructor(code?: number);
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=exit.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"exit.d.ts","sourceRoot":"","sources":["../src/exit.ts"],"names":[],"mappings":"AAIA;;;;GAIG;AACH,qBAAa,UAAW,SAAQ,KAAK;aACP,IAAI,EAAE,MAAM;gBAAZ,IAAI,GAAE,MAAU;CAI7C"}
|
package/dist/exit.js
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
// SPDX-FileCopyrightText: 2023-present Amazon.com, Inc. or its affiliates
|
|
2
|
+
//
|
|
3
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
/**
|
|
5
|
+
* Thrown where the original Python implementation called sys.exit(). Keeping
|
|
6
|
+
* this as an exception makes the library functions testable while the CLI
|
|
7
|
+
* entry points translate it into a real process exit code.
|
|
8
|
+
*/
|
|
9
|
+
export class SystemExit extends Error {
|
|
10
|
+
code;
|
|
11
|
+
constructor(code = 1) {
|
|
12
|
+
super(`exit ${code}`);
|
|
13
|
+
this.code = code;
|
|
14
|
+
this.name = "SystemExit";
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=exit.js.map
|
package/dist/exit.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"exit.js","sourceRoot":"","sources":["../src/exit.ts"],"names":[],"mappings":"AAAA,0EAA0E;AAC1E,EAAE;AACF,sCAAsC;AAEtC;;;;GAIG;AACH,MAAM,OAAO,UAAW,SAAQ,KAAK;IACP;IAA5B,YAA4B,OAAe,CAAC;QAC1C,KAAK,CAAC,QAAQ,IAAI,EAAE,CAAC,CAAC;QADI,SAAI,GAAJ,IAAI,CAAY;QAE1C,IAAI,CAAC,IAAI,GAAG,YAAY,CAAC;IAC3B,CAAC;CACF"}
|
package/dist/git.d.ts
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
export declare class GitError extends Error {
|
|
2
|
+
}
|
|
3
|
+
/** Archive the content of the folder into a repo.zip file. */
|
|
4
|
+
export declare function archive(options: {
|
|
5
|
+
folder: string;
|
|
6
|
+
ref: string;
|
|
7
|
+
}): string;
|
|
8
|
+
/** Bundles the content of the folder into a sha.bundle file. */
|
|
9
|
+
export declare function bundle(options: {
|
|
10
|
+
folder: string;
|
|
11
|
+
sha: string;
|
|
12
|
+
ref: string;
|
|
13
|
+
}): string;
|
|
14
|
+
/** Verifies that a bundle file is valid and can be applied to this repo. */
|
|
15
|
+
export declare function verify_bundle(filePath: string): void;
|
|
16
|
+
/** Unbundles the content of the bundle referred by the sha. */
|
|
17
|
+
export declare function unbundle(options: {
|
|
18
|
+
folder: string;
|
|
19
|
+
sha: string;
|
|
20
|
+
ref: string;
|
|
21
|
+
}): void;
|
|
22
|
+
/** Gets the sha of a ref. */
|
|
23
|
+
export declare function rev_parse(ref: string): string;
|
|
24
|
+
/** Checks if the ancestor is an ancestor of the descendant. */
|
|
25
|
+
export declare function is_ancestor(ancestor: string, descendant: string): boolean;
|
|
26
|
+
/** Gets the URL configured for a git remote. */
|
|
27
|
+
export declare function get_remote_url(remote: string): string;
|
|
28
|
+
export declare function validate_ref_name(name: string): boolean;
|
|
29
|
+
/** Gets the short sha and subject line of the last commit. */
|
|
30
|
+
export declare function get_last_commit_message(): string;
|
|
31
|
+
export type CommitLogEntry = {
|
|
32
|
+
sha: string;
|
|
33
|
+
message: string;
|
|
34
|
+
authorName: string;
|
|
35
|
+
authorEmail: string;
|
|
36
|
+
authoredAt: string;
|
|
37
|
+
};
|
|
38
|
+
/**
|
|
39
|
+
* Lists commits reachable from `newSha` but not from `notSha`, newest first.
|
|
40
|
+
* When `notSha` is null, lists the full history of `newSha`.
|
|
41
|
+
*/
|
|
42
|
+
export declare function log_commits(newSha: string, notSha: string | null, maxCount?: number): CommitLogEntry[];
|
|
43
|
+
export declare function pathExists(filePath: string): boolean;
|
|
44
|
+
//# sourceMappingURL=git.d.ts.map
|