@theholocron/holocron-plugin-github 5.5.1 → 5.6.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/dist/index.d.mts +1 -0
- package/dist/index.mjs +35 -2
- package/package.json +7 -7
package/dist/index.d.mts
CHANGED
|
@@ -448,6 +448,7 @@ export declare class GitHubSource implements Source {
|
|
|
448
448
|
repo?: string;
|
|
449
449
|
}): Promise<void>;
|
|
450
450
|
ensureTag(tag: string, repo?: string): Promise<boolean>;
|
|
451
|
+
moveTag(tag: string, repo?: string): Promise<boolean>;
|
|
451
452
|
listBranches(repo?: string): Promise<SourceBranch[]>;
|
|
452
453
|
deleteBranch(name: string, repo?: string): Promise<void>;
|
|
453
454
|
listPullRequestCommits(number: number, repo?: string): Promise<string[]>;
|
package/dist/index.mjs
CHANGED
|
@@ -2302,6 +2302,15 @@ async function deleteRepoFile(client, repo, path, opts) {
|
|
|
2302
2302
|
}
|
|
2303
2303
|
}
|
|
2304
2304
|
/**
|
|
2305
|
+
* The commit a tag reference ends at. A lightweight tag points at the commit; an annotated one points at a tag object
|
|
2306
|
+
* (which can point at another), so its SHA is never the commit's and has to be followed.
|
|
2307
|
+
*/
|
|
2308
|
+
async function tagCommit(client, repo, ref) {
|
|
2309
|
+
let object = ref.object;
|
|
2310
|
+
while (object.type === "tag") object = (await client.git.getTag(repo, object.sha)).object;
|
|
2311
|
+
return object.sha;
|
|
2312
|
+
}
|
|
2313
|
+
/**
|
|
2305
2314
|
* Tags the default branch's head `tag`. A tag already there at the same content (the same commit, or another commit
|
|
2306
2315
|
* with the same tree) is left alone and answers `false`; one at other content throws, because a version tag is never
|
|
2307
2316
|
* moved. `true` when it made the tag.
|
|
@@ -2318,10 +2327,31 @@ async function ensureRepoTag(client, repo, tag) {
|
|
|
2318
2327
|
await client.git.createRef(repo, `refs/tags/${tag}`, head.commit);
|
|
2319
2328
|
return true;
|
|
2320
2329
|
}
|
|
2321
|
-
|
|
2322
|
-
if (
|
|
2330
|
+
const target = await tagCommit(client, repo, existing);
|
|
2331
|
+
if (target === head.commit) return false;
|
|
2332
|
+
if ((await client.git.getCommit(repo, target)).tree.sha === head.tree) return false;
|
|
2323
2333
|
throw new Error(`${repo} already has the tag ${tag} at other content: bump the version instead of moving the tag`);
|
|
2324
2334
|
}
|
|
2335
|
+
/**
|
|
2336
|
+
* Points `tag`, a tag that moves (a major tag such as `templates-v1`), at the default branch's head: made when it is
|
|
2337
|
+
* missing, moved when it is elsewhere. `true` when it made or moved the tag, `false` when it was already at the head.
|
|
2338
|
+
*/
|
|
2339
|
+
async function moveRepoTag(client, repo, tag) {
|
|
2340
|
+
const head = await defaultHead(client, repo);
|
|
2341
|
+
let existing;
|
|
2342
|
+
try {
|
|
2343
|
+
existing = await client.git.getTagRef(repo, tag);
|
|
2344
|
+
} catch (err) {
|
|
2345
|
+
if (!(err instanceof ProviderApiError && err.status === 404)) throw err;
|
|
2346
|
+
}
|
|
2347
|
+
if (!existing) {
|
|
2348
|
+
await client.git.createRef(repo, `refs/tags/${tag}`, head.commit);
|
|
2349
|
+
return true;
|
|
2350
|
+
}
|
|
2351
|
+
if (await tagCommit(client, repo, existing) === head.commit) return false;
|
|
2352
|
+
await client.git.updateRef(repo, `tags/${tag}`, head.commit, true);
|
|
2353
|
+
return true;
|
|
2354
|
+
}
|
|
2325
2355
|
// src/capabilities/labels.ts
|
|
2326
2356
|
/**
|
|
2327
2357
|
* Idempotently synchronise a repo's labels to the canonical set.
|
|
@@ -3358,6 +3388,9 @@ var GitHubSource = class {
|
|
|
3358
3388
|
async ensureTag(tag, repo = this.repo) {
|
|
3359
3389
|
return ensureRepoTag(this.userSyncClient ?? this.orgClient ?? this.client, repo, tag);
|
|
3360
3390
|
}
|
|
3391
|
+
async moveTag(tag, repo = this.repo) {
|
|
3392
|
+
return moveRepoTag(this.userSyncClient ?? this.orgClient ?? this.client, repo, tag);
|
|
3393
|
+
}
|
|
3361
3394
|
async listBranches(repo) {
|
|
3362
3395
|
return (await this.client.branches.listBranches(repo ?? this.repo)).map((b) => ({
|
|
3363
3396
|
name: b.name,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@theholocron/holocron-plugin-github",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.6.0",
|
|
4
4
|
"description": "Holocron plugin for GitHub. Implements source, ci, secrets, environments, and issues capabilities against the GitHub REST API.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ci",
|
|
@@ -44,21 +44,21 @@
|
|
|
44
44
|
"tsx": "4.23.15",
|
|
45
45
|
"typescript": "^6.0.3",
|
|
46
46
|
"vitest": "^5.1.2",
|
|
47
|
-
"@theholocron/cli": "5.
|
|
48
|
-
"@theholocron/eslint-config": "^9.
|
|
47
|
+
"@theholocron/cli": "5.6.0",
|
|
48
|
+
"@theholocron/eslint-config": "^9.1.0",
|
|
49
49
|
"@theholocron/fs-utils": "^2.0.0",
|
|
50
50
|
"@theholocron/github-client": "^2.2.0",
|
|
51
51
|
"@theholocron/http-client": "^2.2.0",
|
|
52
52
|
"@theholocron/misc-utils": "^2.0.0",
|
|
53
|
-
"@theholocron/tsconfig": "^9.
|
|
54
|
-
"@theholocron/tsdown-config": "^9.
|
|
55
|
-
"@theholocron/vitest-config": "^9.
|
|
53
|
+
"@theholocron/tsconfig": "^9.1.0",
|
|
54
|
+
"@theholocron/tsdown-config": "^9.1.0",
|
|
55
|
+
"@theholocron/vitest-config": "^9.1.0"
|
|
56
56
|
},
|
|
57
57
|
"peerDependencies": {
|
|
58
58
|
"@theholocron/fs-utils": "^2.0.0",
|
|
59
59
|
"@theholocron/github-client": "^2.0.0",
|
|
60
60
|
"@theholocron/misc-utils": "^2.0.0",
|
|
61
|
-
"@theholocron/cli": "5.
|
|
61
|
+
"@theholocron/cli": "5.6.0"
|
|
62
62
|
},
|
|
63
63
|
"engines": {
|
|
64
64
|
"node": ">=22"
|