Skip to content

fix(cli): handle #ref fragments in GitHub template URLs for vp create - #3610

Open
CoderSerio wants to merge 1 commit into
voidzero-dev:mainfrom
CoderSerio:fix/create-github-ref
Open

CoderSerio wants to merge 1 commit into
voidzero-dev:mainfrom
CoderSerio:fix/create-github-ref

Conversation

@CoderSerio

Copy link
Copy Markdown

When passing a GitHub template with a branch or tag fragment (#ref) to vp create, two edge cases previously broke template resolution and default project directory inference:

  1. parseGitHubUrl() matched /github\.com\/([^/]+\/[^/]+)/ on the raw HTTPS URL before splitting #ref:
    • Slash-containing branch names like https://github.com/user/repo#feat/auth were truncated at the / inside the branch ref (user/repo#feat).
    • .git suffixes before #ref (e.g. https://github.com/user/repo.git#v2.0.0) were not stripped because .replace(/\.git$/, '') ran on the string still ending with #v2.0.0.
  2. inferGitHubRepoName() called degitPath.split('/').pop() without stripping #ref, inferring 'fate-template#v2.0.0' for github:nkzw-tech/fate-template#v2.0.0 and 'auth' for github:nkzw-tech/fate-template#feat/auth.

This change separates any #ref fragment before matching/stripping .git in parseGitHubUrl(), strips #ref (along with trailing slashes and .git) before inferring the repository name in inferGitHubRepoName(), and adds unit test assertions in discovery.spec.ts.

This branch has not been deployed

No deployments
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