Compare commits
10 commits
c91c1a7d18
...
485be3e57c
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
485be3e57c | ||
|
|
30a5efb337 | ||
|
|
32a5b2be66 | ||
|
|
4cb019ef4a | ||
|
|
3ebfa2412e | ||
|
|
71b26ffaa4 | ||
|
|
ff53b020d9 | ||
|
|
c921fc1efb | ||
|
|
b60f1dc27d | ||
|
|
8d0b306897 |
8 changed files with 145 additions and 87 deletions
47
.github/workflows/blank.yml
vendored
Normal file
47
.github/workflows/blank.yml
vendored
Normal file
|
|
@ -0,0 +1,47 @@
|
||||||
|
name: Gradle Build
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches: [ main, develop ]
|
||||||
|
pull_request:
|
||||||
|
branches: [ main, develop ]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Checkout code
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Set up JDK 21
|
||||||
|
uses: actions/setup-java@v4
|
||||||
|
with:
|
||||||
|
java-version: '21'
|
||||||
|
distribution: 'temurin'
|
||||||
|
|
||||||
|
- name: Setup Gradle
|
||||||
|
uses: gradle/actions/setup-gradle@v3
|
||||||
|
|
||||||
|
- name: Make gradlew executable
|
||||||
|
run: chmod +x ./gradlew
|
||||||
|
|
||||||
|
- name: Build with Gradle
|
||||||
|
run: ./gradlew build
|
||||||
|
|
||||||
|
- name: Run tests
|
||||||
|
run: ./gradlew test
|
||||||
|
|
||||||
|
- name: Upload build artifacts
|
||||||
|
uses: actions/upload-artifact@v4
|
||||||
|
if: always()
|
||||||
|
with:
|
||||||
|
name: build-artifacts
|
||||||
|
path: build/libs/
|
||||||
|
|
||||||
|
- name: Upload test results
|
||||||
|
uses: actions/upload-artifact@v4
|
||||||
|
if: always()
|
||||||
|
with:
|
||||||
|
name: test-results
|
||||||
|
path: build/reports/tests/
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
# Autoprefix-commit
|
# Autoprefix-commit
|
||||||
A simple intellij plugin that puts the current branch name in front of the commit message
|
A simple intellij plugin that puts the current branch name in front of the commit message
|
||||||
* Updates the branch every time the commit dialog is focussed
|
* Updates the branch every time the commit dialog is focussed
|
||||||
* Puts the branch name in front of any pre-existing text (unless the branch name was already there)
|
* Puts #[branchname] in front of any pre-existing text (unless the branch name was already there)
|
||||||
* No config for other fixed characters
|
* No config for other fixed characters
|
||||||
* Tested on IntelliJ 2025.x
|
* Tested on IntelliJ 2025.x
|
||||||
|
|
@ -1,11 +1,11 @@
|
||||||
plugins {
|
plugins {
|
||||||
id("java")
|
id("java")
|
||||||
id("org.jetbrains.kotlin.jvm") version "1.9.20"
|
id("org.jetbrains.kotlin.jvm") version "2.2.0"
|
||||||
id("org.jetbrains.intellij.platform") version "2.3.0"
|
id("org.jetbrains.intellij.platform") version "2.9.0"
|
||||||
}
|
}
|
||||||
|
|
||||||
group = "com.github.shautvast"
|
group = "com.github.shautvast"
|
||||||
version = "1.0"
|
version = "1.4"
|
||||||
|
|
||||||
repositories {
|
repositories {
|
||||||
mavenCentral()
|
mavenCentral()
|
||||||
|
|
@ -14,39 +14,26 @@ repositories {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
kotlin {
|
|
||||||
jvmToolchain(17)
|
|
||||||
}
|
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
intellijPlatform {
|
intellijPlatform {
|
||||||
create("IC", "2024.2.5")
|
create("IC", "2025.2.2")
|
||||||
testFramework(org.jetbrains.intellij.platform.gradle.TestFrameworkType.Platform)
|
testFramework(org.jetbrains.intellij.platform.gradle.TestFrameworkType.Platform)
|
||||||
bundledPlugin("Git4Idea")
|
bundledPlugin("Git4Idea")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
intellijPlatform {
|
intellijPlatform {
|
||||||
pluginConfiguration {
|
pluginConfiguration {
|
||||||
ideaVersion {
|
ideaVersion {
|
||||||
sinceBuild = "242"
|
sinceBuild = "252"
|
||||||
}
|
}
|
||||||
|
|
||||||
changeNotes = """
|
changeNotes = """
|
||||||
Initial version: insert branchname in commit dialog. No configuration needed.
|
1.1 Initial version: insert branchname in commit dialog. No configuration needed.
|
||||||
|
1.2 No code changes. Plugin was mistakenly compiled using jdk22 so it didn't work.
|
||||||
|
1.3 minor fix for redundant space after the branch name
|
||||||
|
1.4 put # in front of the branch
|
||||||
""".trimIndent()
|
""".trimIndent()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
tasks {
|
|
||||||
// Set the JVM compatibility versions
|
|
||||||
withType<JavaCompile> {
|
|
||||||
sourceCompatibility = "21"
|
|
||||||
targetCompatibility = "21"
|
|
||||||
}
|
|
||||||
withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile> {
|
|
||||||
kotlinOptions.jvmTarget = "21"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,36 @@
|
||||||
|
package com.github.shautvast.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
|
||||||
|
import java.awt.event.FocusAdapter
|
||||||
|
import java.awt.event.FocusEvent
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handles Git branch name injection into commit messages when the commit dialog is opened
|
||||||
|
*/
|
||||||
|
class BranchNameCheckinHandlerFactory : CheckinHandlerFactory() {
|
||||||
|
|
||||||
|
override fun createHandler(panel: CheckinProjectPanel, commitContext: CommitContext): CheckinHandler {
|
||||||
|
return object : CheckinHandler() {
|
||||||
|
init {
|
||||||
|
(panel.preferredFocusedComponent)?.addFocusListener(object : FocusAdapter() {
|
||||||
|
override fun focusGained(e: FocusEvent?) {
|
||||||
|
// update commit message
|
||||||
|
val message = panel.commitMessage
|
||||||
|
val repository = GitRepositoryManager.getInstance(panel.project).repositories.firstOrNull()
|
||||||
|
repository?.let {
|
||||||
|
it.currentBranchName?.let { b ->
|
||||||
|
if (!message.startsWith(b)) {
|
||||||
|
panel.commitMessage = "#$b $message"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -1,12 +0,0 @@
|
||||||
package nl.topsquad.autoprefixcommit
|
|
||||||
|
|
||||||
import com.intellij.openapi.diagnostic.thisLogger
|
|
||||||
import com.intellij.openapi.project.Project
|
|
||||||
import com.intellij.openapi.startup.ProjectActivity
|
|
||||||
|
|
||||||
class APCProjectActivity: ProjectActivity {
|
|
||||||
|
|
||||||
override suspend fun execute(project : Project){
|
|
||||||
thisLogger().warn("Autoprefix-commit plugin is active")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,41 +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
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Handles Git branch name injection into commit messages when the commit dialog is opened
|
|
||||||
*/
|
|
||||||
class BranchNameCheckinHandlerFactory : CheckinHandlerFactory() {
|
|
||||||
|
|
||||||
override fun createHandler(panel: CheckinProjectPanel, commitContext: CommitContext): CheckinHandler {
|
|
||||||
return object : CheckinHandler() {
|
|
||||||
init {
|
|
||||||
(panel.preferredFocusedComponent)?.addFocusListener(object : java.awt.event.FocusAdapter() {
|
|
||||||
override fun focusGained(e: java.awt.event.FocusEvent?) {
|
|
||||||
// update commit message
|
|
||||||
val currentMessage = panel.commitMessage
|
|
||||||
val modifiedMessage = modifyCommitMessage(currentMessage)
|
|
||||||
panel.commitMessage = modifiedMessage
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
fun modifyCommitMessage(message: String): String {
|
|
||||||
val repository = GitRepositoryManager.getInstance(panel.project).repositories.firstOrNull()
|
|
||||||
|
|
||||||
return repository?.let {
|
|
||||||
val branchName = it.currentBranchName
|
|
||||||
if (branchName != null && !message.startsWith("${branchName} ")) {
|
|
||||||
"${it.currentBranchName ?: ""} ${message} "
|
|
||||||
} else {
|
|
||||||
message
|
|
||||||
}
|
|
||||||
} ?: message
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -3,7 +3,7 @@
|
||||||
|
|
||||||
<name>Autoprefix Commit Messages</name>
|
<name>Autoprefix Commit Messages</name>
|
||||||
|
|
||||||
<vendor url="https://www.top-squad.nl">TopSquad</vendor>
|
<vendor url="https://github.com/shautvast">my github profile</vendor>
|
||||||
|
|
||||||
<description><![CDATA[
|
<description><![CDATA[
|
||||||
Automatically adds the branch name to the git commit message.
|
Automatically adds the branch name to the git commit message.
|
||||||
|
|
@ -14,7 +14,6 @@
|
||||||
<depends>Git4Idea</depends>
|
<depends>Git4Idea</depends>
|
||||||
|
|
||||||
<extensions defaultExtensionNs="com.intellij">
|
<extensions defaultExtensionNs="com.intellij">
|
||||||
<!-- <postStartupActivity implementation="nl.topsquad.autoprefixcommit.APCProjectActivity"/>-->
|
<checkinHandlerFactory implementation="com.github.shautvast.autoprefixcommit.BranchNameCheckinHandlerFactory"/>
|
||||||
<checkinHandlerFactory implementation="nl.topsquad.autoprefixcommit.BranchNameCheckinHandlerFactory"/>
|
|
||||||
</extensions>
|
</extensions>
|
||||||
</idea-plugin>
|
</idea-plugin>
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,54 @@
|
||||||
<svg width="40" height="40" viewBox="0 0 40 40" fill="none" xmlns="http://www.w3.org/2000/svg">
|
<svg viewBox="0 0 64 64" xmlns="http://www.w3.org/2000/svg">
|
||||||
<path d="M32.0845 7.94025V4H24.0203V7.9896H16.029V4H7.91553V7.94025H4V36H16.0044V32.0045C16.0058 30.9457 16.4274 29.9308 17.1766 29.1826C17.9258 28.4345 18.9412 28.0143 20 28.0143C21.0588 28.0143 22.0743 28.4345 22.8234 29.1826C23.5726 29.9308 23.9942 30.9457 23.9956 32.0045V36H36V7.94025H32.0845Z"
|
|
||||||
fill="url(#paint0_linear)"/>
|
|
||||||
<defs>
|
<defs>
|
||||||
<linearGradient id="paint0_linear" x1="2.94192" y1="4.89955" x2="37.7772" y2="39.7345"
|
<linearGradient id="branchGrad" x1="0%" y1="0%" x2="100%" y2="100%">
|
||||||
gradientUnits="userSpaceOnUse">
|
<stop offset="0%" style="stop-color:#8C3AED;stop-opacity:1"/>
|
||||||
<stop offset="0.15937" stop-color="#3BEA62"/>
|
<stop offset="100%" style="stop-color:#A855F7;stop-opacity:1"/>
|
||||||
<stop offset="0.5404" stop-color="#3C99CC"/>
|
</linearGradient>
|
||||||
<stop offset="0.93739" stop-color="#6B57FF"/>
|
<linearGradient id="circleGrad" x1="0%" y1="0%" x2="100%" y2="100%">
|
||||||
|
<stop offset="0%" style="stop-color:#000;stop-opacity:0"/>
|
||||||
|
<stop offset="100%" style="stop-color:#A855F7;stop-opacity:1"/>
|
||||||
|
</linearGradient>
|
||||||
|
<linearGradient id="commitGrad" x1="0%" y1="0%" x2="100%" y2="100%">
|
||||||
|
<stop offset="0%" style="stop-color:#10B981;stop-opacity:1"/>
|
||||||
|
<stop offset="100%" style="stop-color:#14B8A6;stop-opacity:1"/>
|
||||||
</linearGradient>
|
</linearGradient>
|
||||||
</defs>
|
</defs>
|
||||||
|
|
||||||
|
<!-- Subtle background -->
|
||||||
|
<circle cx="32" cy="32" r="30" fill="url(#circleGrad)" opacity="0.2"/>
|
||||||
|
|
||||||
|
<!-- Git branch with gentle curves -->
|
||||||
|
<g transform="translate(-4, 0)">
|
||||||
|
<!-- Main branch line -->
|
||||||
|
<line x1="18" y1="20" x2="18" y2="44" stroke="url(#branchGrad)" stroke-width="2.5" stroke-linecap="round"/>
|
||||||
|
|
||||||
|
<!-- Branch line with curve -->
|
||||||
|
<path d="M 18 28 Q 24 28, 28 32 L 28 40" stroke="url(#branchGrad)" stroke-width="2.5" stroke-linecap="round"
|
||||||
|
fill="none"/>
|
||||||
|
|
||||||
|
<!-- Branch nodes -->
|
||||||
|
<circle cx="18" cy="20" r="4" fill="url(#branchGrad)"/>
|
||||||
|
<circle cx="18" cy="44" r="4" fill="url(#branchGrad)"/>
|
||||||
|
<circle cx="28" cy="40" r="4" fill="url(#branchGrad)"/>
|
||||||
|
</g>
|
||||||
|
|
||||||
|
|
||||||
|
<!-- Commit message card -->
|
||||||
|
<g transform="translate(36, 22)">
|
||||||
|
<!-- Subtle shadow -->
|
||||||
|
<rect x="0.5" y="0.5" width="20" height="20" rx="2" fill="#000" opacity="0.1"/>
|
||||||
|
<!-- Card with gradient -->
|
||||||
|
<rect x="0" y="0" width="20" height="20" rx="2" fill="url(#commitGrad)" opacity="0.85"/>
|
||||||
|
<!-- Text lines -->
|
||||||
|
<line x1="3" y1="5" x2="13" y2="5" stroke="#FFF" stroke-width="1.5" stroke-linecap="round" opacity="0.9"/>
|
||||||
|
<line x1="3" y1="8.5" x2="11" y2="8.5" stroke="#FFF" stroke-width="1.5" stroke-linecap="round" opacity="0.75"/>
|
||||||
|
<line x1="3" y1="12" x2="8" y2="12" stroke="#FFF" stroke-width="1.5" stroke-linecap="round" opacity="0.6"/>
|
||||||
|
</g>
|
||||||
|
|
||||||
|
<!-- Arrow indicating automation -->
|
||||||
|
<g transform="translate(26, 30)">
|
||||||
|
<path d="M 0 0 L 10 0 M 7 -3 L 10 0 L 7 3" opacity="0.5" stroke="#000981" stroke-width="2.5"
|
||||||
|
stroke-linecap="round" stroke-linejoin="round" fill="none"/>
|
||||||
|
</g>
|
||||||
|
|
||||||
</svg>
|
</svg>
|
||||||
|
Before Width: | Height: | Size: 818 B After Width: | Height: | Size: 2.5 KiB |
Loading…
Add table
Reference in a new issue