Skip to content
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

Arf 105 create pull request api #109

Merged
merged 22 commits into from May 3, 2017

Conversation

AdrianRaFo
Copy link
Contributor

Fixes #105 Create PullRequest Api integration

Copy link
Contributor

@fedefernandez fedefernandez left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor comments but we should add the docs for these two new operations here

val invalidNewPullRequestData = NewPullRequestData("", "")

val validNewPullRequestIssue = NewPullRequestIssue(26)
val invalidNewPullRequestIssue = NewPullRequestIssue(5)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The invalid vals are not used, could you please remove them?

* requests in the same network, namespace head with a user like this: username:branch.
* @param base Required. The name of the branch you want the changes pulled into. This should be an existing branch
* on the current repository. You cannot submit a pull request to one repository that
* @param maintainerCanModify Indicates whether maintainers can modify the pull request.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bad indentation, please remove the tabs in the scaladocs. Also, please specify that the value for maintainerCanModify is true by default

base,
maintainerCanModify).asJson.noSpaces)

}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's more clear to create the data first and then make the call, something like:

def create(
  accessToken: Option[String] = None,
  headers: Map[String, String] = Map(),
  owner: String,
  repo: String,
  newPullRequest: NewPullRequest,
  head: String,
  base: String,
  maintainerCanModify: Option[Boolean] = Some(true)): M[GHResponse[PullRequest]] = {
  val data = newPullRequest match {
    case NewPullRequestData(title, body) 
      CreatePullRequestData(title, head, base, body, maintainerCanModify)
    case NewPullRequestIssue(issue) 
      CreatePullRequestIssue(issue, head, base, maintainerCanModify)
  httpClient.post[PullRequest](accessToken, s"repos/$owner/$repo/pulls", headers, data.asJson.noSpaces)
}

@fedefernandez
Copy link
Contributor

fedefernandez commented May 2, 2017

Also, please add the tests in ApiSpec.scala

@codecov-io
Copy link

codecov-io commented May 3, 2017

Codecov Report

Merging #109 into master will decrease coverage by 0.12%.
The diff coverage is 75%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #109      +/-   ##
==========================================
- Coverage   88.14%   88.01%   -0.13%     
==========================================
  Files          36       36              
  Lines         506      534      +28     
  Branches        3        3              
==========================================
+ Hits          446      470      +24     
- Misses         60       64       +4
Impacted Files Coverage Δ
.../main/scala/github4s/free/domain/PullRequest.scala 100% <ø> (ø) ⬆️
...cala/github4s/free/interpreters/Interpreters.scala 83.87% <0%> (-1.38%) ⬇️
...n/scala/github4s/free/algebra/PullRequestOps.scala 60% <0%> (-40%) ⬇️
...4s/shared/src/main/scala/github4s/GithubAPIs.scala 96.77% <100%> (+0.1%) ⬆️
...red/src/main/scala/github4s/api/PullRequests.scala 100% <100%> (ø) ⬆️
...ub4s/shared/src/main/scala/github4s/Encoders.scala 100% <100%> (ø) ⬆️
...4s/shared/src/main/scala/github4s/HttpClient.scala 85.1% <0%> (+6.53%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update b869e17...d8f680f. Read the comment docs.


## Create a pull request
If you want to create a pull request,we have two ways to create a pull request.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

--pull request,we have
++pull request, we have

```

On the other hand, we can pass a `issue` id (in `NewPullRequestIssue` object) instead of title and body to get this parameter of the issue
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

--we can pass a `issue`
++we can pass an `issue`
-- (in `NewPullRequestIssue` object)
++ (as part of the `NewPullRequestIssue` object)
-- instead of title and body to get this parameter of the issue
++ instead of the title and the body to get this parameter of the issue.

On the other hand, we can pass a `issue` id (in `NewPullRequestIssue` object) instead of title and body to get this parameter of the issue

**NOTE**: This option delete the issue
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It should end with full stop char ..

-- This option delete
++ This option deletes

decode[Repository](emptyListResponse).isLeft shouldBe true
}

"StatusRepository decoder" should "return a valid repo for a valid JSON" in {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CombinedStatus decoder

@@ -608,11 +608,59 @@ class ApiSpec
accessToken,
headerUserAgent,
validRepoOwner,
invalidRepoName,
validPRRepoName,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Either the test banner or this value are wrong. We should make this consistent.

@@ -111,16 +111,33 @@ trait TestUtils {
val validPullRequestFileSha = "f80f79cafbe3f2ba71311b82e1171e73bd37a470"
val validPullRequestNumber = 1

val validPRRepoName = "sbt-dependencies-test"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What would happen if this repository is deleted?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could use github4s

Copy link
Member

@juanpedromoreno juanpedromoreno left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

giphy 15

@juanpedromoreno juanpedromoreno merged commit 9ee5cc3 into master May 3, 2017
@juanpedromoreno juanpedromoreno deleted the arf-105-Create-Pull-Request-API branch May 3, 2017 10:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants