Skip to content

Commit 7358b55

Browse files
authored
Merge pull request #2009 from xizheyin/fix-behind-upstream
Add upstream merge base commit link for `[behind-upstream]`
2 parents c335263 + 5e2e936 commit 7358b55

File tree

3 files changed

+5
-2
lines changed

3 files changed

+5
-2
lines changed

src/github.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2847,6 +2847,7 @@ pub struct GithubCommit {
28472847
pub sha: String,
28482848
pub commit: GithubCommitCommitField,
28492849
pub parents: Vec<Parent>,
2850+
pub html_url: String,
28502851
}
28512852

28522853
#[derive(Debug, serde::Deserialize)]

src/handlers/check_commits.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,7 @@ fn dummy_commit_from_body(sha: &str, body: &str) -> GithubCommit {
246246
},
247247
},
248248
parents: vec![],
249+
html_url: "".to_owned(),
249250
}
250251
}
251252

src/handlers/check_commits/behind_upstream.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ pub(super) async fn behind_upstream(
1717
let now = chrono::Utc::now().with_timezone(&commit_date.timezone());
1818
let days_old = (now - commit_date).num_days() as usize;
1919

20+
let upstream_commit_url = &compare.merge_base_commit.html_url;
21+
2022
// First try the parent commit age check as it's more accurate
2123
if days_old > age_threshold {
2224
log::info!(
@@ -26,10 +28,9 @@ pub(super) async fn behind_upstream(
2628
);
2729

2830
Some(format!(
29-
r"This PR is based on an upstream commit that is {} days old.
31+
r"This PR is based on an [upstream commit]({upstream_commit_url}) that is {days_old} days old.
3032
3133
*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).*",
32-
days_old
3334
))
3435
} else {
3536
// Parent commit is not too old, log and do nothing

0 commit comments

Comments
 (0)