Skip to content

Commit

Permalink
Merge pull request #499 from alejandrohdezma/fix/url
Browse files Browse the repository at this point in the history
Fix collaborators & release URLs decoding
  • Loading branch information
alejandrohdezma committed Jul 10, 2023
2 parents ce860db + 834be62 commit fe9cc59
Showing 1 changed file with 17 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ import com.alejandrohdezma.sbt.github.github.urls.RepositoryEntryPoint
import com.alejandrohdezma.sbt.github.http.Authentication
import com.alejandrohdezma.sbt.github.http.client
import com.alejandrohdezma.sbt.github.json.Decoder
import com.alejandrohdezma.sbt.github.json.Json
import com.alejandrohdezma.sbt.github.json.error.NotAUrl
import com.alejandrohdezma.sbt.github.syntax.json._
import com.alejandrohdezma.sbt.github.syntax.list._
import com.alejandrohdezma.sbt.github.syntax.scalatry._
Expand Down Expand Up @@ -162,17 +164,19 @@ object Repository {

implicit val RepositoryDecoder: Decoder[Repository] = json =>
for {
name <- json.get[String]("full_name")
description <- json.get[String]("description")
license <- json.get[License]("license")
url <- json.get[URL]("html_url")
startYear <- json.get[ZonedDateTime]("created_at")
defaultBranch <- json.get[String]("default_branch")
contributors <- json.get[URL]("contributors_url")
collaborators <- json.get[URL]("collaborators_url")
organizationUrl <- json.get[Option[URL]]("organization", "url")
releases <- json.get[URL]("releases_url")
ownerUrl <- json.get[URL]("owner", "url")
name <- json.get[String]("full_name")
description <- json.get[String]("description")
license <- json.get[License]("license")
url <- json.get[URL]("html_url")
startYear <- json.get[ZonedDateTime]("created_at")
defaultBranch <- json.get[String]("default_branch")
contributors <- json.get[URL]("contributors_url")
collaborators <- json.get[String]("collaborators_url").map(_.replace("{/collaborator}", ""))
collaboratorsUrl <- Try(sbt.url(collaborators)).failAs(NotAUrl(Json.Text(collaborators)))
organizationUrl <- json.get[Option[URL]]("organization", "url")
releases <- json.get[String]("releases_url").map(_.replace("{/id}", ""))
releasesUrl <- Try(sbt.url(releases)).failAs(NotAUrl(Json.Text(releases)))
ownerUrl <- json.get[URL]("owner", "url")
} yield Repository(
name,
description,
Expand All @@ -181,8 +185,8 @@ object Repository {
startYear.getYear,
defaultBranch,
contributors,
sbt.url(s"$collaborators".replace("{/collaborator}", "")),
sbt.url(s"$releases".replace("{/id}", "")),
collaboratorsUrl,
releasesUrl,
organizationUrl,
ownerUrl
)
Expand Down

0 comments on commit fe9cc59

Please sign in to comment.