pub struct RepoHandler<'octo> { }
Expand description Source§ Source
List forks of a repository. Optionally, specify the sort order, page, and items per_page
use octocrab::params::repos::forks::Sort;
let forks = octocrab::instance()
.repos("owner", "repo")
.list_forks()
.sort(Sort::Oldest)
.page(2u32)
.per_page(30)
.send()
.await?;
Source
Creates a fork of a repository. Optionally, specify the target organization or name to create the fork in, or default_branch_only to fork with only the default branch.
let new_fork = octocrab::instance()
.repos("owner", "repo")
.create_fork()
.organization("weyland-yutani")
.name("new-repo-name")
.default_branch_only(true)
.send()
.await?;
Source§ Source
Get’s a repository’s license.
let license = octocrab::instance().repos("owner", "repo").license().await?;
Source
Get’s a repository’s public key.
let public_key = octocrab::instance().repos("owner", "repo").public_key().await?;
Source
Fetches a single repository.
let repo = octocrab::instance()
.repos("owner", "repo")
.get()
.await?;
Fetches a repository’s metrics.
let repo = octocrab::instance()
.repos("owner", "repo")
.get_community_profile_metrics()
.await?;
Source
Fetches a single reference in the Git database.
use octocrab::params::repos::Reference;
let master = octocrab::instance()
.repos("owner", "repo")
.get_ref(&Reference::Branch("master".to_string()))
.await?;
Source
Fetches information about a git tag with the given tag_sha
.
use octocrab::params::repos::Reference;
let master = octocrab::instance()
.repos("owner", "repo")
.get_tag("402b2026a41b26b691c429ddb0b9c27a31b27a6b")
.await?;
Source
Creates a new reference for the repository.
use octocrab::params::repos::Reference;
octocrab::instance()
.repos("owner", "repo")
.create_ref(&Reference::Tag("1.0".to_string()), master_sha)
.await?;
Source
Deletes an existing reference from the repository.
use octocrab::params::repos::Reference;
octocrab::instance()
.repos("owner", "repo")
.delete_ref(&Reference::Branch("temporary-branch".to_string()))
.await?;
Source
Get repository content.
octocrab::instance()
.repos("owner", "repo")
.get_content()
.path("path/to/file")
.r#ref("main")
.send()
.await?;
Source
Get repository readme.
octocrab::instance()
.repos("owner", "repo")
.get_readme()
.path("path/to/file")
.r#ref("main")
.send()
.await?;
Source
Creates a new file in the repository.
use octocrab::models::repos::CommitAuthor;
octocrab::instance()
.repos("owner", "repo")
.create_file(
"crabs/ferris.txt",
"Created ferris.txt",
"Thought there’d never be a Rust Rap?\n"
)
.branch("master")
.commiter(CommitAuthor {
name: "Octocat".to_string(),
email: "octocat@github.com".to_string(),
date: None,
})
.author(CommitAuthor {
name: "Ferris".to_string(),
email: "ferris@rust-lang.org".to_string(),
date: None,
})
.send()
.await?;
Source
Update an existing file.
path
: the path of the updated file.message
: the message of the commit used to update the filecontent
: the updated contents of the file (base64 encoding is done automatically).sha
: the blob SHA of the file being updated. This can be obtained using the RepoHandler::get_content function.use octocrab::models::repos::CommitAuthor;
octocrab::instance()
.repos("owner", "repo")
.update_file(
"crabs/ferris.txt",
"Updated ferris.txt",
"But me and Ferris Crab: best friends to the end.\n",
blob_sha
)
.branch("master")
.commiter(CommitAuthor {
name: "Octocat".to_string(),
email: "octocat@github.com".to_string(),
date: None,
})
.author(CommitAuthor {
name: "Ferris".to_string(),
email: "ferris@rust-lang.org".to_string(),
date: None,
})
.send()
.await?;
Source
Deletes a file in the repository.
use octocrab::models::repos::CommitAuthor;
octocrab::instance()
.repos("owner", "repo")
.delete_file(
"crabs/ferris.txt",
"Deleted ferris.txt",
blob_sha
)
.branch("master")
.commiter(CommitAuthor {
name: "Octocat".to_string(),
email: "octocat@github.com".to_string(),
date: None,
})
.author(CommitAuthor {
name: "Ferris".to_string(),
email: "ferris@rust-lang.org".to_string(),
date: None,
})
.send()
.await?;
Source
List tags from a repository.
let tags = octocrab::instance().repos("owner", "repo").list_tags().send().await?;
Source
List branches from a repository.
let branches = octocrab::instance()
.repos("owner", "repo")
.list_branches()
.send()
.await?;
Source
List commits from a repository
let commits = octocrab::instance().repos("owner", "repo").list_commits().send().await?;
Source
List teams from a repository.
let teams = octocrab::instance().repos("owner", "repo").list_teams().send().await?;
Source
List collaborators from a repository.
let collaborators = octocrab::instance().repos("owner", "repo").list_collaborators().send().await?;
Source
List contributors from a repository.
let contributors = octocrab::instance().repos("owner", "repo").list_contributors().send().await?;
Source
List star_gazers from a repository.
let stargazers = octocrab::instance().repos("owner", "repo").list_stargazers().send().await?;
Source
Lists languages for the specified repository. The value shown for each language is the number of bytes of code written in that language.
let languages = octocrab::instance()
.repos("owner", "repo")
.list_languages()
.await?;
Source
Creates a ReleaseAssetsHandler
for the specified repository.
Creates a ReleasesHandler
for the specified repository.
Create a status for a specified commit in the specified repository.
SourceList statuses for a reference.
SourceList pull requests for a reference.
SourceList events on this repository.
Takes an optional etag which allows for efficient polling. Here is a quick example to poll a repositories events.
let mut etag = None;
loop {
let response: Etagged<Page<Event>> = octocrab::instance()
.repos("owner", "repo")
.events()
.etag(etag)
.send()
.await?;
if let Some(page) = response.value {
} else {
println!("No new data received, trying again soon");
}
etag = response.etag;
}
Source
Creates a new webhook for the specified repository.
§NotesOnly authorized users or apps can modify repository webhooks.
§Examplesuse octocrab::models::hooks::{Hook, Config as HookConfig, ContentType as HookContentType};
let config = HookConfig {
url: "https://example.com".to_string(),
content_type: Some(HookContentType::Json),
insecure_ssl: None,
secret: None
};
let hook = Hook {
name: "web".to_string(),
config,
..Hook::default()
};
let hook = octocrab.repos("owner", "repo").create_hook(hook).await?;
Source
Gets the combined status for the specified reference.
use octocrab::params::repos::Reference;
let master = octocrab::instance()
.repos("owner", "repo")
.combined_status_for_ref(&Reference::Branch("main".to_string()))
.await?;
Source
Creates a new repository from repository if it is a template.
async fn run() -> octocrab::Result<()> {
octocrab::instance()
.repos("owner", "repo")
.generate("rust")
.owner("new_owner")
.description("Description")
.include_all_branches(true)
.private(true)
.send()
.await
Source
Retrieve the contents of a file in raw format
SourceDeletes this repository.
octocrab::instance().repos("owner", "repo").delete().await
Source
Stream the repository contents as a .tar.gz
SourceCheck if a user is a repository collaborator
SourceMerges head
into the base
branch.
octocrab::instance()
.repos("owner", "repo")
.merge("feature", "master")
.send()
.await?;
Source
Handle secrets on the repository
SourceHandle dependabot alerts on the repository
SourceHandle secrets scanning alerts on the repository
SourceCreates a new Git commit object. See https://docs.github.com/en/rest/git/commits?apiVersion=2022-11-28#create-a-commit
use octocrab::models::repos::CommitAuthor;
async fn run() -> octocrab::Result<(GitCommitObject)> {
let git_commit_object = octocrab::instance()
.repos("owner", "repo")
.create_git_commit_object("message", "tree")
.signature("signature")
.author(CommitAuthor{
name: "name".to_owned(),
email: "email".to_owned(),
date: None
})
.send()
.await;
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4