feat: implement CreateRepoOptions

This commit is contained in:
aviac 2023-09-22 20:36:26 +02:00
parent 030de8f9f8
commit b5d57249fa
No known key found for this signature in database
GPG key ID: 644781002BDEA982
6 changed files with 64 additions and 42 deletions

2
Cargo.lock generated
View file

@ -224,7 +224,7 @@ checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1"
[[package]]
name = "forgejo-api-types"
version = "0.1.0"
version = "0.1.2"
dependencies = [
"chrono",
"clap",

View file

@ -1,6 +1,6 @@
[package]
name = "forgejo-api-types"
version = "0.1.1"
version = "0.1.2"
edition = "2021"
license = "AGPL-3.0-or-later"
keywords = ["forgejo", "types", "codeberg", "api"]

View file

@ -1,39 +1,32 @@
//CreateRepoOption{
//description:
//CreateRepoOption options when creating repository
//
//auto_init boolean
//Whether the repository should be auto-initialized?
//
//default_branch string
//DefaultBranch of the repository (used when initializes and in template)
//
//description string
//Description of the repository to create
//
//gitignores string
//Gitignores to use
//
//issue_labels string
//Label-Set to use
//
//license string
//License to use
//
//name* string
//uniqueItems: true
//Name of the repository to create
//
//private boolean
//Whether the repository is private
//
//readme [...]
//template boolean
//Whether the repository is template
//
//trust_model string
//TrustModel of the repository
//
//Enum:
//[ default, collaborator, committer, collaboratorcommitter ]
//}
use serde::{Deserialize, Serialize};
use crate::types::misc::boolean_enums::auto_init::AutoInit;
use crate::types::misc::boolean_enums::is::private::IsPrivate;
use crate::types::misc::boolean_enums::is::template::IsTemplate;
use crate::types::misc::trust_model::TrustModel;
/// CreateRepoOption represents options when creating a repository.
#[derive(Debug, Serialize, Deserialize)]
pub struct CreateRepoOption {
/// Whether the repository should be auto-initialized.
pub auto_init: AutoInit,
/// Default branch of the repository (used when initializes and in template).
pub default_branch: String,
/// Description of the repository to create.
pub description: String,
/// Gitignores to use.
pub gitignores: String,
/// Label-Set to use.
// 🚧🚧 TODO 🚧🚧 : Do better than comma separated list of names
pub issue_labels: String,
/// License to use.
pub license: String,
/// Name of the repository to create.
pub name: String,
/// Whether the repository is private.
pub private: IsPrivate,
/// Whether the repository is a template.
pub template: IsTemplate,
/// TrustModel of the repository.
pub trust_model: TrustModel,
}

View file

@ -10,3 +10,4 @@ implement_boolean_enum!(delete_branch_after_merge, DeleteBranchAfterMerge);
implement_boolean_enum!(ignore_whitespace_conflicts, IgnoreWhitespaceConflicts);
implement_boolean_enum!(includes_all_repositories, IncludesAllRepositories);
implement_boolean_enum!(prohibit_login, ProhibitLogin);
implement_boolean_enum!(auto_init, AutoInit);

View file

@ -1,4 +1,4 @@
/// bools suck muhahahahaha
/// bools suck muhahahahaha 😈
pub mod boolean_enums;
pub mod color;
pub mod external_issue_format;
@ -8,4 +8,5 @@ pub mod optional_url;
pub mod permission;
pub mod sshurl;
pub mod team_permissions;
pub mod trust_model;
pub mod visibility;

View file

@ -0,0 +1,27 @@
use clap::ValueEnum;
use serde::{Deserialize, Serialize};
use strum::{Display, EnumIs, EnumIter, EnumString};
/// TrustModel represents the trust model of the repository.
#[derive(
Debug,
Clone,
Copy,
PartialEq,
Eq,
ValueEnum,
Display,
EnumIter,
EnumString,
EnumIs,
Serialize,
Deserialize,
)]
#[strum(serialize_all = "lowercase")]
#[serde(rename_all = "lowercase")]
pub enum TrustModel {
Default,
Collaborator,
Committer,
CollaboratorCommitter,
}