diff options
| author | DanConwayDev <DanConwayDev@protonmail.com> | 2024-02-16 22:53:25 +0000 |
|---|---|---|
| committer | DanConwayDev <DanConwayDev@protonmail.com> | 2024-02-16 22:53:25 +0000 |
| commit | 700328779d8982b42f59c5919605fa379c7248ef (patch) | |
| tree | a8c6a76eaf2557af741e2ab30cae9a37be45580d /src/sub_commands/send.rs | |
| parent | 701668b02d999af42f51d8bd25fffb2a8692c3c8 (diff) | |
refactor: added code comments
to reflect the requirement for certain tags
Diffstat (limited to 'src/sub_commands/send.rs')
| -rw-r--r-- | src/sub_commands/send.rs | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/src/sub_commands/send.rs b/src/sub_commands/send.rs index 3a9da4b..ac1d182 100644 --- a/src/sub_commands/send.rs +++ b/src/sub_commands/send.rs | |||
| @@ -405,6 +405,10 @@ pub fn generate_cover_letter_and_patch_events( | |||
| 405 | Tag::Hashtag("cover-letter".to_string()), | 405 | Tag::Hashtag("cover-letter".to_string()), |
| 406 | Tag::Hashtag("root".to_string()), | 406 | Tag::Hashtag("root".to_string()), |
| 407 | ], | 407 | ], |
| 408 | // this is not strictly needed but makes for prettier branch names | ||
| 409 | // eventually a prefix will be needed of the event id to stop 2 proposals with the same name colliding | ||
| 410 | // a change like this, or the removal of this tag will require the actual branch name to be tracked | ||
| 411 | // so pulling and pushing still work | ||
| 408 | if let Ok(branch_name) = git_repo.get_checked_out_branch_name() { | 412 | if let Ok(branch_name) = git_repo.get_checked_out_branch_name() { |
| 409 | vec![Tag::Generic( | 413 | vec![Tag::Generic( |
| 410 | TagKind::Custom("branch-name".to_string()), | 414 | TagKind::Custom("branch-name".to_string()), |
| @@ -584,6 +588,7 @@ pub fn generate_patch_event( | |||
| 584 | } else { | 588 | } else { |
| 585 | vec![] | 589 | vec![] |
| 586 | }, | 590 | }, |
| 591 | // see comment on branch names in cover letter event creation | ||
| 587 | if let Some(branch_name) = branch_name { | 592 | if let Some(branch_name) = branch_name { |
| 588 | if thread_event_id.is_none() { | 593 | if thread_event_id.is_none() { |
| 589 | vec![ | 594 | vec![ |
| @@ -607,14 +612,17 @@ pub fn generate_patch_event( | |||
| 607 | .map(|pk| Tag::public_key(*pk)) | 612 | .map(|pk| Tag::public_key(*pk)) |
| 608 | .collect(), | 613 | .collect(), |
| 609 | vec![ | 614 | vec![ |
| 615 | // a fallback is now in place to extract this from the patch | ||
| 610 | Tag::Generic( | 616 | Tag::Generic( |
| 611 | TagKind::Custom("commit".to_string()), | 617 | TagKind::Custom("commit".to_string()), |
| 612 | vec![commit.to_string()], | 618 | vec![commit.to_string()], |
| 613 | ), | 619 | ), |
| 620 | // this is required as patches cannot be relied upon to include the 'base commit' | ||
| 614 | Tag::Generic( | 621 | Tag::Generic( |
| 615 | TagKind::Custom("parent-commit".to_string()), | 622 | TagKind::Custom("parent-commit".to_string()), |
| 616 | vec![commit_parent.to_string()], | 623 | vec![commit_parent.to_string()], |
| 617 | ), | 624 | ), |
| 625 | // this is required to ensure the commit id matches | ||
| 618 | Tag::Generic( | 626 | Tag::Generic( |
| 619 | TagKind::Custom("commit-pgp-sig".to_string()), | 627 | TagKind::Custom("commit-pgp-sig".to_string()), |
| 620 | vec![ | 628 | vec![ |
| @@ -623,11 +631,13 @@ pub fn generate_patch_event( | |||
| 623 | .unwrap_or_default(), | 631 | .unwrap_or_default(), |
| 624 | ], | 632 | ], |
| 625 | ), | 633 | ), |
| 634 | // removing description tag will not cause anything to break | ||
| 626 | Tag::Description(git_repo.get_commit_message(commit)?.to_string()), | 635 | Tag::Description(git_repo.get_commit_message(commit)?.to_string()), |
| 627 | Tag::Generic( | 636 | Tag::Generic( |
| 628 | TagKind::Custom("author".to_string()), | 637 | TagKind::Custom("author".to_string()), |
| 629 | git_repo.get_commit_author(commit)?, | 638 | git_repo.get_commit_author(commit)?, |
| 630 | ), | 639 | ), |
| 640 | // this is required to ensure the commit id matches | ||
| 631 | Tag::Generic( | 641 | Tag::Generic( |
| 632 | TagKind::Custom("committer".to_string()), | 642 | TagKind::Custom("committer".to_string()), |
| 633 | git_repo.get_commit_comitter(commit)?, | 643 | git_repo.get_commit_comitter(commit)?, |