-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
62 additions
and
1 deletion.
There are no files selected for viewing
20 changes: 20 additions & 0 deletions
20
.../src/main/kotlin/org/jetbrains/research/ideFormerPlugin/api/models/gitRelated/GitMerge.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package org.jetbrains.research.ideFormerPlugin.api.models.gitRelated | ||
|
||
import com.intellij.openapi.project.Project | ||
import com.intellij.openapi.vfs.VirtualFile | ||
import git4idea.commands.GitCommand | ||
|
||
class GitMerge( | ||
project: Project, | ||
projectGitRoot: VirtualFile, | ||
mergingBranchName: String | ||
) : GitApiMethod(project, projectGitRoot) { | ||
// Invariant: you're staying on the right branch that you want to merge changes to. Git checkout was made recently. | ||
override var gitCommand: GitCommand? = GitCommand.MERGE | ||
override var gitCommandParameters: List<String>? = listOf(mergingBranchName) | ||
|
||
override var gitReverseCommand: GitCommand? = GitCommand.RESET | ||
// --merge as opposed to the --hard doesn't reset uncommited/ unstashed files. | ||
// ORIG_HEAD will point to a commit directly before merge has occurred, so you don't have to hunt for it by yourself. | ||
override var gitReverseCommandParameters: List<String>? = listOf("--merge", "ORIG_HEAD") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
...n/kotlin/org/jetbrains/research/ideFormerPlugin/server/requests/gitRelated/getGitMerge.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package org.jetbrains.research.ideFormerPlugin.server.requests.gitRelated | ||
|
||
import io.ktor.server.application.* | ||
import io.ktor.server.routing.* | ||
import org.jetbrains.research.ideFormerPlugin.api.models.gitRelated.GitMerge | ||
import org.jetbrains.research.ideFormerPlugin.server.* | ||
import org.jetbrains.research.ideFormerPlugin.stateKeeper.IdeStateKeeper | ||
import org.slf4j.Logger | ||
|
||
fun Routing.getGitMerge(logger: Logger, ideStateKeeper: IdeStateKeeper) { | ||
get("/git-merge/{${IdeServerConstants.BRANCH_NAME_REQUEST_PARAM}?}") { | ||
val mergingBranchName = call.processRequestParameter(IdeServerConstants.BRANCH_NAME_REQUEST_PARAM, logger) | ||
?: return@get | ||
logger.info("Server GET git merge $mergingBranchName into current branch is called") | ||
|
||
val gitMerge = GitMerge(ideStateKeeper.userProject, ideStateKeeper.projectGitRoot, mergingBranchName) | ||
if (!executeAndRespondError(gitMerge, logger)) return@get | ||
|
||
ideStateKeeper.saveReversibleApiMethod(gitMerge) | ||
logger.info("Git merge api method was saved on the api methods stack") | ||
|
||
call.respondJson("Git merge $mergingBranchName into current branch was processed successfully") | ||
logger.info("Server GET git merge $mergingBranchName into current branch is processed") | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters