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

Get Tag #500

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
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
16 changes: 16 additions & 0 deletions github4s/src/main/scala/github4s/algebras/GitData.scala
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,22 @@ trait GitData[F[_]] {
headers: Map[String, String] = Map()
): F[GHResponse[TreeResult]]

/**
* Get a Tag by sha
*
* @param owner of the repo
* @param repo name of the repo
* @param sha the sha of the tree
* @param headers optional user headers to include in the request
* @return a GHResponse with the Tree
*/
def getTag(
owner: String,
repo: String,
sha: String,
headers: Map[String, String] = Map()
): F[GHResponse[Tag]]

/**
* Create a Tag
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,18 @@ class GitDataInterpreter[F[_]](implicit client: HttpClient[F]) extends GitData[F
NewTreeRequest(treeDataList, baseTree)
)

override def getTag(
owner: String,
repo: String,
sha: String,
headers: Map[String, String]
): F[GHResponse[Tag]] =
client.get[Tag](
accessToken,
s"repos/$owner/$repo/git/tags/$sha",
headers
)

override def createTag(
owner: String,
repo: String,
Expand Down
25 changes: 25 additions & 0 deletions github4s/src/test/scala/github4s/unit/GitDataSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,31 @@ class GitDataSpec extends BaseSpec {

}

"GitData.getTag" should "call to httpClient.get with the right parameters" in {

val response: IO[GHResponse[Tag]] =
IO(
GHResponse(
tag.asRight,
okStatusCode,
Map.empty
)
)

implicit val httpClientMock = httpClientMockGet[Tag](
url = s"repos/$validRepoOwner/$validRepoName/git/tags/$validCommitSha",
response = response
)
val gitData = new GitDataInterpreter[IO]

gitData.getTag(
validRepoOwner,
validRepoName,
validCommitSha,
headerUserAgent
)
}

"GitData.createTag" should "call to httpClient.post with the right parameters" in {

val request =
Expand Down