@@ -13,7 +13,7 @@ use rust_project_goals::{
1313 gh:: {
1414 issue_id:: { IssueId , Repository } ,
1515 issues:: {
16- change_milestone, create_comment, create_issue, fetch_issue, list_issues_in_milestone, lock_issue, sync_assignees, FLAGSHIP_LABEL , LOCK_TEXT
16+ change_milestone, create_comment, create_issue, fetch_issue, list_issues_in_milestone, lock_issue, sync_assignees, update_issue_body , FLAGSHIP_LABEL , LOCK_TEXT
1717 } ,
1818 labels:: GhLabel ,
1919 } ,
@@ -209,6 +209,11 @@ enum GithubAction<'doc> {
209209 body : String ,
210210 } ,
211211
212+ UpdateIssueBody {
213+ number : u64 ,
214+ body : String ,
215+ } ,
216+
212217 // We intentionally do not sync the issue *text*, because it may have been edited.
213218 SyncAssignees {
214219 number : u64 ,
@@ -290,8 +295,14 @@ fn initialize_issues<'doc>(
290295 //
291296 let existing_issue = if let Some ( tracking_issue) = desired_issue. tracking_issue {
292297 // a. We first check if there is a declared tracking issue in the markdown file.
293- // If so, then we just load its information from the repository by number.
294- Some ( fetch_issue ( repository, tracking_issue. number ) ?)
298+ // If so, check if we've already loaded its data.
299+ if let Some ( issue) = milestone_issues. iter ( ) . find ( |issue| issue. number == tracking_issue. number ) {
300+ // If so, reuse it to avoid latency.
301+ Some ( issue. clone ( ) )
302+ } else {
303+ // If not, load its information from the repository by number.
304+ Some ( fetch_issue ( repository, tracking_issue. number ) ?)
305+ }
295306 } else {
296307 // b. If the markdown does not have a declared tracking issue, then we can search through
297308 // the issues in the milestone for one with the correct title.
@@ -348,6 +359,14 @@ fn initialize_issues<'doc>(
348359 } ) ;
349360 }
350361
362+ let link_text = goal_document_link ( timeframe, & desired_issue. goal_document ) ;
363+ if !existing_issue. body . contains ( & link_text) {
364+ actions. insert ( GithubAction :: UpdateIssueBody {
365+ number : existing_issue. number ,
366+ body : desired_issue. body ,
367+ } ) ;
368+ }
369+
351370 let issue_id = IssueId :: new ( repository. clone ( ) , existing_issue. number ) ;
352371 if desired_issue. tracking_issue != Some ( & issue_id) {
353372 actions. insert ( GithubAction :: LinkToTrackingIssue {
@@ -394,6 +413,11 @@ fn issue<'doc>(timeframe: &str, document: &'doc GoalDocument) -> anyhow::Result<
394413 } )
395414}
396415
416+ fn goal_document_link ( timeframe : & str , document : & GoalDocument ) -> String {
417+ let goal_file = document. link_path . file_stem ( ) . unwrap ( ) . to_str ( ) . unwrap ( ) ;
418+ format ! ( "[{timeframe}/{goal_file}](https://rust-lang.github.io/rust-project-goals/{timeframe}/{goal_file}.html)" )
419+ }
420+
397421fn issue_text ( timeframe : & str , document : & GoalDocument ) -> anyhow:: Result < String > {
398422 let mut tasks = vec ! [ ] ;
399423 for goal_plan in & document. goal_plans {
@@ -406,15 +430,13 @@ fn issue_text(timeframe: &str, document: &GoalDocument) -> anyhow::Result<String
406430 . map ( |team| team. name_and_link ( ) )
407431 . collect :: < Vec < _ > > ( ) ;
408432
409- let goal_file = document. link_path . file_stem ( ) . unwrap ( ) . to_str ( ) . unwrap ( ) ;
410-
411433 Ok ( format ! (
412434 r##"
413435| Metadata | |
414436| -------- | --- |
415437| Point of contact | {poc} |
416438| Team(s) | {teams} |
417- | Goal document | [{timeframe}/{goal_file}](https://rust-lang.github.io/rust-project-goals/{timeframe}/{goal_file}.html) |
439+ | Goal document | {goaldocument} |
418440
419441## Summary
420442
@@ -430,6 +452,7 @@ fn issue_text(timeframe: &str, document: &GoalDocument) -> anyhow::Result<String
430452 teams = teams. join( ", " ) ,
431453 summary = document. summary,
432454 tasks = tasks. join( "\n " ) ,
455+ goaldocument = goal_document_link( timeframe, document) ,
433456 ) )
434457}
435458
@@ -495,6 +518,9 @@ impl Display for GithubAction<'_> {
495518 GithubAction :: Comment { number, body } => {
496519 write ! ( f, "post comment on issue #{}: \" {}\" " , number, body)
497520 }
521+ GithubAction :: UpdateIssueBody { number, body : _ } => {
522+ write ! ( f, "update the body on issue #{} for new milestone" , number)
523+ }
498524 GithubAction :: SyncAssignees {
499525 number,
500526 remove_owners,
@@ -565,6 +591,11 @@ impl GithubAction<'_> {
565591 Ok ( ( ) )
566592 }
567593
594+ GithubAction :: UpdateIssueBody { number, body } => {
595+ update_issue_body ( repository, number, & body) ?;
596+ Ok ( ( ) )
597+ }
598+
568599 GithubAction :: SyncAssignees {
569600 number,
570601 remove_owners,
0 commit comments