Skip to content

Commit

Permalink
fix(prompts): prompt does not contain diff for new files
Browse files Browse the repository at this point in the history
Closes #244
  • Loading branch information
Blarc committed Sep 12, 2024
1 parent 534f78f commit 1189812
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 5 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@

- Option to choose prompt per project.

### Fixed

- Prompt does not contain diff for new files.

## [2.3.1] - 2024-09-11

### Fixed
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ package com.github.blarc.ai.commits.intellij.plugin

import com.github.blarc.ai.commits.intellij.plugin.AICommitsBundle.message
import com.intellij.openapi.ui.ValidationInfo
import com.intellij.openapi.vcs.FilePath
import com.intellij.openapi.vcs.changes.Change
import com.intellij.ui.dsl.builder.Cell
import com.intellij.ui.layout.ValidationInfoBuilder
import com.intellij.util.ui.ColumnInfo
Expand Down Expand Up @@ -71,3 +73,7 @@ fun String.wrap(length: Int): String {

return wrapped.toString()
}

fun Change.filePath(): FilePath? {
return afterRevision?.file ?: beforeRevision?.file
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import java.nio.file.FileSystems
object AICommitsUtils {

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

fun matchesGlobs(text: String, globs: Set<String>): Boolean {
Expand Down Expand Up @@ -98,14 +98,14 @@ object AICommitsUtils {
// go through included changes, create a map of repository to changes and discard nulls
val changesByRepository = includedChanges
.filter {
it.virtualFile?.path?.let { path ->
isPathExcluded(path, project)
it.filePath()?.path?.let { path ->
!isPathExcluded(path, project)
} ?: false
}
.mapNotNull { change ->
change.virtualFile?.let { file ->
change.filePath()?.let { filePath ->
gitRepositoryManager.getRepositoryForFileQuick(
file
filePath
) to change
}
}
Expand Down

0 comments on commit 1189812

Please sign in to comment.