Add support for triggering workflows in git submodules#597
Open
bpmiranda3099 wants to merge 2 commits into
Open
Add support for triggering workflows in git submodules#597bpmiranda3099 wants to merge 2 commits into
bpmiranda3099 wants to merge 2 commits into
Conversation
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Adds submodule-aware repository detection so triggering a workflow can resolve the correct repo root (or submodule root) instead of relying solely on the workspace folder.
Changes:
- Introduces
submoduleHelper.tsto find the repository/submodule root for a document URI. - Exports
getGitExtensionfor reuse and updates workflow trigger logic to use repository root resolution. - Updates VS Code task problem matcher configuration.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 8 comments.
| File | Description |
|---|---|
| src/git/submoduleHelper.ts | New helper to resolve repo/submodule root for a document path; logs submodule remote. |
| src/git/repository.ts | Exports getGitExtension() so other modules can query VS Code Git repositories. |
| src/commands/triggerWorkflowRun.ts | Uses repo root resolution and computes workflow path relative to that root. |
| .vscode/tasks.json | Switches problem matcher from webpack watch to tsc watch. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+9
to
+13
| const dir = path.dirname(documentPath); | ||
| const cp = await import("child_process"); | ||
| const util = await import("util"); | ||
| const execPromise = util.promisify(cp.exec); | ||
| const {stdout} = await execPromise("git config --get remote.origin.url", {cwd: dir}); |
| for (const repository of git.repositories) { | ||
| const repoPath = repository.rootUri.fsPath; | ||
|
|
||
| if (documentPath.startsWith(repoPath)) { |
Comment on lines
+37
to
+38
| const submodulePath = path.join(repoPath, submodule.path); | ||
| if (documentPath.startsWith(submodulePath)) { |
Comment on lines
+94
to
+96
| const workflowPath = workflowUri.fsPath; | ||
| const repositoryPath = repositoryUri.fsPath; | ||
| const relativeWorkflowPath = workflowPath.substring(repositoryPath.length + 1); |
| const workspaceFolder = vscode.workspace.getWorkspaceFolder(workflowUri); | ||
| if (!workspaceFolder) { | ||
| return; | ||
| let repositoryUri = await getRepositoryRootForDocumentUri(workflowUri); |
Comment on lines
42
to
43
| const gitHubRepoContext = await getGitHubContextForWorkspaceUri(repositoryUri); | ||
| if (!gitHubRepoContext) { |
| const repoPath = repository.rootUri.fsPath; | ||
|
|
||
| if (documentPath.startsWith(repoPath)) { | ||
| await repository.status(); |
| const cp = await import("child_process"); | ||
| const util = await import("util"); | ||
| const execPromise = util.promisify(cp.exec); | ||
| const {stdout} = await execPromise("git config --get remote.origin.url", {cwd: dir}); |
Author
|
Quick follow-up to clean up some of the code review feedback from Copilot. Nothing changes functionally, just made some stuff more robust and cross-platform friendly. Changes
Testing
Let me know if anything needs further adjustment. |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Description
This PR fixes #596 when triggering GitHub Actions workflows located in git submodules. Previously, the extension would fail with a 404 error when attempting to dispatch workflows in submodules, as it would incorrectly route the dispatch to the parent repository instead of the submodule's separate GitHub repository.
Example Structure
When triggering
submodule/.github/workflows/deploy.yml, the extension should dispatch to thesubmodulerepository, not the parentmonoreporepository.Changes
Submodule Detection and Repository Routing
src/git/submoduleHelper.tswithgetRepositoryRootForDocumentUri()helper functionUpdated Imports and Exports
getGitExtension()insrc/git/repository.tsto enable submodule detectionsrc/commands/triggerWorkflowRun.tsto import and use submodule helperImproved Path Calculation
Debug Configuration
.vscode/tasks.jsonfor proper debug task completion$ts-webpack-watchto correct$tsc-watchvalueRelated Issues
Fixes #596
Testing
The fix ensures that: