Skip to content

Commit 1189812

Browse files
committed
fix(prompts): prompt does not contain diff for new files
Closes #244
1 parent 534f78f commit 1189812

File tree

3 files changed

+15
-5
lines changed

3 files changed

+15
-5
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@
66

77
- Option to choose prompt per project.
88

9+
### Fixed
10+
11+
- Prompt does not contain diff for new files.
12+
913
## [2.3.1] - 2024-09-11
1014

1115
### Fixed

src/main/kotlin/com/github/blarc/ai/commits/intellij/plugin/AICommitsExtensions.kt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ package com.github.blarc.ai.commits.intellij.plugin
22

33
import com.github.blarc.ai.commits.intellij.plugin.AICommitsBundle.message
44
import com.intellij.openapi.ui.ValidationInfo
5+
import com.intellij.openapi.vcs.FilePath
6+
import com.intellij.openapi.vcs.changes.Change
57
import com.intellij.ui.dsl.builder.Cell
68
import com.intellij.ui.layout.ValidationInfoBuilder
79
import com.intellij.util.ui.ColumnInfo
@@ -71,3 +73,7 @@ fun String.wrap(length: Int): String {
7173

7274
return wrapped.toString()
7375
}
76+
77+
fun Change.filePath(): FilePath? {
78+
return afterRevision?.file ?: beforeRevision?.file
79+
}

src/main/kotlin/com/github/blarc/ai/commits/intellij/plugin/AICommitsUtils.kt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import java.nio.file.FileSystems
2222
object AICommitsUtils {
2323

2424
fun isPathExcluded(path: String, project: Project): Boolean {
25-
return !AppSettings2.instance.isPathExcluded(path) && !project.service<ProjectSettings>().isPathExcluded(path)
25+
return AppSettings2.instance.isPathExcluded(path) || project.service<ProjectSettings>().isPathExcluded(path)
2626
}
2727

2828
fun matchesGlobs(text: String, globs: Set<String>): Boolean {
@@ -98,14 +98,14 @@ object AICommitsUtils {
9898
// go through included changes, create a map of repository to changes and discard nulls
9999
val changesByRepository = includedChanges
100100
.filter {
101-
it.virtualFile?.path?.let { path ->
102-
isPathExcluded(path, project)
101+
it.filePath()?.path?.let { path ->
102+
!isPathExcluded(path, project)
103103
} ?: false
104104
}
105105
.mapNotNull { change ->
106-
change.virtualFile?.let { file ->
106+
change.filePath()?.let { filePath ->
107107
gitRepositoryManager.getRepositoryForFileQuick(
108-
file
108+
filePath
109109
) to change
110110
}
111111
}

0 commit comments

Comments
 (0)