Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(release-plz#1487): updating PR on github closes it
Browse files Browse the repository at this point in the history
zvolin committed Jun 9, 2024
1 parent 268bd40 commit 55cdfd8
Showing 4 changed files with 18 additions and 3 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -34,6 +34,7 @@ once_cell = "1.19.0"
parse-changelog = { version = "0.6.8", default-features = false }
pretty_assertions = "1.4.0"
rayon = "1.10.0"
rand = "0.8.5"
regex = "1.10.4"
reqwest = "0.12.4"
reqwest-middleware = { version = "0.3.1", features = ["json"] }
1 change: 1 addition & 0 deletions crates/release_plz_core/Cargo.toml
Original file line number Diff line number Diff line change
@@ -33,6 +33,7 @@ git-url-parse.workspace = true
ignore.workspace = true
lazy_static.workspace = true
parse-changelog.workspace = true
rand.workspace = true
rayon.workspace = true
regex.workspace = true
# native-tls-alpn is needed for http2 support. https://doc.rust-lang.org/cargo/reference/registry-index.html#sparse-protocol
18 changes: 15 additions & 3 deletions crates/release_plz_core/src/command/release_pr.rs
Original file line number Diff line number Diff line change
@@ -311,9 +311,21 @@ async fn github_force_push(
pr: &GitPr,
repository: &Repo,
) -> anyhow::Result<()> {
// first force push the branch and then add new commit using gql api
repository.force_push(pr.branch())?;
github_graphql::commit_changes(client, repository, "chore: release", pr.branch()).await
// note: see https://github.com/MarcoIeni/release-plz/issues/1487
// Create a 'Verified' commit on temporary branch
let tmp_release_branch = format!("{}-tmp-{}", pr.branch(), rand::random::<u32>());
repository.checkout_new_branch(&tmp_release_branch)?;
github_create_release_branch(client, repository, &tmp_release_branch).await?;
// pull this commit
repository.git(&["pull", "--rebase"])?;
// rewrite the PR branch to point to the new commit
repository.force_push(&format!("{tmp_release_branch}:{}", pr.branch()))?;
// delete the temporary branch locally and in remote
repository.checkout(pr.branch())?;
repository.git(&["branch", "-D", tmp_release_branch.as_str()])?;
repository.push(&format!(":refs/heads/{tmp_release_branch}"))?;

Ok(())
}

fn create_release_branch(repository: &Repo, release_branch: &str) -> anyhow::Result<()> {

0 comments on commit 55cdfd8

Please sign in to comment.