fix: resolve default branch instead of hardcoding main/master#406
Open
kjanat wants to merge 3 commits intovercel-labs:mainfrom
Open
fix: resolve default branch instead of hardcoding main/master#406kjanat wants to merge 3 commits intovercel-labs:mainfrom
kjanat wants to merge 3 commits intovercel-labs:mainfrom
Conversation
- Use git ls-remote --symref via simple-git to detect default branch - Fix update URL to use GitHub shorthand instead of /tree/main/ - Fix simple-git .env() API usage in cloneRepo - Fall back to main/master with stderr warning if resolution fails
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.
Summary
skills updatefailed against a real repo (kjanat/paperless-mcp) because the reinstall path was rebuilt with a hardcoded/tree/main/..., while the repo’s default branch ismaster.The only user-facing message was:
✗ Failed to update ...…which gave no actionable reason.
This PR fixes that specific failure and makes branch handling more robust across update/hash paths so repos using non-standard default branches (
master,develop,trunk, etc.) work correctly.Closes #373.
Reproduction / observed behavior
skills checkreported an update forpaperless-ngxskills updateconsistently failed with:✗ Failed to update paperless-ngxfatal: Remote branch main not found in upstream origingit ls-remote --symref https://github.com/kjanat/paperless-mcp.git HEADref: refs/heads/master HEADRoot causes
src/cli.ts(runUpdate) rebuilt install URLs using a hardcoded/tree/main/...src/skill-lock.ts(fetchSkillFolderHash) only triedmain/master, which is brittle for repos with other default branchesChanges
src/git.tsresolveDefaultBranch()usinggit ls-remote --symref <repo> HEAD(via existingsimple-git)parseSymrefOutput()as a pure parser for easier testing.env()usage incloneRepo(constructor env was not being applied as intended)src/skill-lock.tsfetchSkillFolderHash()now resolves the actual default branch firstmain/masterand emit a warningsrc/cli.tsrunUpdate()now uses GitHub shorthand (owner/repo/path) instead of constructing/tree/main/..., so clone/install follows the repo’s default branch naturallyremoveswitch casesrc/remove.ts_detectInstalledAgentsDI hook inRemoveOptionsfor deterministic tests withoutvi.mock()Tests
tests/resolve-default-branch.test.tssymrefoutputtests/remove-canonical.test.tsvi.mock()to DI for better compatibility with plain Node executionTooling
package.jsonpnpm.onlyBuiltDependenciesforesbuildTesting
pnpm run exec:test— 17/17 passingpnpm test— 346/346 passing