Skip to content

feature: added project into repository - PLUTO-1075 #135

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ case class Repository(
language: Option[String],
urls: Seq[RepositoryUrl],
uuid: String,
slug: String
slug: String,
project: Option[Project]
)

object Repository {
Expand All @@ -32,6 +33,9 @@ object Repository {
.localDateTimeReads(dateFormat)
.orElse(Reads.localDateTimeReads(dateFormatWithoutMillis))

implicit val projectReads: Reads[Project] =
((__ \ "name").read[String] and (__ \ "key").read[String])(Project.apply _)

// format: off
implicit val reader: Reads[Repository] = {
((__ \ "name").read[String] and
Expand All @@ -47,7 +51,8 @@ object Repository {
(__ \ "language").readNullable[String] and
(__ \ "links").read[Map[String, JsValue]].map(parseLinks) and
(__ \ "uuid" ).read[String] and
(__ \ "slug" ).read[String]
(__ \ "slug" ).read[String] and
(__ \ "project").readNullable[Project]
) (Repository.apply _)
}
// format: on
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ class RepositorySpecs extends FlatSpec with Matchers {
| "type": "repository",
| "slug": "tweakmsg",
| "is_private": false,
| "project": {"name": "tweakmsg", "key": "TWEAKMSG"},
| "description": "Mercurial (hg) extension to allow commenting on commit messages. Mainly written for practice reading & working with mercurial internals.\r\n"
|}""".stripMargin
val json = Json.parse(input)
Expand All @@ -135,6 +136,7 @@ class RepositorySpecs extends FlatSpec with Matchers {
value.fold(e => fail(s"$e"), r => {
r.name shouldBe "tweakmsg"
r.owner.display_name shouldBe "John Mulligan"
r.project.map(_.name) shouldBe Some("tweakmsg")
})
}

Expand Down