clean up the mess
This commit is contained in:
parent
83885ee5c5
commit
63e358d9c8
5 changed files with 2 additions and 103 deletions
|
|
@ -7,6 +7,6 @@ import com.intellij.openapi.startup.ProjectActivity
|
||||||
class APCProjectActivity: ProjectActivity {
|
class APCProjectActivity: ProjectActivity {
|
||||||
|
|
||||||
override suspend fun execute(project : Project){
|
override suspend fun execute(project : Project){
|
||||||
thisLogger().warn("Autoprefixer Commit is active")
|
thisLogger().warn("Autoprefix-commit plugin is active")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1,35 +0,0 @@
|
||||||
package nl.topsquad.autoprefixcommit
|
|
||||||
|
|
||||||
import com.intellij.openapi.vcs.CheckinProjectPanel
|
|
||||||
import com.intellij.openapi.vcs.changes.CommitContext
|
|
||||||
import com.intellij.openapi.vcs.checkin.CheckinHandler
|
|
||||||
import com.intellij.openapi.vcs.checkin.CheckinHandlerFactory
|
|
||||||
import git4idea.repo.GitRepositoryManager
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Alternative implementation that modifies the commit message right before commit
|
|
||||||
*/
|
|
||||||
class AlternativeBranchNameHandlerFactory : CheckinHandlerFactory() {
|
|
||||||
override fun createHandler(panel: CheckinProjectPanel, commitContext: CommitContext): CheckinHandler {
|
|
||||||
return object : CheckinHandler() {
|
|
||||||
|
|
||||||
override fun beforeCheckin(): ReturnResult {
|
|
||||||
val repository = GitRepositoryManager.getInstance(panel.project).repositories.firstOrNull()
|
|
||||||
repository?.let {
|
|
||||||
val currentBranch = it.currentBranchName
|
|
||||||
val currentMessage = panel.commitMessage
|
|
||||||
|
|
||||||
if (currentBranch != null && !currentMessage.contains(currentBranch)) {
|
|
||||||
val newMessage = if (currentMessage.isEmpty()) {
|
|
||||||
"$currentBranch: "
|
|
||||||
} else {
|
|
||||||
"$currentBranch: $currentMessage"
|
|
||||||
}
|
|
||||||
panel.commitMessage = newMessage
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return ReturnResult.COMMIT
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -28,7 +28,7 @@ class BranchNameCheckinHandlerFactory : CheckinHandlerFactory() {
|
||||||
val repository = GitRepositoryManager.getInstance(panel.project).repositories.firstOrNull()
|
val repository = GitRepositoryManager.getInstance(panel.project).repositories.firstOrNull()
|
||||||
|
|
||||||
return repository?.let {
|
return repository?.let {
|
||||||
val branchName = it.currentBranchName;
|
val branchName = it.currentBranchName
|
||||||
if (branchName != null && !message.startsWith("${branchName} ")) {
|
if (branchName != null && !message.startsWith("${branchName} ")) {
|
||||||
"${it.currentBranchName ?: ""} ${message} "
|
"${it.currentBranchName ?: ""} ${message} "
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
|
|
@ -1,19 +0,0 @@
|
||||||
package nl.topsquad.autoprefixcommit
|
|
||||||
|
|
||||||
import com.intellij.openapi.project.Project
|
|
||||||
import com.intellij.openapi.vcs.changes.LocalChangeList
|
|
||||||
import com.intellij.openapi.vcs.changes.ui.CommitMessageProvider
|
|
||||||
import com.intellij.util.diff.Diff
|
|
||||||
import git4idea.repo.GitRepositoryManager
|
|
||||||
import org.jetbrains.annotations.NotNull
|
|
||||||
|
|
||||||
class BranchNameCommitMessageProvider: CommitMessageProvider {
|
|
||||||
override fun getCommitMessage(@NotNull forChangelist: LocalChangeList, project: Project): String? {
|
|
||||||
val repository = GitRepositoryManager.getInstance(project).repositories.firstOrNull()
|
|
||||||
repository?.let {
|
|
||||||
val currentBranch = it.currentBranchName
|
|
||||||
return currentBranch
|
|
||||||
}
|
|
||||||
return ""
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,47 +0,0 @@
|
||||||
package nl.topsquad.autoprefixcommit
|
|
||||||
|
|
||||||
import com.intellij.openapi.application.ApplicationManager
|
|
||||||
import com.intellij.openapi.vcs.CheckinProjectPanel
|
|
||||||
import com.intellij.openapi.vcs.changes.CommitContext
|
|
||||||
import com.intellij.openapi.vcs.checkin.CheckinHandler
|
|
||||||
import com.intellij.openapi.vcs.checkin.CheckinHandlerFactory
|
|
||||||
import git4idea.repo.GitRepositoryManager
|
|
||||||
import javax.swing.Timer
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Implementation that uses a timer to delay commit message modification
|
|
||||||
*/
|
|
||||||
class DelayedBranchNameHandlerFactory : CheckinHandlerFactory() {
|
|
||||||
override fun createHandler(panel: CheckinProjectPanel, commitContext: CommitContext): CheckinHandler {
|
|
||||||
return object : CheckinHandler() {
|
|
||||||
|
|
||||||
init {
|
|
||||||
// Use a timer to delay the modification slightly
|
|
||||||
val timer = Timer(100) { // 100ms delay
|
|
||||||
ApplicationManager.getApplication().invokeLater {
|
|
||||||
modifyCommitMessage(panel)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
timer.isRepeats = false
|
|
||||||
timer.start()
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun modifyCommitMessage(panel: CheckinProjectPanel) {
|
|
||||||
val repository = GitRepositoryManager.getInstance(panel.project).repositories.firstOrNull()
|
|
||||||
repository?.let {
|
|
||||||
val currentBranch = it.currentBranchName
|
|
||||||
val currentMessage = panel.commitMessage
|
|
||||||
|
|
||||||
if (currentBranch != null && !currentMessage.contains(currentBranch)) {
|
|
||||||
val newMessage = if (currentMessage.isEmpty()) {
|
|
||||||
"$currentBranch: "
|
|
||||||
} else {
|
|
||||||
"$currentBranch: $currentMessage"
|
|
||||||
}
|
|
||||||
panel.commitMessage = newMessage
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Loading…
Add table
Reference in a new issue