Skip to content

Commit

Permalink
Merge pull request #1710 from ehuss/docs-force-update
Browse files Browse the repository at this point in the history
Fix docs-update creating merge commits
  • Loading branch information
Mark-Simulacrum authored Jul 31, 2023
2 parents 82073e7 + 3878a49 commit 5df6772
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions src/handlers/docs_update.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,19 +64,17 @@ pub async fn handle_job() -> Result<()> {

pub async fn docs_update() -> Result<Option<Issue>> {
let gh = GithubClient::new_with_default_token(Client::new());
let dest_repo = gh.repository(DEST_REPO).await?;
let work_repo = gh.repository(WORK_REPO).await?;
work_repo
.merge_upstream(&gh, &work_repo.default_branch)
.await?;

let updates = get_submodule_updates(&gh, &work_repo).await?;
if updates.is_empty() {
tracing::trace!("no updates this week?");
return Ok(None);
}

create_commit(&gh, &work_repo, &updates).await?;
Ok(Some(create_pr(&gh, &updates).await?))
create_commit(&gh, &dest_repo, &work_repo, &updates).await?;
Ok(Some(create_pr(&gh, &dest_repo, &updates).await?))
}

struct Update {
Expand Down Expand Up @@ -158,11 +156,12 @@ async fn generate_pr_body(

async fn create_commit(
gh: &GithubClient,
dest_repo: &Repository,
rust_repo: &Repository,
updates: &[Update],
) -> Result<()> {
let master_ref = rust_repo
.get_reference(gh, &format!("heads/{}", rust_repo.default_branch))
let master_ref = dest_repo
.get_reference(gh, &format!("heads/{}", dest_repo.default_branch))
.await?;
let master_commit = rust_repo.git_commit(gh, &master_ref.object.sha).await?;
let tree_entries: Vec<_> = updates
Expand All @@ -186,8 +185,7 @@ async fn create_commit(
Ok(())
}

async fn create_pr(gh: &GithubClient, updates: &[Update]) -> Result<Issue> {
let dest_repo = gh.repository(DEST_REPO).await?;
async fn create_pr(gh: &GithubClient, dest_repo: &Repository, updates: &[Update]) -> Result<Issue> {
let mut body = String::new();
for update in updates {
write!(body, "{}\n", update.pr_body).unwrap();
Expand Down

0 comments on commit 5df6772

Please sign in to comment.