ephemeris_forge_github/api/request/repository.rs
1use facet::Facet;
2
3use crate::{
4 MergeCommitMessage, MergeCommitTitle, PullRequestCreationPolicy, SquashMergeCommitMessage,
5 SquashMergeCommitTitle, Visibility,
6};
7
8/// The managed subset of GitHub's repository update body.
9///
10/// Every property is optional and an omitted property leaves the live value
11/// alone, so `Some(false)` is written and `None` is not.
12#[derive(Clone, Debug, Default, Eq, Facet, PartialEq)]
13#[facet(skip_all_unless_truthy)]
14pub struct RepositoryPatch {
15 /// The repository's slug.
16 pub name: Option<String>,
17 /// The one-line summary shown on the repository's landing page.
18 pub description: Option<String>,
19 /// The project home page.
20 pub homepage: Option<String>,
21 /// Who can see the repository.
22 pub visibility: Option<Visibility>,
23 /// Whether the issue tracker is enabled.
24 pub has_issues: Option<bool>,
25 /// Whether project boards are enabled.
26 pub has_projects: Option<bool>,
27 /// Whether the wiki is enabled.
28 pub has_wiki: Option<bool>,
29 /// Whether pull requests are enabled.
30 pub has_pull_requests: Option<bool>,
31 /// Whether discussions are enabled.
32 pub has_discussions: Option<bool>,
33 /// Who can open pull requests.
34 pub pull_request_creation_policy: Option<PullRequestCreationPolicy>,
35 /// Whether the repository is a template.
36 pub is_template: Option<bool>,
37 /// The default branch.
38 pub default_branch: Option<String>,
39 /// Whether merging is allowed to squash commits into one.
40 pub allow_squash_merge: Option<bool>,
41 /// Whether merging is allowed to create a merge commit.
42 pub allow_merge_commit: Option<bool>,
43 /// Whether merging is allowed to rebase commits onto the base branch.
44 pub allow_rebase_merge: Option<bool>,
45 /// Whether pull requests may merge automatically once checks pass.
46 pub allow_auto_merge: Option<bool>,
47 /// Whether the source branch is deleted automatically after merging.
48 pub delete_branch_on_merge: Option<bool>,
49 /// Whether a pull request branch may be updated from the base branch.
50 pub allow_update_branch: Option<bool>,
51 /// The title of a squash merge commit. Sent with the message.
52 pub squash_merge_commit_title: Option<SquashMergeCommitTitle>,
53 /// The message of a squash merge commit. Sent with the title.
54 pub squash_merge_commit_message: Option<SquashMergeCommitMessage>,
55 /// The title of a merge commit. Sent with the message.
56 pub merge_commit_title: Option<MergeCommitTitle>,
57 /// The message of a merge commit. Sent with the title.
58 pub merge_commit_message: Option<MergeCommitMessage>,
59 /// Whether the repository is archived.
60 pub archived: Option<bool>,
61 /// Whether private forks are allowed.
62 pub allow_forking: Option<bool>,
63 /// Whether web commits need a sign-off.
64 pub web_commit_signoff_required: Option<bool>,
65}
66
67impl RepositoryPatch {
68 /// Whether the body would carry no property at all.
69 #[must_use]
70 pub fn is_empty(&self) -> bool {
71 *self == Self::default()
72 }
73}
74
75/// The body that replaces a repository's topics.
76#[derive(Facet)]
77pub(crate) struct TopicsBody<'a> {
78 pub(crate) names: &'a [String],
79}