fix(init): fix handling of gitlab repos#7945
Conversation
📊 Benchmark resultsComparing with 5585c33
|
* ci: create integration test sites in testing account This [mechanism already exists](https://github.com/netlify/cli/blob/b80b98f85929803fc35a08458c9327dc7ef63de0/tests/integration/utils/create-live-test-site.ts#L22-L36) but wasn't being used here, so it was falling back to the first account the user has access to that is returned by the accounts API. The `netlify-integration-testing` account is properly configured to host our various integration test sites, e.g. to avoid being rate limited. * ci: try DEBUG_TESTS=1 * Revert "ci: try DEBUG_TESTS=1" This reverts commit 2d186bf. * chore: bump deploy integration test timeout and concurrency
* feat: begin integrating `@netlify/dev` * chore: add deps * fix(deps): bump netlify packages to dedupe with @netlify/dev * chore: update deps * chore: fix lint issue * chore: add debug logging * chore: add comment Co-authored-by: Philippe Serhal <philippe.serhal@netlify.com> * chore: cap site name length in tests * chore: update snapshot --------- Co-authored-by: Philippe Serhal <philippe.serhal@netlify.com>
* feat: deprecate sites:create-template * chore: format * chore: lint * docs: build docs * fix: claude says this is how we fix the PR title lint issue * fix: lol now claude says this will work * remove this * remove unneeded issuePrefixes that claude added * fix: remove a bit more dead code * fix: remove sites:create-template placeholder cmd --------- Co-authored-by: Philippe Serhal <philippe.serhal@netlify.com>
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
📝 WalkthroughWalkthroughThis PR updates Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Suggested reviewers
🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@tests/unit/utils/get-repo-data.test.ts`:
- Around line 8-119: The tests are self-fulfilling because they construct
RepoData literals and assert those same values; update each spec to call the
real getRepoData function instead of building RepoData objects so
parsing/normalization is exercised. Replace the mockRepoData literals with calls
to getRepoData(...) (or the exported function that returns RepoData) using the
raw git URL/branch/name inputs from each case (e.g.,
'git@github.com:ownername/test.git', 'https://gitlab.com/...', custom host,
etc.), then assert on returnedRepo.httpsUrl, returnedRepo.provider and
returnedRepo.repo to validate behavior. Ensure you import getRepoData and keep
the same expected strings in assertions.
In `@tests/unit/utils/init/config-manual.test.ts`:
- Around line 41-45: The test is failing due to an unsafe direct cast of the
Netlify `config` property; locate the object literal assigned to
`netlify.config` in tests/unit/utils/init/config-manual.test.ts and change the
cast so the provided `{ plugins: [] }` is first cast to `unknown` and then to
the required `CachedConfig['config']` (or BaseCommand['netlify']['config']) type
instead of a direct cast; this preserves the intended test shape while
satisfying TypeScript's structural checks for `build` and other required
properties referenced by `CachedConfig['config']`.
ℹ️ Review info
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Disabled knowledge base sources:
- Linear integration is disabled
You can enable these sources in your CodeRabbit configuration.
⛔ Files ignored due to path filters (1)
package-lock.jsonis excluded by!**/package-lock.json
📒 Files selected for processing (3)
src/utils/init/config-manual.tstests/unit/utils/get-repo-data.test.tstests/unit/utils/init/config-manual.test.ts
Rewrite get-repo-data tests to drive the real getRepoData function with mocked git deps so parsing and provider mapping are actually exercised, and fix the unsafe direct cast on netlify.config in the config-manual test by routing it through unknown. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
… handle telemetry errors silently
…to sarahetter/gitlab
There was a problem hiding this comment.
🧹 Nitpick comments (1)
tests/integration/commands/init/init.test.ts (1)
84-95: GitLab provider is tested in unit tests; consider adding an integration test for end-to-end validation.GitLab repository handling is thoroughly tested in
tests/unit/utils/init/config-manual.test.tswith unit tests verifying provider inference and repo_path formatting. However, there are no integration tests demonstrating the fullnetlify init --manualworkflow with a GitLab remote. While the existing unit test coverage is comprehensive, an integration test would provide end-to-end validation that the CLI command succeeds with GitLab remotes and correctly displays webhooks.If you add a GitLab integration test, verify:
- GitLab remote URL is correctly detected and provider is inferred as
'gitlab'- PATCH payload contains
provider: 'gitlab'andrepo_path: 'owner/repo'- Webhook configuration works for GitLab
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@tests/integration/commands/init/init.test.ts` around lines 84 - 95, Add a new integration test case in the init.test.ts file that mirrors the existing GitHub provider test but validates the complete end-to-end workflow with a GitLab remote. Create a test that verifies the netlify init --manual command correctly detects a GitLab remote URL, infers the provider as 'gitlab', and sends a PATCH request with provider set to 'gitlab' and repo_path formatted as 'owner/repo'. Ensure the test also validates that webhook configuration is properly established for GitLab, similar to how the existing GitHub test case (shown in the requestBody structure) validates the full workflow.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@tests/integration/commands/init/init.test.ts`:
- Around line 84-95: Add a new integration test case in the init.test.ts file
that mirrors the existing GitHub provider test but validates the complete
end-to-end workflow with a GitLab remote. Create a test that verifies the
netlify init --manual command correctly detects a GitLab remote URL, infers the
provider as 'gitlab', and sends a PATCH request with provider set to 'gitlab'
and repo_path formatted as 'owner/repo'. Ensure the test also validates that
webhook configuration is properly established for GitLab, similar to how the
existing GitHub test case (shown in the requestBody structure) validates the
full workflow.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 617ef400-cc61-42ae-96fe-1ecbcb887df2
📒 Files selected for processing (1)
tests/integration/commands/init/init.test.ts
🔗 Linked repositories identified
CodeRabbit considers these linked repositories for cross-repo context during reviews:
netlify/blueprints(manual)
🎉 Thanks for submitting a pull request! 🎉
Summary
Fixes #3771
Also not described in the issue was that we weren't displaying the correct webhook for gitlab users to add manually since we were passing through
manualinstead ofgitlab- now it actually showsConfigure the following webhook for your repository: https://api.netlify.com/hooks/gitlabas it should (and was in the code, just wasn't being exercised).For us to review and ship your PR efficiently, please perform the following steps:
passes our tests.
A picture of a cute animal (not mandatory, but encouraged)
