Struct Repos

Source
pub struct Repos { /* private fields */ }
Expand description

The Repos struct provides methods for interacting with repositories.

Implementations§

Source§

impl Repos

Source

pub fn delete(&self) -> DeleteRepoBuilder

Deletes a repository by its owner and name. WARNING: This is irreversible and will delete all data associated with the repository. This action cannot be undone. When invoking this method, you will not be asked for confirmation. Use with caution, please don’t nuke your repositories.

§Example
let client = Client::new(
   "https://gitea.example.com",
   Auth::Token("your-token")
);
client
   .repos("owner", "repo")
   .delete()
   .send(&client)
   .await
   .unwrap();
Source

pub fn get(&self) -> GetRepoBuilder

Gets a repository by its owner and name. This will return a [Repository] object if the repository exists and is visible to the currently authenticated user.

§Example
let client = Client::new(
    "https://gitea.example.com",
    Auth::Token("your-token")
);
let repo = client
    .repos("owner", "repo")
    .get()
    .send(&client)
    .await
    .unwrap();
Source

pub fn create_fork(&self) -> CreateForkBuilder

Forks a repository by its owner and name. The [CreateForkOption] struct provides a number of optional fields to customize the fork, but all fields are entirely optional. If you don’t set any fields, the fork will be created with the same name as the original repository in the authenticated user’s account.

§Examples
let client = Client::new(
    "https://gitea.example.com",
    Auth::Token("your-token")
);
let forked_repo = client
    .repos("owner", "repo")
    .create_fork()
    .name("my-fork")
    .send(&client)
    .await
    .unwrap();

This will fork the repository “owner/repo” into the authenticated user’s account with the name “my-fork”.

let client = Client::new(
   "https://gitea.example.com",
   Auth::Token("your-token")
);
let forked_repo = client
   .repos("owner", "repo")
   .create_fork()
   .organization("my-org")
   .send(&client)
   .await
   .unwrap();

This will fork the repository “owner/repo” into the organization “my-org” with the same name as the original repository.

let client = Client::new(
   "https://gitea.example.com",
   Auth::Token("your-token")
);
let created_repo = client
  .user()
  .create_repo("my-new-repo")
  .send(&client)
  .await
  .unwrap();
let forked_repo = client
   .repos("owner", "my-new-repo")
   .create_fork()
   .name("my-new-repo")
   .send(&client)
   .await
   .expect_err("Repository with the same name should already exist for the current user");

This will create a new repository with the name “my-new-repo” for the authenticated user, then attempt to fork the repository “owner/repo” into the authenticated user’s account. The fork will fail because a repository with the same name already exists.

Source

pub fn edit(&self) -> EditRepoBuilder

Edits a repository by its owner and name.

If you don’t set any fields, the repository will not be modified.

§Example
let client = Client::new(
    "https://gitea.example.com",
     Auth::Token("your-token")
);
let repo = client
    .repos("owner", "repo")
    .edit()
    .description("A new description")
    .send(&client)
    .await
    .unwrap();

This will set the description of the repository “owner/repo” to “A new description”. If you want to remove the description, you can set it to an empty string.

Source

pub fn get_forks(&self) -> ListForksBuilder

Lists the forks of a repository by its owner and name.

Source

pub fn get_commits(&self) -> GetCommitsBuilder

Gets a list of commits for a repository. The [GetCommitsOption] struct provides a number of optional fields to filter the results, but all fields are entirely optional. If you don’t set any fields, you will get the most recent commits for the default branch.

§Example
let client = Client::new(
   "https://gitea.example.com",
   Auth::Token("your-token")
);
let commits = client
  .repos("owner", "repo")
  .get_commits()
  .send(&client)
  .await
  .unwrap();
Source

pub fn list_branches(&self) -> ListBranchesBuilder

Lists a repository’s branches.

§Example
let client = Client::new(
    "https://gitea.example.com",
    Auth::Token("your-token")
);
let branches = client
    .repos("owner", "repo")
    .list_branches()
    .send(&client)
    .await
    .unwrap();

This will list the branches for the repository “owner/repo”.

Source

pub fn create_branch( &self, new_branch_name: impl ToString, ) -> CreateBranchBuilder

Creates a new branch in a repository.

§Example
let client = Client::new(
    "https://gitea.example.com",
    Auth::Token("your-token")
);
client
    .repos("owner", "repo")
    .create_branch("new-branch")
    .old_ref_name("main")
    .send(&client)
    .await
    .unwrap();

This will create a new branch named “new-branch” in the repository “owner/repo” based on the “main” branch.

let client = Client::new(
    "https://gitea.example.com",
    Auth::Token("your-token")
);
client
    .repos("owner", "repo")
    .create_branch("new-branch")
    .send(&client)
    .await
    .unwrap();

This will create a new empty branch named “new-branch” in the repository “owner/repo”

Source

pub fn get_branch(&self, branch: impl ToString) -> GetBranchBuilder

Gets a branch in a repository. This will return a Branch object if the branch exists.

§Example
let client = Client::new(
    "https://gitea.example.com",
    Auth::Token("your-token")
);
let branch = client
    .repos("owner", "repo")
    .get_branch("main")
    .send(&client)
    .await
    .unwrap();

This will get the branch “main” in the repository “owner/repo”.

Source

pub fn delete_branch(&self, branch: impl ToString) -> DeleteBranchBuilder

Deletes a branch in a repository. WARNING: This is irreversible and will delete all data associated with the branch. This action cannot be undone. When invoking this method, you will not be asked for confirmation. Use with caution

§Example
let client = Client::new(
    "https://gitea.example.com",
    Auth::Token("your-token")
);
client
    .repos("owner", "repo")
    .delete_branch("branch-to-delete")
    .send(&client)
    .await
    .unwrap();

This will delete the branch “branch-to-delete” in the repository “owner/repo”.

Auto Trait Implementations§

§

impl Freeze for Repos

§

impl RefUnwindSafe for Repos

§

impl Send for Repos

§

impl Sync for Repos

§

impl Unpin for Repos

§

impl UnwindSafe for Repos

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> ErasedDestructor for T
where T: 'static,

Source§

impl<T> MaybeSendSync for T