Skip to content

feat: raise error when GitLab CLI is required but not installed #852

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 16, 2025

Conversation

fgreinacher
Copy link
Contributor

@fgreinacher fgreinacher commented May 16, 2025

Contributes to #822

@fgreinacher fgreinacher requested a review from Copilot May 16, 2025 14:50
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR introduces error handling for cases when the GitLab CLI is required (via the publishToCatalog option) but not installed.

  • Added a new test to verify that a SemanticReleaseError is thrown when the GitLab CLI is absent.
  • Updated verify.js and publish.js to use a glab wrapper that calls the GitLab CLI and handles errors.
  • Extended the error definitions with a new error code EGLABNOTINSTALLED.

Reviewed Changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
test/verify.test.js Added a test case to verify the behavior when GitLab CLI is missing.
lib/verify.js Introduced CLI verification logic when publishToCatalog is enabled.
lib/publish.js Refactored to use the new glab wrapper for GitLab CLI commands.
lib/glab.js Created a wrapper for invoking the GitLab CLI via execa.
lib/definitions/errors.js Added a new error definition for when the GitLab CLI is not installed.
Comments suppressed due to low confidence (1)

test/verify.test.js:1003

  • [nitpick] Consider adding a test case when publishToCatalog is false to verify that the GitLab CLI verification is correctly skipped.
const execa = (await td.replaceEsm("execa")).execa;

@fgreinacher fgreinacher force-pushed the feat/error-when-glab-is-missing branch from 72d1d1a to 432d982 Compare May 16, 2025 14:54
@fgreinacher fgreinacher requested a review from Copilot May 16, 2025 14:54
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR introduces error handling to ensure that the GitLab CLI is installed when the "publishToCatalog" option is enabled. Key changes include:

  • Adding a test in test/verify.test.js that verifies a SemanticReleaseError is thrown when the GitLab CLI is missing.
  • Updating lib/verify.js to check for the GitLab CLI by executing "glab version" and pushing an error if it fails.
  • Replacing direct execa calls with a dedicated glab wrapper in both lib/publish.js and lib/glab.js, and extending error definitions in lib/definitions/errors.js.

Reviewed Changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.

Show a summary per file
File Description
test/verify.test.js Adds a new test to assert error handling when the GitLab CLI is not installed.
lib/verify.js Incorporates a runtime check for the GitLab CLI by invoking the glab command and handling errors.
lib/publish.js Uses the glab wrapper for invoking GitLab CLI commands.
lib/glab.js Introduces a wrapper function to standardize running GitLab CLI commands via execa.
lib/definitions/errors.js Extends the error definitions with EGLABNOTINSTALLED and provides related documentation.
Comments suppressed due to low confidence (1)

test/verify.test.js:994

  • The test description refers to 'GitLab CI' while the error messages and logger indicate 'GitLab CLI'. Consider updating the description to 'GitLab CLI' for consistency.
  'Throw SemanticReleaseError if "publishToCatalog" option is set and the GitLab CI is not installed.',

@fgreinacher fgreinacher force-pushed the feat/error-when-glab-is-missing branch from 432d982 to 457241f Compare May 16, 2025 14:56
@fgreinacher fgreinacher requested a review from Copilot May 16, 2025 14:59
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR implements a new error pathway to raise an error when the GitLab CLI is required (via the publishToCatalog option) but is not installed. Key changes include:

  • Adding a new test in test/verify.test.js to verify the error behavior when the GitLab CLI is missing.
  • Updating verify.js to check for the GitLab CLI and push a SemanticReleaseError if it fails.
  • Refactoring publish.js to consistently use the new glab wrapper for command execution.
  • Adding the EGLABNOTINSTALLED error definition in errors.js.

Reviewed Changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
test/verify.test.js New test added to validate error thrown when GitLab CLI is not installed
lib/verify.js Enhanced verification to check GitLab CLI and handle failure accordingly
lib/publish.js Updated to use glab wrapper instead of direct execa calls
lib/glab.js New wrapper for executing GitLab CLI commands
lib/definitions/errors.js Added new error definition for missing GitLab CLI
Comments suppressed due to low confidence (1)

lib/publish.js:198

  • [nitpick] Ensure that using the glab wrapper here is consistent with its usage elsewhere in the code, confirming that all GitLab CLI invocations follow the same error handling and timeout patterns.
await glab(["repo", "publish", "catalog", gitTag], {

@fgreinacher
Copy link
Contributor Author

@JonasSchubert Another one for you :)

@fgreinacher fgreinacher requested a review from JonasSchubert May 16, 2025 15:01
Copy link
Contributor

@JonasSchubert JonasSchubert left a comment

Choose a reason for hiding this comment

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

Simple and clean 👍
LGTM

@fgreinacher fgreinacher merged commit c128fc6 into beta May 16, 2025
14 checks passed
@fgreinacher fgreinacher deleted the feat/error-when-glab-is-missing branch May 16, 2025 15:12
Copy link

🎉 This PR is included in version 13.3.0-beta.2 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants