Skip to content

Commit 31e611c

Browse files
committed
cross compilation && pr commits
1 parent ac88319 commit 31e611c

File tree

5 files changed

+40
-8
lines changed

5 files changed

+40
-8
lines changed

build.sbt

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,11 @@ import Dependencies._
22

33
name := """bitbucket-scala-client"""
44

5-
version := "1.1"
5+
version := "1.1-SNAPSHOT"
66

7-
scalaVersion := "2.11.1"
7+
scalaVersion := "2.10.5"
8+
9+
crossScalaVersions := Seq("2.10.5", "2.11.6")
810

911
scalacOptions := Seq("-deprecation", "-feature", "-unchecked", "-Ywarn-adapted-args", "-Xlint")
1012

@@ -25,7 +27,7 @@ publishMavenStyle := true
2527

2628
publishArtifact in Test := false
2729

28-
pomIncludeRepository := { _ => false}
30+
pomIncludeRepository := { _ => false }
2931

3032
publishTo := {
3133
val nexus = "https://oss.sonatype.org/"

project/Dependencies.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ import sbt._
33
object Dependencies {
44

55
// Generic
6-
lazy val jodaTime = "joda-time" % "joda-time" % "2.3"
6+
lazy val jodaTime = "joda-time" % "joda-time" % "2.7"
77

88
// Play framework
9-
lazy val playWS = "com.typesafe.play" %% "play-ws" % "2.3.2"
9+
lazy val playWS = "com.typesafe.play" %% "play-ws" % "2.3.8"
1010

1111
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
package com.codacy.client.bitbucket
2+
3+
import org.joda.time.DateTime
4+
import play.api.libs.functional.syntax._
5+
import play.api.libs.json._
6+
7+
case class Commit(hash: String, authorName: String, parents: Option[Seq[String]], date: DateTime, message: String)
8+
9+
object Commit {
10+
val dateFormat = "yyyy-MM-dd'T'HH:mm:ssZZ"
11+
implicit val jodaDateTimeReads = Reads.jodaDateReads(dateFormat)
12+
13+
implicit val reader: Reads[Commit] = (
14+
(__ \ "hash").read[String] and
15+
(__ \ "author" \ "user" \ "username").read[String] and
16+
(__ \ "parents" \\ "hash").read[Option[Seq[String]]] and
17+
(__ \ "date").read[DateTime] and
18+
(__ \ "message").read[String]
19+
)(Commit.apply _)
20+
}

src/main/scala/com/codacy/client/bitbucket/PullRequest.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import play.api.libs.functional.syntax._
55
import play.api.libs.json._
66

77
case class PullRequest(id: Long, title: String, description: String,
8-
authorUsername: String, authorAvatar: String,
8+
authorUsername: String, authorAvatar: Option[String],
99
state: String, created_on: DateTime, updated_on: DateTime,
1010
sourceRepository: String, sourceBranch: String, sourceCommit: String,
1111
destRepository: String, destBranch: String, destCommit: String) {
@@ -21,7 +21,7 @@ object PullRequest {
2121
(__ \ "title").read[String] and
2222
(__ \ "description").read[String] and
2323
(__ \ "author" \ "username").read[String] and
24-
(__ \ "author" \ "links" \ "avatar").read[String] and
24+
(__ \ "author" \ "links" \ "avatar").read[Option[String]] and
2525
(__ \ "state").read[String] and
2626
(__ \ "created_on").read[DateTime] and
2727
(__ \ "updated_on").read[DateTime] and

src/main/scala/com/codacy/client/bitbucket/service/PullRequestServices.scala

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package com.codacy.client.bitbucket.service
22

3-
import com.codacy.client.bitbucket.PullRequest
43
import com.codacy.client.bitbucket.client.{BitbucketClient, Request, RequestResponse}
4+
import com.codacy.client.bitbucket.{Commit, PullRequest}
55

66
class PullRequestServices(client: BitbucketClient) {
77

@@ -17,4 +17,14 @@ class PullRequestServices(client: BitbucketClient) {
1717
client.executePaginated(Request(url, classOf[Seq[PullRequest]]))
1818
}
1919

20+
/*
21+
* Gets the list of commits of a pull request
22+
*
23+
*/
24+
def getPullRequestCommits(owner: String, repository: String, prId: Long): RequestResponse[Seq[Commit]] = {
25+
val url = s"https://bitbucket.org/!api/2.0/repositories/$owner/$repository/pullrequests/$prId/commits"
26+
27+
client.executePaginated(Request(url, classOf[Seq[Commit]]))
28+
}
29+
2030
}

0 commit comments

Comments
 (0)