Skip to content

feat: resolve target repo from active editor and submodules#20

Open
plungarini wants to merge 3 commits into
anhthang:developfrom
plungarini:feature/submodule-aware-repo-discovery
Open

feat: resolve target repo from active editor and submodules#20
plungarini wants to merge 3 commits into
anhthang:developfrom
plungarini:feature/submodule-aware-repo-discovery

Conversation

@plungarini
Copy link
Copy Markdown

Closes #19

Replaces the showWorkspaceFolderPick-based selectRepo with a resolver backed by the vscode.git extension API. This fixes the long-standing issue where gitflow commands always targeted the top-level repository, even when the user was working inside a submodule.

Resolution order

  1. Repository owning the currently focused editor.
  2. Single-repo workspace, that one.
  3. QuickPick over all repos and submodules when ambiguous.

Why the previous implementation didn't work for submodules

vscode.window.showWorkspaceFolderPick only enumerates workspace folders, so submodules are invisible to it. It also only fires when there are 2+ workspace folders, meaning a typical single-folder workspace with submodules silently fell through to vscode.workspace.rootPath in cmd.ts, which is always the top-level repo.

Manual testing

  • Single-repo workspace, no submodules. No picker, command runs against the repo as before.
  • Workspace with a submodule, active file in the submodule. Command targets the submodule.
  • Workspace with a submodule, no active editor. QuickPick appears listing parent and submodule.
  • User cancels the QuickPick, command aborts silently.

Known related issue, not addressed here

flow.gitDir in src/flow.ts is computed once at module load from vscode.workspace.rootPath. It's used by the in-progress merge tracking file (MERGE_BASE) during feature finish. Same root-cause family but a wider change.

Replaces the showWorkspaceFolderPick-based selectRepo with a resolver
backed by the vscode.git extension API. Resolution order:

1. Repository owning the currently focused editor.
2. Single repository workspace, that one.
3. QuickPick over all repos and submodules when ambiguous.

The previous implementation only fired for multi-root workspaces with
2+ folders, and could never see submodules since showWorkspaceFolderPick
only knows about workspace folders. As a result, commands always
targeted the top-level repo even when the user was working inside a
submodule.

Note: flow.gitDir in flow.ts is still computed at module load from
workspace.rootPath. It is only used by the in-progress merge tracking
file (MERGE_BASE) during feature finish. Out of scope here, will need
a follow-up.

Closes anhthang#19
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.

Repository discovery ignores submodules and active editor selection

1 participant