Compare changes
Choose two branches to see what one has that the other does not, then open a pull request for it.
2 commits
2 files+24−50/2 viewed
| 114 | 114 | return (false, BTreeMap::new()); | |
| 115 | 115 | } | |
| 116 | 116 | let target = sha.clone().unwrap_or_else(|| "FETCH_HEAD".into()); | |
| 117 | − | // The commit may be further back than a shallow fetch reaches. | |
| 118 | − | let present = Command::new("git").current_dir(&path).args(["cat-file", "-e", &format!("{target}^{{commit}}")]).status().is_ok_and(|s| s.success()); | |
| 119 | − | if !present && !self.fetch_retrying(&path, &["fetch", "--no-tags", "--quiet", "origin"], auth.as_deref()) { | |
| 120 | − | return (false, BTreeMap::new()); | |
| 117 | + | // The commit may be further back than a shallow fetch reaches: the | |
| 118 | + | // branch moved on after the run began, say. Ask for the commit | |
| 119 | + | // itself, and failing that the whole history; a plain fetch never | |
| 120 | + | // reaches past a shallow boundary. | |
| 121 | + | let has = |target: &str| Command::new("git").current_dir(&path).args(["cat-file", "-e", &format!("{target}^{{commit}}")]).status().is_ok_and(|s| s.success()); | |
| 122 | + | if !has(&target) { | |
| 123 | + | let by_sha = sha.as_deref().is_some_and(|sha| { | |
| 124 | + | let mut args = vec!["fetch", "--no-tags", "--quiet"]; | |
| 125 | + | if depth > 0 { | |
| 126 | + | args.push(&depth_arg); | |
| 127 | + | } | |
| 128 | + | args.extend(["origin", sha]); | |
| 129 | + | self.git(&path, &args, auth.as_deref()) && has(sha) | |
| 130 | + | }); | |
| 131 | + | let shallow = path.join(".git").join("shallow").exists(); | |
| 132 | + | let deepen: &[&str] = if shallow { &["fetch", "--no-tags", "--quiet", "--unshallow", "origin"] } else { &["fetch", "--no-tags", "--quiet", "origin"] }; | |
| 133 | + | if !by_sha && !self.fetch_retrying(&path, deepen, auth.as_deref()) { | |
| 134 | + | return (false, BTreeMap::new()); | |
| 135 | + | } | |
| 121 | 136 | } | |
| 122 | 137 | let checked_out = match &branch { | |
| 123 | 138 | Some(branch) => self.git(&path, &["checkout", "--quiet", "--force", "-B", branch, &target], None), |
| 124 | 124 | const include = jobs.length ? jobs : [{ group: "none", units: "" }]; | |
| 125 | 125 | lines.push(`has_${stage}=${jobs.length > 0}`, `${stage}=${JSON.stringify({ include })}`); | |
| 126 | 126 | } | |
| 127 | − | if (data.migration_errors.length) throw new Error(`Could not read pending migrations: ${data.migration_errors.map((e) => e.unit).join(", ")}`); | |
| 127 | + | if (data.migration_errors.length) { | |
| 128 | + | // The units, then why for the first: one cause (a token, say) is usually all of them. | |
| 129 | + | throw new Error(`Could not read pending migrations: ${data.migration_errors.map((e) => e.unit).join(", ")} | |
| 130 | + | ${data.migration_errors[0].error}`); | |
| 131 | + | } | |
| 128 | 132 | if (process.env.GITHUB_OUTPUT) appendFileSync(process.env.GITHUB_OUTPUT, `${lines.join("\n")}\n`); | |
| 129 | 133 | else console.log(lines.join("\n")); | |
| 130 | 134 | if (process.env.GITHUB_STEP_SUMMARY) { |