Skip to content

Commit

Permalink
Add delete_ref in RepoHandler
Browse files Browse the repository at this point in the history
Fixes: #572
  • Loading branch information
tniessen committed Feb 9, 2024
1 parent ff27745 commit 6d4a293
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions src/api/repos.rs
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,35 @@ 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 6d4a293

Please sign in to comment.