Repository: scala-steward-org/scala-steward
Pull request #1981 (2021-03-01 11:18:36)

Added support for GitLab draft MRs
GitLab support for draft MRs introduced in #1961 (see [`NewPullRequestData`](https://github.com/scala-steward-org/scala-steward/pull/1961/files#diff-9f88dbf5ecab0e5057fa1fff36ae22860f197aa6cfb0d1b0d62a8bb74a6d2321R43))

codecov[bot]: # [Codecov](https://codecov.io/gh/scala-steward-org/scala-steward/pull/1981?src=pr&el=h1) Report
> Merging [#1981](https://codecov.io/gh/scala-steward-org/scala-steward/pull/1981?src=pr&el=desc) (242595a) into [master](https://codecov.io/gh/scala-steward-org/scala-steward/commit/a9e14755dc357ee24bd5cf215d67ce07f79bf590?el=desc) (a9e1475) will **increase** coverage by `0.03%`.
> The diff coverage is `100.00%`.

[![Impacted file tree graph](https://codecov.io/gh/scala-steward-org/scala-steward/pull/1981/graphs/tree.svg?width=650&height=150&src=pr&token=udzMsc1Dne)](https://codecov.io/gh/scala-steward-org/scala-steward/pull/1981?src=pr&el=tree)

```diff
@@            Coverage Diff             @@
##           master    #1981      +/-   ##
==========================================
+ Coverage   78.52%   78.55%   +0.03%     
==========================================
  Files         130      130              
  Lines        2244     2248       +4     
  Branches       53       54       +1     
==========================================
+ Hits         1762     1766       +4     
  Misses        482      482              
```


| [Impacted Files](https://codecov.io/gh/scala-steward-org/scala-steward/pull/1981?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [...rg/scalasteward/core/vcs/gitlab/GitLabApiAlg.scala](https://codecov.io/gh/scala-steward-org/scala-steward/pull/1981/diff?src=pr&el=tree#diff-bW9kdWxlcy9jb3JlL3NyYy9tYWluL3NjYWxhL29yZy9zY2FsYXN0ZXdhcmQvY29yZS92Y3MvZ2l0bGFiL0dpdExhYkFwaUFsZy5zY2FsYQ==) | `67.04% <100.00%> (+1.56%)` | :arrow_up: |

------

[Continue to review full report at Codecov](https://codecov.io/gh/scala-steward-org/scala-steward/pull/1981?src=pr&el=continue).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/scala-steward-org/scala-steward/pull/1981?src=pr&el=footer). Last update [a9e1475...242595a](https://codecov.io/gh/scala-steward-org/scala-steward/pull/1981?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).


Patch:
diff --git a/modules/core/src/main/scala/org/scalasteward/core/vcs/gitlab/GitLabApiAlg.scala b/modules/core/src/main/scala/org/scalasteward/core/vcs/gitlab/GitLabApiAlg.scala
index b8922cf1..575db030 100644
--- a/modules/core/src/main/scala/org/scalasteward/core/vcs/gitlab/GitLabApiAlg.scala
+++ b/modules/core/src/main/scala/org/scalasteward/core/vcs/gitlab/GitLabApiAlg.scala
@@ -42,7 +42,14 @@ final private[gitlab] case class MergeRequestPayload(
 
 private[gitlab] object MergeRequestPayload {
   def apply(id: String, projectId: Long, data: NewPullRequestData): MergeRequestPayload =
-    MergeRequestPayload(id, data.title, data.body, projectId, data.head, data.base)
+    MergeRequestPayload(
+      id,
+      List(if (data.draft) "Draft: " else "", data.title).mkString,
+      data.body,
+      projectId,
+      data.head,
+      data.base
+    )
 }
 
 final private[gitlab] case class MergeRequestOut(


Test patch:
diff --git a/modules/core/src/test/scala/org/scalasteward/core/vcs/gitlab/MergeRequestPayloadTest.scala b/modules/core/src/test/scala/org/scalasteward/core/vcs/gitlab/MergeRequestPayloadTest.scala
new file mode 100644
index 00000000..99677dac
--- /dev/null
+++ b/modules/core/src/test/scala/org/scalasteward/core/vcs/gitlab/MergeRequestPayloadTest.scala
@@ -0,0 +1,48 @@
+package org.scalasteward.core.vcs.gitlab
+
+import io.circe.syntax._
+import io.circe.literal._
+import munit.FunSuite
+import org.scalasteward.core.git.Branch
+import org.scalasteward.core.vcs.data.NewPullRequestData
+import org.scalasteward.core.vcs.gitlab.GitLabJsonCodec._
+
+class MergeRequestPayloadTest extends FunSuite {
+  private val master = Branch("master")
+  private val data = NewPullRequestData(
+    "Test MR title",
+    "Test MR body",
+    "source",
+    master
+  )
+  private val id = "123"
+  private val projectId = 321L
+
+  test("asJson") {
+    val obtained = MergeRequestPayload(id, projectId, data).asJson
+    val expected =
+      json"""{
+               "id" : "123",
+               "title" : "Test MR title",
+               "description" : "Test MR body",
+               "target_project_id" : 321,
+               "source_branch" : "source",
+               "target_branch" : "master"
+             }"""
+    assertEquals(obtained, expected)
+  }
+
+  test("asJson for draft MR") {
+    val obtained = MergeRequestPayload(id, projectId, data.copy(draft = true)).asJson
+    val expected =
+      json"""{
+               "id" : "123",
+               "title" : "Draft: Test MR title",
+               "description" : "Test MR body",
+               "target_project_id" : 321,
+               "source_branch" : "source",
+               "target_branch" : "master"
+             }"""
+    assertEquals(obtained, expected)
+  }
+}