Skip to content

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

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

fix(init): fix handling of gitlab repos#7945
sarahetter wants to merge 21 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 392af83

  • Dependency count: 1,127 (no change)
  • Package size: 379 MB (no change)
  • Number of ts-expect-error directives: 354 (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

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: e8deedb5-54d3-454c-a29b-5910f01f7349

📥 Commits

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

⛔ Files ignored due to path filters (1)
  • package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (3)
  • src/commands/database/db-status.ts
  • src/utils/telemetry/report-error.ts
  • tests/unit/commands/database/db-status.test.ts
🔗 Linked repositories identified

CodeRabbit considers these linked repositories for cross-repo context during reviews:

  • netlify/blueprints (manual)
✅ Files skipped from review due to trivial changes (1)
  • src/commands/database/db-status.ts

📝 Walkthrough

Summary by CodeRabbit

  • Bug Fixes

    • Improved repository configuration detection to use provided platform information when available, with fallback to manual entry.
    • Enhanced error reporting robustness with added exception handling.
  • Style

    • Adjusted database status output formatting for consistency.
  • Tests

    • Added comprehensive test coverage for repository data parsing and configuration workflows.
    • Improved test suite cleanup procedures.

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). 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) | ⏱️ ~20 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 | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
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 (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely summarizes the main objective of the PR: fixing handling of GitLab repositories in the init flow.
Description check ✅ Passed The description relates directly to the changeset by explaining issue #3771 fix and the webhook display correction for GitLab users.
Linked Issues check ✅ Passed Changes address #3771 requirements: repository URL parsing is fixed via updated repoPath resolution logic in config-manual.ts, and GitLab webhook display is corrected by setting provider from repoData.provider instead of hardcoding 'manual'.
Out of Scope Changes check ✅ Passed All changes are directly related to the GitLab URL parsing fix and webhook display issue; peripheral updates to db-status.ts styling and report-error.ts error handling are minor and reasonable maintenance improvements without introducing unrelated features.

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

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

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

ESLint install failed due to a network error.


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