Skip to content

Add Analyze Changed Files action for Git-tracked projects - #120

Open
Bazooper-blip wants to merge 1 commit into
integrated-application-development:masterfrom
Bazooper-blip:analyze-changed-files
Open

Add Analyze Changed Files action for Git-tracked projects#120
Bazooper-blip wants to merge 1 commit into
integrated-application-development:masterfrom
Bazooper-blip:analyze-changed-files

Conversation

@Bazooper-blip

Copy link
Copy Markdown

Implements #3: a new Analyze Changed Files action that analyzes every Delphi source file the project's Git repository reports as changed (modified, staged, or untracked), mirroring SonarLint's "Analyze VCS Changed Files".

Changes:

  • New DelphiLint.VersionControl unit. TryGetChangedDelphiFiles runs git rev-parse --show-cdup and git status --porcelain --no-renames (headless, output captured over a pipe, 10s timeout) in the analysis base directory, and returns absolute paths of changed Delphi sources that still exist. The porcelain parsing is a separate pure function covered by unit tests (deleted files excluded, malformed lines skipped, quoted paths unescaped).
  • The repository root is resolved from the relative --show-cdup rather than --show-toplevel, because the latter canonicalizes mapped/substituted drives to physical paths that don't match the IDE's file paths — which would make the analyzer's base-directory filter silently drop every file. (Found this the hard way on a subst'd drive.)
  • New ActionAnalyzeChangedFiles in the plugin, wired into the DelphiLint main menu, the tool window's popup menu, IDE Insight, and toolbar customization/cleanup, with the same enablement rules as the other analyze actions. "Save before analysis" saves only open editors whose files are in the changed set.
  • If the project isn't in a Git repository (or git isn't on the PATH), the action shows the same style of message dialog as the existing "no open project" cases.

Design choices to sanity-check in review:

  • Git-only, via the PATH git executable, rather than the ToolsAPI version-control services — simpler, and matches what most git-based tooling does; other VCSes could be added behind the same function later.
  • Untracked files are included, since they're the classic "about to be committed for the first time" case.
  • The action stays enabled even when the project isn't in a repository (checking would mean running git on every action-state refresh); clicking explains why nothing can be analyzed.

Testing: new DelphiLintTest.VersionControl DUnitX fixture for the porcelain parsing (4 tests, all passing; full suite passes at the same rate as master). The git integration itself was exercised end-to-end with a console harness against a real repository — from the repo root, from subdirectories, on a substituted drive, and against a non-repository directory. I have not yet exercised the action inside the IDE itself.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant