fix(cli): remove .git folder when creating project from git template#13239
Open
OlegHQ wants to merge 2 commits intoserverless:mainfrom
Open
fix(cli): remove .git folder when creating project from git template#13239OlegHQ wants to merge 2 commits intoserverless:mainfrom
OlegHQ wants to merge 2 commits intoserverless:mainfrom
Conversation
When using `--template-url` with a plain Git URL (e.g., [email protected]:... or https://example.com/repo.git), the template is cloned via git clone. Previously, the .git folder was left in the new project, causing it to point to the template repository instead of being a fresh project. This change: - Adds git clone support for plain Git URLs (both HTTPS and SSH) - Removes the .git folder after cloning to disassociate from template repo - Handles SSH URLs (git@...) that cannot be parsed as standard URLs - Adds test coverage for the new git clone and .git removal behavior Fixes serverless#11978
- Replace child_process.exec() with spawn() using array arguments - Add input validation to reject URLs with shell metacharacters - Remove console.error in favor of silent error handling - Add test for command injection prevention
|
All contributors have signed the CLA ✍️ ✅ |
Contributor
✅ Snyk checks have passed. No issues have been found so far.
💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse. |
Author
|
I have read the CLA Document and I hereby sign the CLA |
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.
When creating a project from a git template URL, the
.gitfolder is copied to the new project, causing git to track the template repository instead of being ready for a new repository.This change removes the
.gitfolder after cloning the template, so the new project starts fresh without any git history.Verification
Environment: Darwin (arm64)
Runtime: Node.js v24.11.1
Test Steps
npm installnpm run test:unit -w @serverlessinc/sf-core -- --testPathPattern=download.testResults
Test Suites: 24 passed, 24 total
Tests: 368 passed, 368 total
All unit tests pass, including new tests that verify the
.gitfolder removal behavior.Closes: #11978