Skip to content

Commit

Permalink
feat: add repository list language support (#595)
Browse files Browse the repository at this point in the history
  • Loading branch information
GeekMasher authored Mar 6, 2024
1 parent 2b68d03 commit c18e90b
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
23 changes: 23 additions & 0 deletions src/api/repos.rs
Original file line number Diff line number Diff line change
Expand Up @@ -489,6 +489,29 @@ impl<'octo> RepoHandler<'octo> {
ListStarGazersBuilder::new(self)
}

/// Lists languages for the specified repository.
/// The value shown for each language is the number of bytes of code written in that language.
///
/// ```no_run
/// # async fn run() -> octocrab::Result<()> {
///
/// // Get the languages used in the repository
/// let languages = octocrab::instance()
/// .repos("owner", "repo")
/// .list_languages()
/// .await?;
/// # Ok(())
/// # }
/// ```
pub async fn list_languages(&self) -> Result<models::repos::Languages> {
let route = format!(
"/repos/{owner}/{repo}/languages",
owner = self.owner,
repo = self.repo,
);
self.crab.get(route, None::<&()>).await
}

/// Creates a `ReleasesHandler` for the specified repository.
pub fn releases(&self) -> releases::ReleasesHandler<'_, '_> {
releases::ReleasesHandler::new(self)
Expand Down
3 changes: 3 additions & 0 deletions src/models/repos.rs
Original file line number Diff line number Diff line change
Expand Up @@ -377,3 +377,6 @@ pub struct MergeCommit {
pub html_url: String,
pub comments_url: String,
}

/// A HashMap of languages and the number of bytes of code written in that language.
pub type Languages = std::collections::HashMap<String, i64>;

0 comments on commit c18e90b

Please sign in to comment.