Skip to content

Add upstream merge base commit link for [behind-upstream] #2009

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 24, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/github.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2847,6 +2847,7 @@ pub struct GithubCommit {
pub sha: String,
pub commit: GithubCommitCommitField,
pub parents: Vec<Parent>,
pub html_url: String,
}

#[derive(Debug, serde::Deserialize)]
Expand Down
1 change: 1 addition & 0 deletions src/handlers/check_commits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,7 @@ fn dummy_commit_from_body(sha: &str, body: &str) -> GithubCommit {
},
},
parents: vec![],
html_url: "".to_owned(),
}
}

Expand Down
5 changes: 3 additions & 2 deletions src/handlers/check_commits/behind_upstream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ pub(super) async fn behind_upstream(
let now = chrono::Utc::now().with_timezone(&commit_date.timezone());
let days_old = (now - commit_date).num_days() as usize;

let upstream_commit_url = &compare.merge_base_commit.html_url;

// First try the parent commit age check as it's more accurate
if days_old > age_threshold {
log::info!(
Expand All @@ -26,10 +28,9 @@ pub(super) async fn behind_upstream(
);

Some(format!(
r"This PR is based on an upstream commit that is {} days old.
r"This PR is based on an [upstream commit]({upstream_commit_url}) that is {days_old} days old.

*It's recommended to update your branch according to the [rustc-dev-guide](https://rustc-dev-guide.rust-lang.org/contributing.html#keeping-your-branch-up-to-date).*",
days_old
))
} else {
// Parent commit is not too old, log and do nothing
Expand Down
Loading