You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
r"This PR is based on an upstream commit that is {} days old.
31
-
32
-
*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).*",
33
-
days_old
34
-
));
35
-
}
36
-
Ok(None) => {
37
-
// Parent commit is not too old, log and do nothing
38
-
log::debug!("PR #{} parent commit is not too old", event.issue.number);
39
-
}
40
-
Err(e) => {
41
-
// Error checking parent commit age, log and do nothing
42
-
log::error!(
43
-
"Error checking parent commit age for PR #{}: {}",
44
-
event.issue.number,
45
-
e
46
-
);
47
-
}
48
-
}
49
-
50
-
None
51
-
}
52
-
53
-
/// Checks if the PR's parent commit is too old.
54
-
///
55
-
/// This determines if a PR needs updating by examining the first parent of the PR's head commit,
56
-
/// which typically represents the base branch commit that the PR is based on.
57
-
///
58
-
/// If this parent commit is older than the specified threshold, it suggests the PR
59
-
/// should be updated/rebased to a more recent version of the base branch.
60
-
///
61
-
/// Returns:
62
-
/// - Ok(Some(days_old)) - If parent commit is older than the threshold
63
-
/// - Ok(None)
64
-
/// - If there is no parent commit
65
-
/// - If parent is within threshold
66
-
/// - Err(...) - If an error occurred during processing
67
-
pub(super)asyncfnis_parent_commit_too_old(
68
-
commit:&GithubCommit,
69
-
repo:&Repository,
70
-
client:&GithubClient,
71
-
max_days_old:usize,
72
-
) -> anyhow::Result<Option<usize>>{
73
-
// Get the first parent (it should be from the base branch)
let days_old = commit_days_old(&parent_sha, repo, client).await?;
79
-
80
-
if days_old > max_days_old {
81
-
Ok(Some(days_old))
21
+
if days_old > age_threshold {
22
+
log::info!(
23
+
"PR #{} has a parent commit that is {} days old",
24
+
event.issue.number,
25
+
days_old
26
+
);
27
+
28
+
Some(format!(
29
+
r"This PR is based on an upstream commit that is {} days old.
30
+
31
+
*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
33
+
))
82
34
}else{
83
-
Ok(None)
35
+
// Parent commit is not too old, log and do nothing
36
+
log::debug!("PR #{} parent commit is not too old", event.issue.number);
37
+
None
84
38
}
85
39
}
86
-
87
-
/// Returns the number of days old the commit is
88
-
pub(super)asyncfncommit_days_old(
89
-
sha:&str,
90
-
repo:&Repository,
91
-
client:&GithubClient,
92
-
) -> anyhow::Result<usize>{
93
-
// Get the commit details to check its date
94
-
let commit:GithubCommit = repo.github_commit(client,&sha).await?;
95
-
96
-
// compute the number of days old the commit is
97
-
let commit_date = commit.commit.author.date;
98
-
let now = chrono::Utc::now().with_timezone(&commit_date.timezone());
99
-
let days_old = (now - commit_date).num_days()asusize;
0 commit comments