@@ -13,7 +13,7 @@ use rust_project_goals::{
13
13
gh:: {
14
14
issue_id:: { IssueId , Repository } ,
15
15
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
17
17
} ,
18
18
labels:: GhLabel ,
19
19
} ,
@@ -209,6 +209,11 @@ enum GithubAction<'doc> {
209
209
body : String ,
210
210
} ,
211
211
212
+ UpdateIssueBody {
213
+ number : u64 ,
214
+ body : String ,
215
+ } ,
216
+
212
217
// We intentionally do not sync the issue *text*, because it may have been edited.
213
218
SyncAssignees {
214
219
number : u64 ,
@@ -348,6 +353,14 @@ fn initialize_issues<'doc>(
348
353
} ) ;
349
354
}
350
355
356
+ let link_text = goal_document_link ( timeframe, & desired_issue. goal_document ) ;
357
+ if !existing_issue. body . contains ( & link_text) {
358
+ actions. insert ( GithubAction :: UpdateIssueBody {
359
+ number : existing_issue. number ,
360
+ body : existing_issue. body ,
361
+ } ) ;
362
+ }
363
+
351
364
let issue_id = IssueId :: new ( repository. clone ( ) , existing_issue. number ) ;
352
365
if desired_issue. tracking_issue != Some ( & issue_id) {
353
366
actions. insert ( GithubAction :: LinkToTrackingIssue {
@@ -394,6 +407,11 @@ fn issue<'doc>(timeframe: &str, document: &'doc GoalDocument) -> anyhow::Result<
394
407
} )
395
408
}
396
409
410
+ fn goal_document_link ( timeframe : & str , document : & GoalDocument ) -> String {
411
+ let goal_file = document. link_path . file_stem ( ) . unwrap ( ) . to_str ( ) . unwrap ( ) ;
412
+ format ! ( "[{timeframe}/{goal_file}](https://rust-lang.github.io/rust-project-goals/{timeframe}/{goal_file}.html)" )
413
+ }
414
+
397
415
fn issue_text ( timeframe : & str , document : & GoalDocument ) -> anyhow:: Result < String > {
398
416
let mut tasks = vec ! [ ] ;
399
417
for goal_plan in & document. goal_plans {
@@ -406,15 +424,13 @@ fn issue_text(timeframe: &str, document: &GoalDocument) -> anyhow::Result<String
406
424
. map ( |team| team. name_and_link ( ) )
407
425
. collect :: < Vec < _ > > ( ) ;
408
426
409
- let goal_file = document. link_path . file_stem ( ) . unwrap ( ) . to_str ( ) . unwrap ( ) ;
410
-
411
427
Ok ( format ! (
412
428
r##"
413
429
| Metadata | |
414
430
| -------- | --- |
415
431
| Point of contact | {poc} |
416
432
| Team(s) | {teams} |
417
- | Goal document | [{timeframe}/{goal_file}](https://rust-lang.github.io/rust-project-goals/{timeframe}/{goal_file}.html) |
433
+ | Goal document | {goaldocument} |
418
434
419
435
## Summary
420
436
@@ -430,6 +446,7 @@ fn issue_text(timeframe: &str, document: &GoalDocument) -> anyhow::Result<String
430
446
teams = teams. join( ", " ) ,
431
447
summary = document. summary,
432
448
tasks = tasks. join( "\n " ) ,
449
+ goaldocument = goal_document_link( timeframe, document) ,
433
450
) )
434
451
}
435
452
@@ -495,6 +512,9 @@ impl Display for GithubAction<'_> {
495
512
GithubAction :: Comment { number, body } => {
496
513
write ! ( f, "post comment on issue #{}: \" {}\" " , number, body)
497
514
}
515
+ GithubAction :: UpdateIssueBody { number, body : _ } => {
516
+ write ! ( f, "update the body on issue #{} for new milestone" , number)
517
+ }
498
518
GithubAction :: SyncAssignees {
499
519
number,
500
520
remove_owners,
@@ -565,6 +585,11 @@ impl GithubAction<'_> {
565
585
Ok ( ( ) )
566
586
}
567
587
588
+ GithubAction :: UpdateIssueBody { number, body } => {
589
+ update_issue_body ( repository, number, & body) ?;
590
+ Ok ( ( ) )
591
+ }
592
+
568
593
GithubAction :: SyncAssignees {
569
594
number,
570
595
remove_owners,
0 commit comments