@biffo/cli 0.41.10 → 0.41.11
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/core.version +1 -1
- package/dist/index.js +43 -3
- package/package.json +1 -1
package/core.version
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
0.41.
|
|
1
|
+
0.41.11
|
package/dist/index.js
CHANGED
|
@@ -835,6 +835,39 @@ var GitHubAdapter = class {
|
|
|
835
835
|
log.info(`Committed ${files.map((f) => f.path).join(", ")} to ${branch}`);
|
|
836
836
|
return commit.sha;
|
|
837
837
|
}
|
|
838
|
+
/** The commit SHA at the head of `branch`. */
|
|
839
|
+
async getBranchSha(org, repo, branch) {
|
|
840
|
+
const ref = await this.waitForRef(org, repo, `heads/${branch}`, 12e4, 3e3);
|
|
841
|
+
return ref.object.sha;
|
|
842
|
+
}
|
|
843
|
+
/**
|
|
844
|
+
* Point `branch` at `sha` via a fast-forward-only ref update (issue #329).
|
|
845
|
+
*
|
|
846
|
+
* `sha` must be an ancestor-descendant of the branch's current head:
|
|
847
|
+
* GitHub's `updateRef` rejects a non-fast-forward move unless `force` is set,
|
|
848
|
+
* and it is deliberately left unset here. The only caller is `writeInstanceFiles`,
|
|
849
|
+
* moving a freshly-created branch onto the instance commit built on that
|
|
850
|
+
* branch's own shared base — always a fast-forward. If it ever isn't, failing
|
|
851
|
+
* loudly is the correct outcome, not clobbering history.
|
|
852
|
+
*
|
|
853
|
+
* Idempotent: a no-op (no API write) when `branch` is already at `sha`, so a
|
|
854
|
+
* resumed init neither errors nor rewrites anything.
|
|
855
|
+
*/
|
|
856
|
+
async fastForwardBranch(org, repo, branch, sha) {
|
|
857
|
+
const current = await this.getBranchSha(org, repo, branch);
|
|
858
|
+
if (current === sha) {
|
|
859
|
+
log.info(`${branch} already at ${sha.slice(0, 7)} \u2014 skipping`);
|
|
860
|
+
return;
|
|
861
|
+
}
|
|
862
|
+
await this.octokit.git.updateRef({
|
|
863
|
+
owner: org,
|
|
864
|
+
repo,
|
|
865
|
+
ref: `heads/${branch}`,
|
|
866
|
+
sha,
|
|
867
|
+
force: false
|
|
868
|
+
});
|
|
869
|
+
log.info(`Fast-forwarded ${branch} to ${sha.slice(0, 7)}`);
|
|
870
|
+
}
|
|
838
871
|
async setDefaultBranch(org, repo, branch) {
|
|
839
872
|
await this.octokit.repos.update({ owner: org, repo, default_branch: branch });
|
|
840
873
|
log.info(`Default branch set to ${branch}`);
|
|
@@ -4814,7 +4847,12 @@ function appSiblingRegistryFiles(config) {
|
|
|
4814
4847
|
}));
|
|
4815
4848
|
}
|
|
4816
4849
|
var INSTANCE_CONFIG_FILE = "biffo.config.json";
|
|
4817
|
-
var
|
|
4850
|
+
var INSTANCE_FILE_BASE_BRANCH = "main";
|
|
4851
|
+
var INSTANCE_FILE_FOLLOWER_BRANCHES = ["dev", "staging"];
|
|
4852
|
+
var INSTANCE_FILE_BRANCHES = [
|
|
4853
|
+
INSTANCE_FILE_BASE_BRANCH,
|
|
4854
|
+
...INSTANCE_FILE_FOLLOWER_BRANCHES
|
|
4855
|
+
];
|
|
4818
4856
|
async function writeInstanceFiles(github, org, repo, config) {
|
|
4819
4857
|
const files = [
|
|
4820
4858
|
{ path: INSTANCE_CORE_FILE, content: serializeInstanceCoreVersion(getLatestCoreVersion()) },
|
|
@@ -4822,8 +4860,10 @@ async function writeInstanceFiles(github, org, repo, config) {
|
|
|
4822
4860
|
...config ? appSiblingRegistryFiles(config) : []
|
|
4823
4861
|
];
|
|
4824
4862
|
const message = config ? `chore: record core version, register the ${ROOT_SIBLING_NAME} sibling, and drop the template ${INSTANCE_CONFIG_FILE}` : `chore: record core version and drop the template ${INSTANCE_CONFIG_FILE}`;
|
|
4825
|
-
|
|
4826
|
-
|
|
4863
|
+
const committed = await github.commitFiles(org, repo, INSTANCE_FILE_BASE_BRANCH, files, message);
|
|
4864
|
+
const sharedSha = committed ?? await github.getBranchSha(org, repo, INSTANCE_FILE_BASE_BRANCH);
|
|
4865
|
+
for (const branch of INSTANCE_FILE_FOLLOWER_BRANCHES) {
|
|
4866
|
+
await github.fastForwardBranch(org, repo, branch, sharedSha);
|
|
4827
4867
|
}
|
|
4828
4868
|
}
|
|
4829
4869
|
function printPlan2(config) {
|