Skip to content

fix(init): fix handling of gitlab repos#7945

Open
sarahetter wants to merge 26 commits into
mainfrom
sarahetter/gitlab
Open

fix(init): fix handling of gitlab repos#7945
sarahetter wants to merge 26 commits into
mainfrom
sarahetter/gitlab

Conversation

@sarahetter

Copy link
Copy Markdown
Contributor

🎉 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 manual instead of gitlab - now it actually shows Configure the following webhook for your repository: https://api.netlify.com/hooks/gitlab as 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:

  • Open a bug/issue before writing your code 🧑‍💻. This ensures we can discuss the changes and get feedback from everyone that should be involved. If you`re fixing a typo or something that`s on fire 🔥 (e.g. incident related), you can skip this step.
  • Read the contribution guidelines 📖. This ensures your code follows our style guide and
    passes our tests.
  • Update or add tests (if any source code was changed or added) 🧪
  • Update or add documentation (if features were changed or added) 📝
  • Make sure the status checks below are successful ✅

A picture of a cute animal (not mandatory, but encouraged)
image

@sarahetter sarahetter requested a review from a team as a code owner February 13, 2026 15:01
@github-actions

github-actions Bot commented Feb 13, 2026

Copy link
Copy Markdown

📊 Benchmark results

Comparing with 5585c33

  • Dependency count: 1,127 (no change)
  • Package size: 379 MB (no change)
  • Number of ts-expect-error directives: 352 (no change)

jaredm563
jaredm563 previously approved these changes Feb 18, 2026
Comment thread src/utils/init/config-manual.ts Outdated
serhalp and others added 5 commits February 23, 2026 13:12
* 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>
@sarahetter sarahetter requested a review from a team as a code owner February 23, 2026 18:12
@coderabbitai

coderabbitai Bot commented Feb 23, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Note

Reviews paused

It 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 reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

This PR updates src/utils/init/config-manual.ts to accept repoData.repo as a repo_path override (falling back to getRepoPath({ repoData })) and to set repo.provider from repoData.provider only when it is 'github' or 'gitlab' (otherwise 'manual'). It adds unit tests: tests/unit/utils/get-repo-data.test.ts (remote URL parsing/provider inference) and tests/unit/utils/init/config-manual.test.ts (config-manual setupSite assertions). Integration test payloads are updated to expect GitHub provider metadata. It also removes bold styling around @netlify/database in db-status output, wraps a detached execa call in report-error with try/catch, and adds a test teardown to unstub globals.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

  • netlify/cli#8209: Overlaps changes to src/utils/telemetry/report-error.ts — both PRs modify error-reporting child-process behavior.

Suggested reviewers

  • serhalp
🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Out of Scope Changes check ⚠️ Warning Changes to db-status.ts (removing bold styling) and report-error.ts (adding try/catch) are incidental improvements unrelated to the GitLab URL parsing fix. Remove unrelated changes to db-status.ts and report-error.ts, or include them in a separate PR with corresponding linked issues and justification.
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title 'fix(init): fix handling of gitlab repos' directly addresses the main objective of fixing GitLab repository URL parsing, which is the core change demonstrated across multiple test and source files.
Description check ✅ Passed The description is related to the changeset, referencing issue #3771 and explaining the webhook display fix for GitLab users, which aligns with the code changes.
Linked Issues check ✅ Passed The PR addresses the primary objective from issue #3771 by fixing GitLab repo URL parsing through improved provider detection and repo_path construction in config-manual.ts and corresponding tests.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch sarahetter/gitlab

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

📥 Commits

Reviewing files that changed from the base of the PR and between 2453221 and ebc8b07.

⛔ Files ignored due to path filters (1)
  • package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (3)
  • src/utils/init/config-manual.ts
  • tests/unit/utils/get-repo-data.test.ts
  • tests/unit/utils/init/config-manual.test.ts

Comment thread tests/unit/utils/get-repo-data.test.ts
Comment thread tests/unit/utils/init/config-manual.test.ts
@serhalp serhalp changed the title feat: fix handling of gitlab repos fix(init): fix handling of gitlab repos Mar 2, 2026
sarahetter and others added 4 commits March 31, 2026 09:46
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>
@sarahetter sarahetter requested a review from a team May 5, 2026 19:37
jaredm563
jaredm563 previously approved these changes Jun 9, 2026

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 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.ts with unit tests verifying provider inference and repo_path formatting. However, there are no integration tests demonstrating the full netlify init --manual workflow 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:

  1. GitLab remote URL is correctly detected and provider is inferred as 'gitlab'
  2. PATCH payload contains provider: 'gitlab' and repo_path: 'owner/repo'
  3. 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

📥 Commits

Reviewing files that changed from the base of the PR and between c31135d and 94f015a.

📒 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)

@jaredm563 jaredm563 requested a review from a team June 16, 2026 21:20
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.

GitLab repo URL not being parsed correctly

4 participants