Skip to content

bbugdigger/BranchScope

Repository files navigation

Branch Scope logo

Branch Scope

Scope the IntelliJ project view to files modified in your current branch.

Open the Project view selector and pick Branch Modified Files to focus the tree on exactly the files that make up your work-in-progress branch — commits on top of the base branch plus uncommitted edits and new untracked files. Treat it as the project view of your pull request.

Features

  • "Branch Modified Files" entry in the Project view selector dropdown, alongside Project, Production, Tests, Open Files and All Changed Files. Powered by a custom NamedScope.
  • Smart base-branch detection. The diff base is the merge-base of HEAD with origin/HEADmainmasterdevelop, in that order. Override per project from settings if your team uses a different base.
  • Committed + uncommitted + untracked. Files that you committed on this branch, files staged or modified in the working tree, and untracked-but-not-ignored files all appear in the same view.
  • VCS status colors everywhere. A ProjectViewNodeDecorator paints branch-modified files with IntelliJ's standard green/blue file-status colors in every project view pane, so you can spot them at a glance even from the regular Project view.
  • Auto-refresh. The view recomputes on Git repository state changes (commits, checkouts, fetches) and on working-tree updates from ChangeListManager. Updates are debounced.
  • Public-API only. No com.intellij.*.impl.* types and no @ApiStatus.Internal usage — the plugin should remain compatible with future IntelliJ versions without binary breakage.

Install

Requires IntelliJ Platform 2026.1 or newer. The plugin depends on the bundled Git integration (Git4Idea), which ships with all IntelliJ-based IDEs.

From disk (current local-build flow):

  1. Build the plugin ZIP:
    ./gradlew buildPlugin
    On Windows: ./gradlew.bat buildPlugin. The artifact lands at build/distributions/BranchScope-1.0.0-SNAPSHOT.zip.
  2. In IntelliJ IDEA: Settings → Plugins → ⚙ → Install Plugin from Disk… and pick the ZIP.

A JetBrains Marketplace listing is in preparation.

Usage

  1. Open a Git project and check out a feature branch with at least one change vs. main / master / develop.
  2. In the Project tool window, click the pane selector (the one that defaults to Project) and choose Branch Modified Files.
  3. The tree collapses to just the files in your branch's diff. Status colors mark them as added / modified / etc.

The view updates automatically as you commit, switch branches, edit, or run git fetch.

Settings

Under Settings → Tools → Branch Scope:

  • Base branchauto for automatic detection (recommended), or a specific ref name like develop, release/v3, or origin/staging.
  • Include uncommitted working-tree changes — on by default. Turn off to see only files that are part of your branch's commit history.

How it works

On project open and on every relevant VCS event, a project-level service runs:

mergeBase = git merge-base HEAD <baseBranch>
fileSet   = git diff --name-status -M <mergeBase>          # working tree vs base, when "include uncommitted" is on
        ∪   ChangeListManager.unversionedFilesPaths        # untracked files
        OR
fileSet   = git diff --name-status -M <mergeBase>..HEAD    # committed-only, when "include uncommitted" is off

The result is published as a snapshot consumed by:

  • BranchScopePackageSet — the PackageSetBase whose contains(...) is queried by IntelliJ's project-view scope filter.
  • BranchScopeNodeDecorator — the ProjectViewNodeDecorator that colors branch-modified files in every pane.

After each recompute, the service fires NamedScopeManager.fireScopeListeners() and ProjectView.refresh() so cached scope membership is invalidated.

Build from source

Requires JDK 21 (matches the JBR shipped with 2026.1).

./gradlew clean test            # unit + IntelliJ-fixture tests
./gradlew runIde                # spin up a sandbox IDE with the plugin
./gradlew buildPlugin           # produce the marketplace ZIP
./gradlew verifyPlugin          # run the plugin verifier

The IDE version targeted by runIde is set in build.gradle.kts (intellijIdea("2026.1.1")).

Limitations / known issues

  • The scope can only filter files that exist on disk, so files deleted in the branch don't appear in the tree. Their absence from the view is by design of NamedScope.
  • On very large repos with thousands of modified files, the first git diff may take a beat to populate; the project view stays empty until that finishes.

License

MIT.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages