@tablation/crew 0.1.5 → 0.1.7

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.
Files changed (2) hide show
  1. package/dist/cli.js +20 -10
  2. package/package.json +1 -1
package/dist/cli.js CHANGED
@@ -2793,6 +2793,12 @@ function gitOk(cwd, args) {
2793
2793
  return null;
2794
2794
  }
2795
2795
  }
2796
+ function commitDate(cwd, sha) {
2797
+ const out = gitOk(cwd, ["show", "-s", "--format=%cI", sha]);
2798
+ if (!out) return null;
2799
+ const t = new Date(out);
2800
+ return Number.isNaN(t.getTime()) ? null : t.toISOString();
2801
+ }
2796
2802
  var currentBranch = (cwd) => git(cwd, ["rev-parse", "--abbrev-ref", "HEAD"]);
2797
2803
  var headSha = (cwd) => git(cwd, ["rev-parse", "HEAD"]);
2798
2804
  function status(cwd) {
@@ -4980,7 +4986,10 @@ function planStamp(cwd, tickets, contract, fromSha, toSha, merged = /* @__PURE__
4980
4986
  return null;
4981
4987
  }).filter((p) => p !== null);
4982
4988
  }
4983
- async function applyStamp(tracker, plan, version, contract, emit, dryRun) {
4989
+ function mergedAtFor(cwd, sha, fallback) {
4990
+ return cwd && commitDate(cwd, sha) || fallback;
4991
+ }
4992
+ async function applyStamp(tracker, plan, version, contract, emit, dryRun, cwd) {
4984
4993
  let stamped = 0;
4985
4994
  const at = (/* @__PURE__ */ new Date()).toISOString();
4986
4995
  for (const { ticket, sha } of plan) {
@@ -4995,13 +5004,14 @@ async function applyStamp(tracker, plan, version, contract, emit, dryRun) {
4995
5004
  try {
4996
5005
  await tracker.updateTicket(ticket.id, {
4997
5006
  status: contract.statuses.deployed,
4998
- ...version ? { released_version: version, released_at: at } : {},
5007
+ // `released_at` is always a real release moment here; only the version is optional (versioning: none).
5008
+ released_at: at,
5009
+ ...version ? { released_version: version } : {},
4999
5010
  // Written here rather than only on the external path (below): a
5000
5011
  // ticket's record should mean the same thing regardless of which
5001
- // release mode closed it (ISSUE-218). `merged_at` is stamped
5002
- // alongside — not read off the commit itself — since that is the
5003
- // moment the tracker learns of it, same as the external path.
5004
- ...sha ? { commit_sha: sha, merged_at: at } : {}
5012
+ // release mode closed it (ISSUE-218). `merged_at` is the commit's own
5013
+ // date, not the stamp time (which trails the deploy in ci_* modes).
5014
+ ...sha ? { commit_sha: sha, merged_at: mergedAtFor(cwd, sha, at) } : {}
5005
5015
  });
5006
5016
  emit.emit(`stamped ${contract.statuses.deployed}${version ? ` (${version})` : ""}${shaNote}`, {
5007
5017
  ticket: ticket.issue_id
@@ -5013,7 +5023,7 @@ async function applyStamp(tracker, plan, version, contract, emit, dryRun) {
5013
5023
  }
5014
5024
  return stamped;
5015
5025
  }
5016
- async function applyExternalClosures(tracker, closures, contract, emit, dryRun) {
5026
+ async function applyExternalClosures(tracker, closures, contract, emit, dryRun, cwd) {
5017
5027
  if (!closures?.length) return 0;
5018
5028
  let stamped = 0;
5019
5029
  const at = (/* @__PURE__ */ new Date()).toISOString();
@@ -5028,7 +5038,7 @@ async function applyExternalClosures(tracker, closures, contract, emit, dryRun)
5028
5038
  try {
5029
5039
  await tracker.updateTicket(ticket.id, {
5030
5040
  commit_sha: closure.mergedAt,
5031
- merged_at: at,
5041
+ merged_at: mergedAtFor(cwd, closure.mergedAt, at),
5032
5042
  ...confirmed ? { status: contract.statuses.deployed, released_at: at, ...version ? { released_version: version } : {} } : {}
5033
5043
  });
5034
5044
  emit.emit(`stamped commit_sha (${closure.mergedAt.slice(0, 8)})${shippedNote}`, { ticket: ticket.issue_id });
@@ -8820,12 +8830,12 @@ ${changed2.map((c) => ` - ${c}
8820
8830
  outcome.decision.head,
8821
8831
  new Map(outcome.merged.map((m) => [m.ticket.issue_id, m.sha]))
8822
8832
  );
8823
- if (plan.length) await applyStamp(tracker, plan, outcome.version, tracker.contract, remit, dryRun);
8833
+ if (plan.length) await applyStamp(tracker, plan, outcome.version, tracker.contract, remit, dryRun, target.dir);
8824
8834
  } else if (outcome.stopped) {
8825
8835
  remit.emit(`nothing stamped \u2014 ${outcome.stopped}`);
8826
8836
  }
8827
8837
  if (outcome.externalClosures?.length) {
8828
- await applyExternalClosures(tracker, outcome.externalClosures, tracker.contract, remit, dryRun);
8838
+ await applyExternalClosures(tracker, outcome.externalClosures, tracker.contract, remit, dryRun, target.dir);
8829
8839
  }
8830
8840
  const news = describeRelease(outcome, scope);
8831
8841
  if (news) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tablation/crew",
3
- "version": "0.1.5",
3
+ "version": "0.1.7",
4
4
  "description": "A standing team of headless agents that picks work off a Tablation board, does it on a machine you control, and reports back.",
5
5
  "type": "module",
6
6
  "license": "MIT",