Skip to content

Commit

Permalink
Add delete_ref in RepoHandler
Browse files Browse the repository at this point in the history
  • Loading branch information
tniessen committed Feb 10, 2024
1 parent ff27745 commit 31f5aab
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions src/api/repos.rs
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,32 @@ impl<'octo> RepoHandler<'octo> {
.await
}

/// Deletes an existing reference from the repository.
/// ```no_run
/// # async fn run() -> octocrab::Result<()> {
/// # let master_sha = "";
/// use octocrab::params::repos::Reference;
///
/// // Deletes the "heads/temporary-branch" reference.
/// octocrab::instance()
/// .repos("owner", "repo")
/// .delete_ref(&Reference::Branch("temporary-branch".to_string()))
/// .await?;
/// # Ok(())
/// # }
/// ```
pub async fn delete_ref(&self, reference: &params::repos::Reference) -> Result<()> {
let route = format!(
"/repos/{owner}/{repo}/git/refs/{ref}",
owner = self.owner,
repo = self.repo,
ref = reference.ref_url()
);
crate::map_github_error(self.crab._delete(route, None::<&()>).await?)
.await
.map(drop)
}

/// Get repository content.
/// ```no_run
/// # async fn run() -> octocrab::Result<()> {
Expand Down

0 comments on commit 31f5aab

Please # to comment.