Skip to content

Conversation

addaleax
Copy link
Collaborator

No description provided.

@Copilot Copilot AI review requested due to automatic review settings October 13, 2025 15:09
@addaleax addaleax requested a review from a team as a code owner October 13, 2025 15:09
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 adds a best guess about the installation method to the buildInfo() function in the CLI REPL package. The implementation analyzes environment variables, file paths, and system properties to determine how MongoDB shell was installed.

  • Adds installationMethod field to BuildInfo interface with types for npx, homebrew, linux-system-wide, or other
  • Implements detection logic using environment variables and filesystem paths
  • Updates build info type definitions to properly handle the new field

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
packages/cli-repl/src/build-info.ts Adds installation method detection logic and updates interface
packages/build/src/build-info.ts Updates build info type definitions and removes unused import

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Comment on lines +56 to +57
process.execPath.startsWith('/usr/bin/') &&
(await fs.stat(process.execPath)).uid === 0
Copy link

Copilot AI Oct 13, 2025

Choose a reason for hiding this comment

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

The condition checks if the file owner's UID is 0 (root), but this doesn't guarantee system-wide installation. Files in /usr/bin/ could be owned by root even in local installations. Consider checking if the current process has root privileges instead, or remove this condition since the path check may be sufficient.

Suggested change
process.execPath.startsWith('/usr/bin/') &&
(await fs.stat(process.execPath)).uid === 0
process.execPath.startsWith('/usr/bin/')

Copilot uses AI. Check for mistakes.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

^ I don't think Copilot is making a lot of sense here?

Comment on lines 49 to 50
__filename.match(/\bhomebrew\b/i) &&
process.execPath.match(/\bhomebrew\b/)
Copy link

Copilot AI Oct 13, 2025

Choose a reason for hiding this comment

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

The regex pattern /\\bhomebrew\\b/i is duplicated. Consider extracting it to a constant to avoid repetition and make maintenance easier.

Copilot uses AI. Check for mistakes.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

No strong feelings

@addaleax addaleax added the no-title-validation Skips validation of PR titles (conventional commit adherence + JIRA ticket inclusion) label Oct 13, 2025
@addaleax addaleax changed the title fix(cli-repl): add best guess about installation method to buildInfo() fix(cli-repl): add best guess about installation method to buildInfo() MONGOSH-2915 Oct 14, 2025
@addaleax addaleax self-assigned this Oct 14, 2025
@addaleax addaleax removed the no-title-validation Skips validation of PR titles (conventional commit adherence + JIRA ticket inclusion) label Oct 14, 2025
@addaleax addaleax removed their assignment Oct 14, 2025
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.

1 participant