@brainervirus/workit-core 8.12.3 → 8.13.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.
@@ -25,6 +25,7 @@ import fs from "node:fs";
25
25
  import os from "node:os";
26
26
  import path from "node:path";
27
27
  import { releaseBranch, resolveBranchPolicyFor, validateBranchNameFor } from "../core/branch";
28
+ import { releaseTagPrefixOf } from "../core/branch-policy";
28
29
  import { resolveRuntimeWorkspaceVcs } from "../core/workspaces";
29
30
  import { appendHookObserved, readLedger } from "../ledger";
30
31
  import { resolveStore, resolveTaskKey, type StoreLocation } from "../store/paths";
@@ -1340,7 +1341,7 @@ const refusal = (action: RawAction, branch: string | null, dir?: string): string
1340
1341
  // custom protected branch): the push has its own granted verb.
1341
1342
  const plainPush = action.kind === "push" && !action.blindForce && !action.deletes;
1342
1343
  if (dir && branch && plainPush && releaseBranch(dir, branch))
1343
- return `workit: raw ${quote("git push")} onto ${branch}, a protected release branch, bypasses workit's protected-branch check. To finish a release or hotfix, push it with ${quote(`workit git push --release ${branch} [--release v<version>]`)}: it pushes ${branch} (fast-forward only) and the release tag, verifies the remote and records it, under the ${quote("release")} grant (if refused, ask the user to run ${quote("workit grant set <workspace> release=true")}). Feature work goes through ${quote("workit git push")} and ${quote("workit pr merge")}.`;
1344
+ return `workit: raw ${quote("git push")} onto ${branch}, a protected release branch, bypasses workit's protected-branch check. To finish a release or hotfix, push it with ${quote(`workit git push --release ${branch} [--release ${releaseTagPrefixOf(dir)}<version>]`)}: it pushes ${branch} (fast-forward only) and the release tag, verifies the remote and records it, under the ${quote("release")} grant (if refused, ask the user to run ${quote("workit grant set <workspace> release=true")}). Feature work goes through ${quote("workit git push")} and ${quote("workit pr merge")}.`;
1344
1345
  return `workit: raw ${quote("git push")}${action.kind === "push" && action.blindForce ? " --force" : ""} onto ${branch}, a protected branch or the default target, bypasses workit's protected-branch check. Push your feature branch with ${quote("workit git push")} (${quote("workit git push --force-with-lease")} to rewrite it) and land it with ${quote("workit pr merge")}.`;
1345
1346
  };
1346
1347
 
@@ -1459,14 +1460,15 @@ const isTag = (facts: RefFacts, name: string): boolean =>
1459
1460
  * the release grant: denied with the workit command. `--follow-tags` only
1460
1461
  * nudges (it pushes annotated tags the pushed commits already reach).
1461
1462
  */
1462
- const tagRefusal = (action: PushAction, facts: RefFacts): string | null => {
1463
+ const tagRefusal = (action: PushAction, facts: RefFacts, dir: string): string | null => {
1463
1464
  const tags = [
1464
1465
  ...(action.tags ?? []),
1465
1466
  ...action.targets.filter((name): name is string => name !== null && isTag(facts, name)),
1466
1467
  ];
1467
1468
  if (!tags.length && !action.allTags) return null;
1468
- const named = tags.length ? tags.join(" --release ") : "v<version>";
1469
- return `workit: raw ${quote(`git push${action.allTags ? " --tags" : ""}`)} of ${tags.length ? `tag ${tags.join(", ")}` : "tags"} bypasses the release grant. Push a release tag with ${quote(`workit git push --release ${named}`)} (v<version> tags whose commit the production branch already has; a tag never moves), under the ${quote("release")} grant (if refused, ask the user to run ${quote("workit grant set <workspace> release=true")}).`;
1469
+ const shape = `${releaseTagPrefixOf(dir)}<version>`;
1470
+ const named = tags.length ? tags.join(" --release ") : shape;
1471
+ return `workit: raw ${quote(`git push${action.allTags ? " --tags" : ""}`)} of ${tags.length ? `tag ${tags.join(", ")}` : "tags"} bypasses the release grant. Push a release tag with ${quote(`workit git push --release ${named}`)} (${shape} tags whose commit the production branch already has; a tag never moves), under the ${quote("release")} grant (if refused, ask the user to run ${quote("workit grant set <workspace> release=true")}).`;
1470
1472
  };
1471
1473
 
1472
1474
  /** The remote's branches (`ls-remote --heads`, bounded); null when it cannot be read. */
@@ -1557,7 +1559,7 @@ const pushRefusal = (action: PushAction, repo: Repo, config: GitConfig): string
1557
1559
  if (guarded) return refusal(action, guarded, repo.dir);
1558
1560
  }
1559
1561
  return (
1560
- tagRefusal(pushed, facts) ??
1562
+ tagRefusal(pushed, facts, repo.dir) ??
1561
1563
  (action.deletes ? null : offPolicyPush(pushed, repo, facts, remote))
1562
1564
  );
1563
1565
  };