@biffo/cli 0.73.0 → 0.73.1

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/index.js +16 -2
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -1737,6 +1737,18 @@ function coreTag(version) {
1737
1737
  return `core-v${version}`;
1738
1738
  }
1739
1739
  var defaultGit = (args) => execFileSync2("git", args, { encoding: "utf8" });
1740
+ function workingTreeMatchesTag(repo, version, git = defaultGit) {
1741
+ const tag = coreTag(version);
1742
+ try {
1743
+ const head = git(["-C", repo, "rev-parse", "HEAD"]).trim();
1744
+ const tagCommit = git(["-C", repo, "rev-parse", `${tag}^{commit}`]).trim();
1745
+ if (!head || head !== tagCommit) return false;
1746
+ const dirty = git(["-C", repo, "status", "--porcelain", "--untracked-files=no"]).trim();
1747
+ return dirty === "";
1748
+ } catch {
1749
+ return false;
1750
+ }
1751
+ }
1740
1752
  function tagExists(repo, tag, git) {
1741
1753
  try {
1742
1754
  git(["-C", repo, "rev-parse", "-q", "--verify", `refs/tags/${tag}`]);
@@ -2108,7 +2120,8 @@ function defaultDeps() {
2108
2120
  git: new GitAdapter(),
2109
2121
  makeGitHub: (token) => new GitHubAdapter(token),
2110
2122
  resolveToken: resolveGitHubToken,
2111
- materialize: materializeTemplateAtTag
2123
+ materialize: materializeTemplateAtTag,
2124
+ workingTreeMatchesTag
2112
2125
  };
2113
2126
  }
2114
2127
  function resolveGitHubToken() {
@@ -2157,6 +2170,7 @@ async function checkInstanceCurrency(git, cwd, allowDirty) {
2157
2170
  async function runCoreUpgradeResolved(options, deps, cleanups) {
2158
2171
  await checkInstanceCurrency(deps.git, options.cwd, options.allowDirty ?? false);
2159
2172
  const materialize = deps.materialize ?? materializeTemplateAtTag;
2173
+ const treeMatchesTag = deps.workingTreeMatchesTag ?? workingTreeMatchesTag;
2160
2174
  const templateRepo = options.templateRepo ? resolve3(options.templateRepo) : resolveTemplateRoot({ guidance: MISSING_TEMPLATE_ROOT_GUIDANCE2 });
2161
2175
  const instanceVersion = readInstanceCoreVersion(options.cwd);
2162
2176
  let theirsDir;
@@ -2167,7 +2181,7 @@ async function runCoreUpgradeResolved(options, deps, cleanups) {
2167
2181
  } else {
2168
2182
  const workingVersion = latestCoreVersion(templateRepo);
2169
2183
  toVersion = options.toVersion ?? workingVersion;
2170
- if (toVersion === workingVersion) {
2184
+ if (toVersion === workingVersion && treeMatchesTag(templateRepo, toVersion)) {
2171
2185
  theirsDir = templateRepo;
2172
2186
  } else {
2173
2187
  const t = materialize(templateRepo, toVersion);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@biffo/cli",
3
- "version": "0.73.0",
3
+ "version": "0.73.1",
4
4
  "description": "Biffo project scaffolding CLI",
5
5
  "license": "MIT",
6
6
  "type": "module",