@biffo/cli 0.185.3 → 0.185.5
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.js +55 -5
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -824,6 +824,29 @@ function classifyUpgradeBranches(refs, currentBranch) {
|
|
|
824
824
|
// src/adapters/git/index.ts
|
|
825
825
|
var GitAdapter = class {
|
|
826
826
|
/** True if `cwd` is inside a git working tree. */
|
|
827
|
+
/**
|
|
828
|
+
* The committer identity git would resolve here, or `null` per unresolved value
|
|
829
|
+
* (#737).
|
|
830
|
+
*
|
|
831
|
+
* `git config --get` exits 1 when a key is unset, which `execa` throws on — so a
|
|
832
|
+
* missing value is caught and reported as `null` rather than as an error. That
|
|
833
|
+
* distinction is the whole point: an unset identity is a condition the caller
|
|
834
|
+
* must act on, not a failure of this lookup.
|
|
835
|
+
*
|
|
836
|
+
* No `cwd` resolves against the process's own configuration, which is what the
|
|
837
|
+
* scaffold's throwaway temp dir inherits.
|
|
838
|
+
*/
|
|
839
|
+
async configuredIdentity(cwd) {
|
|
840
|
+
const read2 = async (key) => {
|
|
841
|
+
try {
|
|
842
|
+
const { stdout } = await execa2("git", ["config", "--get", key], cwd ? { cwd } : {});
|
|
843
|
+
return stdout.trim() || null;
|
|
844
|
+
} catch {
|
|
845
|
+
return null;
|
|
846
|
+
}
|
|
847
|
+
};
|
|
848
|
+
return { name: await read2("user.name"), email: await read2("user.email") };
|
|
849
|
+
}
|
|
827
850
|
async isGitRepo(cwd) {
|
|
828
851
|
try {
|
|
829
852
|
await execa2("git", ["rev-parse", "--is-inside-work-tree"], { cwd });
|
|
@@ -5652,6 +5675,7 @@ async function runSiblingCreate(github, aws, coreAws, git, config, session, opti
|
|
|
5652
5675
|
const totalSteps = 8;
|
|
5653
5676
|
const { org, repo } = githubRepo(config);
|
|
5654
5677
|
const pathPrefix = resolvePathPrefix(config);
|
|
5678
|
+
assertGitIdentity(await git.configuredIdentity());
|
|
5655
5679
|
if (!session.completedSteps.includes("verify_credentials")) {
|
|
5656
5680
|
log.step(1, totalSteps, "Verifying AWS credentials...");
|
|
5657
5681
|
await aws.verifyCredentials();
|
|
@@ -5944,6 +5968,18 @@ function readExistingSiblingOrigins(filePath) {
|
|
|
5944
5968
|
throw err;
|
|
5945
5969
|
}
|
|
5946
5970
|
}
|
|
5971
|
+
function assertGitIdentity(identity) {
|
|
5972
|
+
const missing = [identity.name ? null : "user.name", identity.email ? null : "user.email"].filter(
|
|
5973
|
+
(v) => v !== null
|
|
5974
|
+
);
|
|
5975
|
+
if (missing.length === 0) return;
|
|
5976
|
+
throw new Error(
|
|
5977
|
+
`git has no ${missing.join(" or ")} configured, so the scaffold commit would fail after the GitHub repository had already been created. Set it first:
|
|
5978
|
+
` + missing.map(
|
|
5979
|
+
(k) => ` git config --global ${k} "${k === "user.name" ? "Your Name" : "you@example.com"}"`
|
|
5980
|
+
).join("\n")
|
|
5981
|
+
);
|
|
5982
|
+
}
|
|
5947
5983
|
function assertCoreSupportsSiblingRouting(cloneDir, coreRepo, pathPrefix = "x") {
|
|
5948
5984
|
const cdnVarsPath = join20(cloneDir, "modules", "cloud", "aws", "cdn", "variables.tf");
|
|
5949
5985
|
let declaresSiblingOrigins = false;
|
|
@@ -8567,9 +8603,9 @@ function deriveRequiredContexts(observed) {
|
|
|
8567
8603
|
const required = Math.ceil(window.length * CONTEXT_CONSISTENCY_THRESHOLD);
|
|
8568
8604
|
return [...seenOn.entries()].filter(([, shas]) => shas.size >= required).map(([name]) => name).sort();
|
|
8569
8605
|
}
|
|
8570
|
-
function protectionParamsFor(contexts) {
|
|
8606
|
+
function protectionParamsFor(contexts, options = {}) {
|
|
8571
8607
|
return {
|
|
8572
|
-
required_status_checks: { strict: true, contexts: [...contexts].sort() },
|
|
8608
|
+
required_status_checks: { strict: options.strict ?? true, contexts: [...contexts].sort() },
|
|
8573
8609
|
enforce_admins: false,
|
|
8574
8610
|
required_pull_request_reviews: {
|
|
8575
8611
|
required_approving_review_count: 0,
|
|
@@ -8702,6 +8738,7 @@ async function runBranchProtectionCheck(explicitRepo, options = {}) {
|
|
|
8702
8738
|
});
|
|
8703
8739
|
const findings = [];
|
|
8704
8740
|
const audited = [];
|
|
8741
|
+
const observedStrict = /* @__PURE__ */ new Map();
|
|
8705
8742
|
for (const branch of BRANCHES) {
|
|
8706
8743
|
try {
|
|
8707
8744
|
await octokit.repos.getBranch({ owner, repo, branch });
|
|
@@ -8713,6 +8750,7 @@ async function runBranchProtectionCheck(explicitRepo, options = {}) {
|
|
|
8713
8750
|
try {
|
|
8714
8751
|
const { data } = await octokit.repos.getBranchProtection({ owner, repo, branch });
|
|
8715
8752
|
findings.push(...auditBranch(branch, data));
|
|
8753
|
+
observedStrict.set(branch, data.required_status_checks?.strict ?? false);
|
|
8716
8754
|
} catch (err) {
|
|
8717
8755
|
if (err.status === 404) {
|
|
8718
8756
|
findings.push(...auditBranch(branch, null));
|
|
@@ -8745,12 +8783,22 @@ async function runBranchProtectionCheck(explicitRepo, options = {}) {
|
|
|
8745
8783
|
`);
|
|
8746
8784
|
console.log(formatPlans(plans));
|
|
8747
8785
|
let applied = 0;
|
|
8786
|
+
let preserved = 0;
|
|
8748
8787
|
for (const plan of plans.filter((p) => p.action === "apply")) {
|
|
8788
|
+
const existing = observedStrict.get(plan.branch);
|
|
8789
|
+
const strict = existing ?? true;
|
|
8790
|
+
if (existing === false) {
|
|
8791
|
+
preserved += 1;
|
|
8792
|
+
console.log(
|
|
8793
|
+
` ${plan.branch}: keeping strict=false \u2014 already set on this branch, so it is a
|
|
8794
|
+
decision rather than a gap. Change it deliberately with \`gh api\`, not here.`
|
|
8795
|
+
);
|
|
8796
|
+
}
|
|
8749
8797
|
await octokit.repos.updateBranchProtection({
|
|
8750
8798
|
owner,
|
|
8751
8799
|
repo,
|
|
8752
8800
|
branch: plan.branch,
|
|
8753
|
-
...protectionParamsFor(plan.contexts)
|
|
8801
|
+
...protectionParamsFor(plan.contexts, { strict })
|
|
8754
8802
|
});
|
|
8755
8803
|
applied += 1;
|
|
8756
8804
|
}
|
|
@@ -8760,8 +8808,10 @@ async function runBranchProtectionCheck(explicitRepo, options = {}) {
|
|
|
8760
8808
|
);
|
|
8761
8809
|
process.exit(1);
|
|
8762
8810
|
}
|
|
8763
|
-
console.log(
|
|
8764
|
-
|
|
8811
|
+
console.log(
|
|
8812
|
+
`
|
|
8813
|
+
\u2713 protection applied to ${applied} branch(es)` + (preserved > 0 ? `, ${preserved} keeping an existing strict=false` : "") + ". Re-run without --fix to verify."
|
|
8814
|
+
);
|
|
8765
8815
|
return;
|
|
8766
8816
|
}
|
|
8767
8817
|
if (findings.length > 0) {
|