-
Notifications
You must be signed in to change notification settings - Fork 2
fix: remove getting skipped files popup #68
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
0bfd15c
Do not show popup when fetching skipped worktree
monosoul 757a86f
Refresh ChangesView when calling a git update index command
monosoul d427934
Make SkippedWorktreeFilesCache thread safe
monosoul 0cd0d2d
rename files to follow conventions
monosoul dea7c08
Use IO dispatcher since call to git is blockig
monosoul 744e4f1
Mark getSkippedWorktreeFiles fun as blocking
monosoul File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
...tlin/com/github/monosoul/git/updateindex/extended/changes/view/GetSkippedWorktreeFiles.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,43 @@ | ||
| package com.github.monosoul.git.updateindex.extended.changes.view | ||
|
|
||
| import com.github.monosoul.git.updateindex.extended.changes.view.Constants.SKIPPED_FILE | ||
| import com.intellij.externalProcessAuthHelper.AuthenticationMode.NONE | ||
| import com.intellij.openapi.project.Project | ||
| import com.intellij.openapi.vcs.FilePath | ||
| import com.intellij.openapi.vcs.ProjectLevelVcsManager | ||
| import com.intellij.openapi.vcs.VcsException | ||
| import com.intellij.openapi.vcs.VcsRoot | ||
| import com.intellij.vcsUtil.VcsUtil | ||
| import git4idea.GitUtil | ||
| import git4idea.commands.Git | ||
| import git4idea.commands.GitCommand.LS_FILES | ||
| import git4idea.commands.GitCommandResult | ||
| import git4idea.commands.GitLineHandler | ||
| import org.jetbrains.annotations.Blocking | ||
|
|
||
| @Blocking | ||
| fun getSkippedWorktreeFiles(project: Project): List<FilePath> { | ||
| val vcsManager = ProjectLevelVcsManager.getInstance(project) ?: return emptyList() | ||
|
|
||
| return vcsManager.allVcsRoots.map(VcsRoot::getPath).map { vcsRoot -> | ||
| GitLineHandler(project, vcsRoot, LS_FILES).apply { | ||
| addParameters("-v") | ||
| ignoreAuthenticationMode = NONE | ||
| }.let(Git.getInstance()::runCommand).mapOrThrow { result -> | ||
| result.filter { | ||
| it.startsWith(SKIPPED_FILE) | ||
| }.map { | ||
| it.removePrefix("$SKIPPED_FILE ") | ||
| }.map { | ||
| VcsUtil.getFilePath(vcsRoot, GitUtil.unescapePath(it)) | ||
| } | ||
| } | ||
| }.flatten() | ||
| } | ||
|
|
||
| @Throws(VcsException::class) | ||
| private fun <T> GitCommandResult.mapOrThrow(mapper: (List<String>) -> T): T { | ||
| throwOnError() | ||
|
|
||
| return mapper(output) | ||
| } |
48 changes: 0 additions & 48 deletions
48
.../com/github/monosoul/git/updateindex/extended/changes/view/GetSkippedWorktreeFilesTask.kt
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
67 changes: 67 additions & 0 deletions
67
...in/com/github/monosoul/git/updateindex/extended/changes/view/SkippedWorktreeFilesCache.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,67 @@ | ||
| package com.github.monosoul.git.updateindex.extended.changes.view | ||
|
|
||
| import com.intellij.openapi.components.Service | ||
| import com.intellij.openapi.components.service | ||
| import com.intellij.openapi.diagnostic.logger | ||
| import com.intellij.openapi.project.Project | ||
| import com.intellij.openapi.util.Disposer | ||
| import com.intellij.openapi.vcs.FilePath | ||
| import com.intellij.openapi.vcs.changes.ChangesViewManager | ||
| import com.intellij.platform.ide.progress.withBackgroundProgress | ||
| import kotlinx.coroutines.CoroutineScope | ||
| import kotlinx.coroutines.Dispatchers | ||
| import kotlinx.coroutines.ExperimentalCoroutinesApi | ||
| import kotlinx.coroutines.SupervisorJob | ||
| import kotlinx.coroutines.cancel | ||
| import kotlinx.coroutines.launch | ||
| import java.util.concurrent.atomic.AtomicReference | ||
|
|
||
| @Service(Service.Level.PROJECT) | ||
| class SkippedWorktreeFilesCache(private val project: Project) { | ||
|
|
||
| @OptIn(ExperimentalCoroutinesApi::class) | ||
| private val scope = CoroutineScope(SupervisorJob() + Dispatchers.IO.limitedParallelism(1)) | ||
| private val cachedFiles = AtomicReference<List<FilePath>?>(null) | ||
|
|
||
| init { | ||
| Disposer.register(project) { scope.cancel() } | ||
| } | ||
|
|
||
| fun getOrLoad(): List<FilePath>? { | ||
| val cached = cachedFiles.get() | ||
| if (cached != null) { | ||
| return cached | ||
| } | ||
|
|
||
| scope.launch { | ||
| try { | ||
| val files = withBackgroundProgress(project, "Getting Skipped Files", cancellable = false) { | ||
| getSkippedWorktreeFiles(project) | ||
| } | ||
| cachedFiles.set(files) | ||
| ChangesViewManager.getInstanceEx(project).scheduleRefresh() | ||
| } catch (e: Exception) { | ||
| logger.warn("Failed to load skipped worktree files", e) | ||
| } | ||
| } | ||
monosoul marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| return null | ||
| } | ||
|
|
||
| fun clear() { | ||
| cachedFiles.set(null) | ||
| } | ||
|
|
||
| /** | ||
| * For testing purposes: set cached files directly without async loading | ||
| */ | ||
| internal fun setCachedFiles(files: List<FilePath>) { | ||
monosoul marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| cachedFiles.set(files) | ||
| } | ||
|
|
||
| companion object { | ||
| private val logger = logger<SkippedWorktreeFilesCache>() | ||
|
|
||
| fun getInstance(project: Project): SkippedWorktreeFilesCache = project.service() | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.