Compare commits

..

6 commits
v1.2 ... main

Author SHA1 Message Date
Shautvast
485be3e57c new version
Some checks failed
Gradle Build / build (push) Has been cancelled
2025-11-20 15:10:32 +01:00
Shautvast
30a5efb337 add hash 2025-11-20 15:07:53 +01:00
Shautvast
32a5b2be66 update version to 1.3 2025-10-02 15:58:42 +02:00
Shautvast
4cb019ef4a made the code simpler 2025-10-02 15:51:55 +02:00
Shautvast
3ebfa2412e main v1.3 remove the redundant space after the branch name 2025-10-02 15:27:09 +02:00
Sander Hautvast
71b26ffaa4
Create build action 2025-10-02 10:45:57 +02:00
4 changed files with 60 additions and 20 deletions

47
.github/workflows/blank.yml vendored Normal file
View 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/

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 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

View file

@ -5,7 +5,7 @@ plugins {
} }
group = "com.github.shautvast" group = "com.github.shautvast"
version = "1.2" version = "1.4"
repositories { repositories {
mavenCentral() mavenCentral()
@ -20,8 +20,6 @@ dependencies {
testFramework(org.jetbrains.intellij.platform.gradle.TestFrameworkType.Platform) testFramework(org.jetbrains.intellij.platform.gradle.TestFrameworkType.Platform)
bundledPlugin("Git4Idea") bundledPlugin("Git4Idea")
} }
} }
intellijPlatform { intellijPlatform {
@ -33,6 +31,8 @@ intellijPlatform {
changeNotes = """ changeNotes = """
1.1 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.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,25 +19,18 @@ 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 currentMessage = panel.commitMessage val message = panel.commitMessage
val modifiedMessage = modifyCommitMessage(currentMessage) val repository = GitRepositoryManager.getInstance(panel.project).repositories.firstOrNull()
panel.commitMessage = modifiedMessage repository?.let {
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
}
} }
} }
} }