Commit 9efb8e80 authored by Konstantin Tskhovrebov's avatar Konstantin Tskhovrebov 🤖

Merge branch 'feature/commit_diff_api_entity' into 'feature/commits_route_navigations'

Model layer for commit diff screen

See merge request terrakok/gitlab-client!146
parents e4b7b291 3f3ca8fd
<component name="ProjectCodeStyleConfiguration">
<state>
<option name="USE_PER_PROJECT_SETTINGS" value="true" />
<option name="PREFERRED_PROJECT_CODE_STYLE" value="Default" />
</state>
</component>
\ No newline at end of file
package ru.terrakok.gitlabclient.entity.app
import ru.terrakok.gitlabclient.entity.Author
import ru.terrakok.gitlabclient.entity.Commit
import ru.terrakok.gitlabclient.entity.commit.Commit
/**
* Created by Eugene Shapovalov (@CraggyHaggy) on 20.10.18.
......
package ru.terrakok.gitlabclient.entity
package ru.terrakok.gitlabclient.entity.commit
import com.google.gson.annotations.SerializedName
import org.threeten.bp.LocalDateTime
......
package ru.terrakok.gitlabclient.entity.commit
import com.google.gson.annotations.SerializedName
data class CommitDiff(
@SerializedName("old_path") val oldPath: String,
@SerializedName("new_path") val newPath: String,
@SerializedName("a_mode") val aMode: String,
@SerializedName("b_mode") val bMode: String,
@SerializedName("new_file") val newFile: Boolean,
@SerializedName("renamed_file") val renamedFile: Boolean,
@SerializedName("deleted_file") val deletedFile: Boolean,
@SerializedName("diff") val diff: String
)
\ No newline at end of file
......@@ -5,6 +5,8 @@ import io.reactivex.Single
import org.threeten.bp.LocalDateTime
import retrofit2.http.*
import ru.terrakok.gitlabclient.entity.*
import ru.terrakok.gitlabclient.entity.commit.Commit
import ru.terrakok.gitlabclient.entity.commit.CommitDiff
import ru.terrakok.gitlabclient.entity.event.Event
import ru.terrakok.gitlabclient.entity.event.EventAction
import ru.terrakok.gitlabclient.entity.event.EventTarget
......@@ -19,7 +21,6 @@ import ru.terrakok.gitlabclient.entity.target.TargetType
import ru.terrakok.gitlabclient.entity.todo.Todo
import ru.terrakok.gitlabclient.entity.todo.TodoAction
import ru.terrakok.gitlabclient.entity.todo.TodoState
/**
* @author Konstantin Tskhovrebov (aka terrakok). Date: 28.03.17
*/
......@@ -261,4 +262,16 @@ interface GitlabApi {
@Path("project_id") projectId: Long,
@Path("merge_request_id") mergeRequestId: Long
): Single<MergeRequest>
@GET("$API_PATH/projects/{project_id}/repository/commits/{sha}/diff")
fun getCommitDiff(
@Path("project_id") projectId: Long,
@Path("sha") commitId: String
): Single<CommitDiff>
@GET("$API_PATH//projects/:id/repository/commits/:sha")
fun getCommit(
@Path("project_id") projectId: Long,
@Path("sha") commitId: String
): Single<Commit>
}
\ No newline at end of file
......@@ -60,5 +60,10 @@ class ProjectInteractor @Inject constructor(
.observeOn(schedulers.ui())
fun getCommitDiff(
projectId: Long,
commitId: String
) = projectRepository.getCommitDiff(projectId, commitId)
class ReadmeNotFound : Exception()
}
\ No newline at end of file
......@@ -7,6 +7,7 @@ import org.threeten.bp.LocalDateTime
import ru.terrakok.gitlabclient.entity.*
import ru.terrakok.gitlabclient.entity.app.CommitWithAuthor
import ru.terrakok.gitlabclient.entity.app.target.*
import ru.terrakok.gitlabclient.entity.commit.Commit
import ru.terrakok.gitlabclient.entity.event.EventAction
import ru.terrakok.gitlabclient.entity.mergerequest.MergeRequest
import ru.terrakok.gitlabclient.entity.mergerequest.MergeRequestScope
......
......@@ -71,4 +71,14 @@ class ProjectRepository @Inject constructor(
.getRepositoryTree(projectId, path, branchName, recursive)
.subscribeOn(schedulers.io())
.observeOn(schedulers.ui())
fun getCommit(projectId: Long, commitId: String) = api
.getCommit(projectId, commitId)
.subscribeOn(schedulers.io())
.observeOn(schedulers.ui())
fun getCommitDiff(projectId: Long, commitId: String) = api
.getCommitDiff(projectId, commitId)
.subscribeOn(schedulers.io())
.observeOn(schedulers.ui())
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment