pub struct Repos { /* private fields */ }
Expand description
The Repos struct provides methods for interacting with repositories.
Implementations§
source§impl Repos
impl Repos
sourcepub fn delete(&self) -> DeleteRepoBuilder
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();
sourcepub fn get(&self) -> GetRepoBuilder
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();
sourcepub fn create_fork(&self) -> CreateForkBuilder
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.
sourcepub fn edit(&self) -> EditRepoBuilder
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.
sourcepub fn get_forks(&self) -> ListForksBuilder
pub fn get_forks(&self) -> ListForksBuilder
Lists the forks of a repository by its owner and name.
sourcepub fn get_commits(&self) -> GetCommitsBuilder
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();