Skip to content

Commit e195d97

Browse files
added project into repository
1 parent e3ed2c8 commit e195d97

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

src/main/scala/com/codacy/client/bitbucket/v2/Repository.scala

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ case class Repository(
2020
language: Option[String],
2121
urls: Seq[RepositoryUrl],
2222
uuid: String,
23-
slug: String
23+
slug: String,
24+
project: Option[Project]
2425
)
2526

2627
object Repository {
@@ -32,6 +33,9 @@ object Repository {
3233
.localDateTimeReads(dateFormat)
3334
.orElse(Reads.localDateTimeReads(dateFormatWithoutMillis))
3435

36+
implicit val projectReads: Reads[Project] =
37+
((__ \ "name").read[String] and (__ \ "key").read[String])(Project.apply _)
38+
3539
// format: off
3640
implicit val reader: Reads[Repository] = {
3741
((__ \ "name").read[String] and
@@ -47,7 +51,8 @@ object Repository {
4751
(__ \ "language").readNullable[String] and
4852
(__ \ "links").read[Map[String, JsValue]].map(parseLinks) and
4953
(__ \ "uuid" ).read[String] and
50-
(__ \ "slug" ).read[String]
54+
(__ \ "slug" ).read[String] and
55+
(__ \ "project").readNullable[Project]
5156
) (Repository.apply _)
5257
}
5358
// format: on

src/test/scala/com/codacy/client/bitbucket/v2/RepositorySpecs.scala

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@ class RepositorySpecs extends FlatSpec with Matchers {
127127
| "type": "repository",
128128
| "slug": "tweakmsg",
129129
| "is_private": false,
130+
| "project": {"name": "tweakmsg", "key": "TWEAKMSG"},
130131
| "description": "Mercurial (hg) extension to allow commenting on commit messages. Mainly written for practice reading & working with mercurial internals.\r\n"
131132
|}""".stripMargin
132133
val json = Json.parse(input)
@@ -135,6 +136,7 @@ class RepositorySpecs extends FlatSpec with Matchers {
135136
value.fold(e => fail(s"$e"), r => {
136137
r.name shouldBe "tweakmsg"
137138
r.owner.display_name shouldBe "John Mulligan"
139+
r.project.map(_.name) shouldBe Some("tweakmsg")
138140
})
139141
}
140142

0 commit comments

Comments
 (0)