Compare commits

..

No commits in common. "main" and "v1.1" have entirely different histories.
main ... v1.1

5 changed files with 22 additions and 63 deletions

View file

@ -1,47 +0,0 @@
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/

View file

@ -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 #[branchname] in front of any pre-existing text (unless the branch name was already there) * Puts the branch name 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

View file

@ -5,7 +5,7 @@ plugins {
} }
group = "com.github.shautvast" group = "com.github.shautvast"
version = "1.4" version = "1.1"
repositories { repositories {
mavenCentral() mavenCentral()
@ -20,6 +20,8 @@ dependencies {
testFramework(org.jetbrains.intellij.platform.gradle.TestFrameworkType.Platform) testFramework(org.jetbrains.intellij.platform.gradle.TestFrameworkType.Platform)
bundledPlugin("Git4Idea") bundledPlugin("Git4Idea")
} }
} }
intellijPlatform { intellijPlatform {
@ -29,10 +31,7 @@ intellijPlatform {
} }
changeNotes = """ changeNotes = """
1.1 Initial version: insert branchname in commit dialog. No configuration needed. 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()
} }
} }

View file

@ -19,18 +19,25 @@ class BranchNameCheckinHandlerFactory : CheckinHandlerFactory() {
(panel.preferredFocusedComponent)?.addFocusListener(object : FocusAdapter() { (panel.preferredFocusedComponent)?.addFocusListener(object : FocusAdapter() {
override fun focusGained(e: FocusEvent?) { override fun focusGained(e: FocusEvent?) {
// update commit message // update commit message
val message = panel.commitMessage val currentMessage = panel.commitMessage
val repository = GitRepositoryManager.getInstance(panel.project).repositories.firstOrNull() val modifiedMessage = modifyCommitMessage(currentMessage)
repository?.let { panel.commitMessage = modifiedMessage
it.currentBranchName?.let { b ->
if (!message.startsWith(b)) {
panel.commitMessage = "#$b $message"
}
}
}
} }
}) })
} }
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
}
} }
} }
} }

View file

@ -1,5 +1,5 @@
<idea-plugin> <idea-plugin>
<id>nl.top-squad.autoprefix-commit</id> <id>com.github.shautvast.autoprefix-commit</id>
<name>Autoprefix Commit Messages</name> <name>Autoprefix Commit Messages</name>