Skip to content
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

feat(remote): Replace exec with execFile for improved security #270

Merged
merged 1 commit into from
Jan 6, 2025

Conversation

yamadashy
Copy link
Owner

Checklist

  • Run npm run test
  • Run npm run lint

Copy link

stackblitz bot commented Jan 6, 2025

Review PR in StackBlitz Codeflow Run & review this pull request in StackBlitz Codeflow.

src/core/file/gitCommand.ts Dismissed Show dismissed Hide dismissed
Copy link
Contributor

coderabbitai bot commented Jan 6, 2025

Warning

Rate limit exceeded

@yamadashy has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 20 minutes and 2 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📥 Commits

Reviewing files that changed from the base of the PR and between 14457a2 and 91c4b60.

📒 Files selected for processing (4)
  • src/core/file/gitCommand.ts (3 hunks)
  • tests/core/file/gitCommand.test.ts (4 hunks)
  • website/client/.vitepress/theme/components/TryIt.vue (2 hunks)
  • website/client/.vitepress/theme/components/api/client.ts (1 hunks)
📝 Walkthrough

Walkthrough

The pull request modifies the Git command execution approach in the gitCommand.ts file by replacing execAsync with execFileAsync. This change updates how Git commands are invoked, transitioning from string-based command execution to using an array of arguments with the execFile method. The modifications affect the isGitInstalled and execGitShallowClone functions, updating their command execution syntax while maintaining the same core functionality.

Changes

File Change Summary
src/core/file/gitCommand.ts - Replaced execAsync with execFileAsync
- Updated command execution from string-based to argument-array method
- Modified isGitInstalled and execGitShallowClone functions to use new execution approach
tests/core/file/gitCommand.test.ts - Renamed mock function from execAsync to execFileAsync
- Updated test cases to reflect new command execution method
- Maintained original test logic with updated function naming

Sequence Diagram

sequenceDiagram
    participant Client
    participant GitCommand
    participant ChildProcess
    
    Client->>GitCommand: Request Git operation
    GitCommand->>ChildProcess: execFileAsync('git', [arguments])
    ChildProcess-->>GitCommand: Return command execution result
    GitCommand-->>Client: Provide operation result
Loading

Possibly related PRs


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 6

🧹 Nitpick comments (1)
src/core/file/gitCommand.ts (1)

35-36: Good practice of specifying arguments in an array.
Both fetch and checkout commands are now parameterized, reducing injection risks. However, be sure to update the corresponding tests.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 49b62c5 and 14457a2.

📒 Files selected for processing (2)
  • src/core/file/gitCommand.ts (3 hunks)
  • tests/core/file/gitCommand.test.ts (4 hunks)
🧰 Additional context used
🪛 GitHub Check: Test (macos-latest, 20.x)
tests/core/file/gitCommand.test.ts

[failure] 19-19: tests/core/file/gitCommand.test.ts > gitCommand > isGitInstalled > should return true when git is installed
AssertionError: expected "spy" to be called with arguments: [ 'git --version' ]

Received:

1st spy call:

Array [

  • "git --version",
  • "git",
  • Array [
  • "--version",
    
  • ],
    ]

Number of calls: 1

❯ tests/core/file/gitCommand.test.ts:19:33


[failure] 28-28: tests/core/file/gitCommand.test.ts > gitCommand > isGitInstalled > should return false when git command fails
AssertionError: expected "spy" to be called with arguments: [ 'git --version' ]

Received:

1st spy call:

Array [

  • "git --version",
  • "git",
  • Array [
  • "--version",
    
  • ],
    ]

Number of calls: 1

❯ tests/core/file/gitCommand.test.ts:28:33


[failure] 38-38: tests/core/file/gitCommand.test.ts > gitCommand > isGitInstalled > should return false when git command returns stderr
AssertionError: expected "spy" to be called with arguments: [ 'git --version' ]

Received:

1st spy call:

Array [

  • "git --version",
  • "git",
  • Array [
  • "--version",
    
  • ],
    ]

Number of calls: 1

❯ tests/core/file/gitCommand.test.ts:38:33


[failure] 51-51: tests/core/file/gitCommand.test.ts > gitCommand > execGitShallowClone > should execute without branch option if not specified by user
AssertionError: expected "spy" to be called with arguments: [ Array(1) ]

Received:

1st spy call:

Array [

  • "git",
  • Array [
  • "clone",
    
  • "--depth",
    
  • "1",
    
  • "https://github.com/user/repo.git",
    
  • "/tmp/repo",
    
  • ],
    ]

Number of calls: 1

❯ tests/core/file/gitCommand.test.ts:51:33


[failure] 63-63: tests/core/file/gitCommand.test.ts > gitCommand > execGitShallowClone > should throw error when git clone fails
AssertionError: expected "spy" to be called with arguments: [ Array(1) ]

Received:

1st spy call:

Array [

  • "git",
  • Array [
  • "clone",
    
  • "--depth",
    
  • "1",
    
  • "https://github.com/user/repo.git",
    
  • "/tmp/repo",
    
  • ],
    ]

Number of calls: 1

❯ tests/core/file/gitCommand.test.ts:63:33


[failure] 75-75: tests/core/file/gitCommand.test.ts > gitCommand > execGitShallowClone > should execute commands correctly when branch is specified
AssertionError: expected 1st "spy" call to have been called with [ 'git -C /tmp/repo init' ]

  • Expected
  • Received

    Array [

  • "git -C /tmp/repo init",
  • "git",
  • Array [
  • "-C",
    
  • "/tmp/repo",
    
  • "init",
    
  • ],
    ]

❯ tests/core/file/gitCommand.test.ts:75:33


[failure] 99-99: tests/core/file/gitCommand.test.ts > gitCommand > execGitShallowClone > should throw error when git fetch fails
AssertionError: expected 1st "spy" call to have been called with [ 'git -C /tmp/repo init' ]

  • Expected
  • Received

    Array [

  • "git -C /tmp/repo init",
  • "git",
  • Array [
  • "-C",
    
  • "/tmp/repo",
    
  • "init",
    
  • ],
    ]

❯ tests/core/file/gitCommand.test.ts:99:33


[failure] 122-122: tests/core/file/gitCommand.test.ts > gitCommand > execGitShallowClone > should handle short SHA correctly
AssertionError: expected 1st "spy" call to have been called with [ 'git -C /tmp/repo init' ]

  • Expected
  • Received

    Array [

  • "git -C /tmp/repo init",
  • "git",
  • Array [
  • "-C",
    
  • "/tmp/repo",
    
  • "init",
    
  • ],
    ]

❯ tests/core/file/gitCommand.test.ts:122:33


[failure] 145-145: tests/core/file/gitCommand.test.ts > gitCommand > execGitShallowClone > should throw error when remote ref is not found, and it's not due to short SHA
AssertionError: expected 1st "spy" call to have been called with [ 'git -C /tmp/repo init' ]

  • Expected
  • Received

    Array [

  • "git -C /tmp/repo init",
  • "git",
  • Array [
  • "-C",
    
  • "/tmp/repo",
    
  • "init",
    
  • ],
    ]

❯ tests/core/file/gitCommand.test.ts:145:33

🪛 GitHub Check: Test (macos-latest, 18.x)
tests/core/file/gitCommand.test.ts

[failure] 19-19: tests/core/file/gitCommand.test.ts > gitCommand > isGitInstalled > should return true when git is installed
AssertionError: expected "spy" to be called with arguments: [ 'git --version' ]

Received:

1st spy call:

Array [

  • "git --version",
  • "git",
  • Array [
  • "--version",
    
  • ],
    ]

Number of calls: 1

❯ tests/core/file/gitCommand.test.ts:19:33


[failure] 28-28: tests/core/file/gitCommand.test.ts > gitCommand > isGitInstalled > should return false when git command fails
AssertionError: expected "spy" to be called with arguments: [ 'git --version' ]

Received:

1st spy call:

Array [

  • "git --version",
  • "git",
  • Array [
  • "--version",
    
  • ],
    ]

Number of calls: 1

❯ tests/core/file/gitCommand.test.ts:28:33


[failure] 38-38: tests/core/file/gitCommand.test.ts > gitCommand > isGitInstalled > should return false when git command returns stderr
AssertionError: expected "spy" to be called with arguments: [ 'git --version' ]

Received:

1st spy call:

Array [

  • "git --version",
  • "git",
  • Array [
  • "--version",
    
  • ],
    ]

Number of calls: 1

❯ tests/core/file/gitCommand.test.ts:38:33


[failure] 51-51: tests/core/file/gitCommand.test.ts > gitCommand > execGitShallowClone > should execute without branch option if not specified by user
AssertionError: expected "spy" to be called with arguments: [ Array(1) ]

Received:

1st spy call:

Array [

  • "git",
  • Array [
  • "clone",
    
  • "--depth",
    
  • "1",
    
  • "https://github.com/user/repo.git",
    
  • "/tmp/repo",
    
  • ],
    ]

Number of calls: 1

❯ tests/core/file/gitCommand.test.ts:51:33


[failure] 63-63: tests/core/file/gitCommand.test.ts > gitCommand > execGitShallowClone > should throw error when git clone fails
AssertionError: expected "spy" to be called with arguments: [ Array(1) ]

Received:

1st spy call:

Array [

  • "git",
  • Array [
  • "clone",
    
  • "--depth",
    
  • "1",
    
  • "https://github.com/user/repo.git",
    
  • "/tmp/repo",
    
  • ],
    ]

Number of calls: 1

❯ tests/core/file/gitCommand.test.ts:63:33


[failure] 75-75: tests/core/file/gitCommand.test.ts > gitCommand > execGitShallowClone > should execute commands correctly when branch is specified
AssertionError: expected 1st "spy" call to have been called with [ 'git -C /tmp/repo init' ]

  • Expected
  • Received

    Array [

  • "git -C /tmp/repo init",
  • "git",
  • Array [
  • "-C",
    
  • "/tmp/repo",
    
  • "init",
    
  • ],
    ]

❯ tests/core/file/gitCommand.test.ts:75:33


[failure] 99-99: tests/core/file/gitCommand.test.ts > gitCommand > execGitShallowClone > should throw error when git fetch fails
AssertionError: expected 1st "spy" call to have been called with [ 'git -C /tmp/repo init' ]

  • Expected
  • Received

    Array [

  • "git -C /tmp/repo init",
  • "git",
  • Array [
  • "-C",
    
  • "/tmp/repo",
    
  • "init",
    
  • ],
    ]

❯ tests/core/file/gitCommand.test.ts:99:33


[failure] 122-122: tests/core/file/gitCommand.test.ts > gitCommand > execGitShallowClone > should handle short SHA correctly
AssertionError: expected 1st "spy" call to have been called with [ 'git -C /tmp/repo init' ]

  • Expected
  • Received

    Array [

  • "git -C /tmp/repo init",
  • "git",
  • Array [
  • "-C",
    
  • "/tmp/repo",
    
  • "init",
    
  • ],
    ]

❯ tests/core/file/gitCommand.test.ts:122:33


[failure] 145-145: tests/core/file/gitCommand.test.ts > gitCommand > execGitShallowClone > should throw error when remote ref is not found, and it's not due to short SHA
AssertionError: expected 1st "spy" call to have been called with [ 'git -C /tmp/repo init' ]

  • Expected
  • Received

    Array [

  • "git -C /tmp/repo init",
  • "git",
  • Array [
  • "-C",
    
  • "/tmp/repo",
    
  • "init",
    
  • ],
    ]

❯ tests/core/file/gitCommand.test.ts:145:33

🪛 GitHub Check: Test (macos-latest, 18.20.0)
tests/core/file/gitCommand.test.ts

[failure] 19-19: tests/core/file/gitCommand.test.ts > gitCommand > isGitInstalled > should return true when git is installed
AssertionError: expected "spy" to be called with arguments: [ 'git --version' ]

Received:

1st spy call:

Array [

  • "git --version",
  • "git",
  • Array [
  • "--version",
    
  • ],
    ]

Number of calls: 1

❯ tests/core/file/gitCommand.test.ts:19:33


[failure] 28-28: tests/core/file/gitCommand.test.ts > gitCommand > isGitInstalled > should return false when git command fails
AssertionError: expected "spy" to be called with arguments: [ 'git --version' ]

Received:

1st spy call:

Array [

  • "git --version",
  • "git",
  • Array [
  • "--version",
    
  • ],
    ]

Number of calls: 1

❯ tests/core/file/gitCommand.test.ts:28:33


[failure] 38-38: tests/core/file/gitCommand.test.ts > gitCommand > isGitInstalled > should return false when git command returns stderr
AssertionError: expected "spy" to be called with arguments: [ 'git --version' ]

Received:

1st spy call:

Array [

  • "git --version",
  • "git",
  • Array [
  • "--version",
    
  • ],
    ]

Number of calls: 1

❯ tests/core/file/gitCommand.test.ts:38:33


[failure] 51-51: tests/core/file/gitCommand.test.ts > gitCommand > execGitShallowClone > should execute without branch option if not specified by user
AssertionError: expected "spy" to be called with arguments: [ Array(1) ]

Received:

1st spy call:

Array [

  • "git",
  • Array [
  • "clone",
    
  • "--depth",
    
  • "1",
    
  • "https://github.com/user/repo.git",
    
  • "/tmp/repo",
    
  • ],
    ]

Number of calls: 1

❯ tests/core/file/gitCommand.test.ts:51:33


[failure] 63-63: tests/core/file/gitCommand.test.ts > gitCommand > execGitShallowClone > should throw error when git clone fails
AssertionError: expected "spy" to be called with arguments: [ Array(1) ]

Received:

1st spy call:

Array [

  • "git",
  • Array [
  • "clone",
    
  • "--depth",
    
  • "1",
    
  • "https://github.com/user/repo.git",
    
  • "/tmp/repo",
    
  • ],
    ]

Number of calls: 1

❯ tests/core/file/gitCommand.test.ts:63:33


[failure] 75-75: tests/core/file/gitCommand.test.ts > gitCommand > execGitShallowClone > should execute commands correctly when branch is specified
AssertionError: expected 1st "spy" call to have been called with [ 'git -C /tmp/repo init' ]

  • Expected
  • Received

    Array [

  • "git -C /tmp/repo init",
  • "git",
  • Array [
  • "-C",
    
  • "/tmp/repo",
    
  • "init",
    
  • ],
    ]

❯ tests/core/file/gitCommand.test.ts:75:33


[failure] 99-99: tests/core/file/gitCommand.test.ts > gitCommand > execGitShallowClone > should throw error when git fetch fails
AssertionError: expected 1st "spy" call to have been called with [ 'git -C /tmp/repo init' ]

  • Expected
  • Received

    Array [

  • "git -C /tmp/repo init",
  • "git",
  • Array [
  • "-C",
    
  • "/tmp/repo",
    
  • "init",
    
  • ],
    ]

❯ tests/core/file/gitCommand.test.ts:99:33


[failure] 122-122: tests/core/file/gitCommand.test.ts > gitCommand > execGitShallowClone > should handle short SHA correctly
AssertionError: expected 1st "spy" call to have been called with [ 'git -C /tmp/repo init' ]

  • Expected
  • Received

    Array [

  • "git -C /tmp/repo init",
  • "git",
  • Array [
  • "-C",
    
  • "/tmp/repo",
    
  • "init",
    
  • ],
    ]

❯ tests/core/file/gitCommand.test.ts:122:33


[failure] 145-145: tests/core/file/gitCommand.test.ts > gitCommand > execGitShallowClone > should throw error when remote ref is not found, and it's not due to short SHA
AssertionError: expected 1st "spy" call to have been called with [ 'git -C /tmp/repo init' ]

  • Expected
  • Received

    Array [

  • "git -C /tmp/repo init",
  • "git",
  • Array [
  • "-C",
    
  • "/tmp/repo",
    
  • "init",
    
  • ],
    ]

❯ tests/core/file/gitCommand.test.ts:145:33

🪛 GitHub Check: Test (ubuntu-latest, 23.x)
tests/core/file/gitCommand.test.ts

[failure] 19-19: tests/core/file/gitCommand.test.ts > gitCommand > isGitInstalled > should return true when git is installed
AssertionError: expected "spy" to be called with arguments: [ 'git --version' ]

Received:

1st spy call:

Array [

  • "git --version",
  • "git",
  • Array [
  • "--version",
    
  • ],
    ]

Number of calls: 1

❯ tests/core/file/gitCommand.test.ts:19:33


[failure] 28-28: tests/core/file/gitCommand.test.ts > gitCommand > isGitInstalled > should return false when git command fails
AssertionError: expected "spy" to be called with arguments: [ 'git --version' ]

Received:

1st spy call:

Array [

  • "git --version",
  • "git",
  • Array [
  • "--version",
    
  • ],
    ]

Number of calls: 1

❯ tests/core/file/gitCommand.test.ts:28:33


[failure] 38-38: tests/core/file/gitCommand.test.ts > gitCommand > isGitInstalled > should return false when git command returns stderr
AssertionError: expected "spy" to be called with arguments: [ 'git --version' ]

Received:

1st spy call:

Array [

  • "git --version",
  • "git",
  • Array [
  • "--version",
    
  • ],
    ]

Number of calls: 1

❯ tests/core/file/gitCommand.test.ts:38:33


[failure] 51-51: tests/core/file/gitCommand.test.ts > gitCommand > execGitShallowClone > should execute without branch option if not specified by user
AssertionError: expected "spy" to be called with arguments: [ Array(1) ]

Received:

1st spy call:

Array [

  • "git",
  • Array [
  • "clone",
    
  • "--depth",
    
  • "1",
    
  • "https://github.com/user/repo.git",
    
  • "/tmp/repo",
    
  • ],
    ]

Number of calls: 1

❯ tests/core/file/gitCommand.test.ts:51:33


[failure] 63-63: tests/core/file/gitCommand.test.ts > gitCommand > execGitShallowClone > should throw error when git clone fails
AssertionError: expected "spy" to be called with arguments: [ Array(1) ]

Received:

1st spy call:

Array [

  • "git",
  • Array [
  • "clone",
    
  • "--depth",
    
  • "1",
    
  • "https://github.com/user/repo.git",
    
  • "/tmp/repo",
    
  • ],
    ]

Number of calls: 1

❯ tests/core/file/gitCommand.test.ts:63:33


[failure] 75-75: tests/core/file/gitCommand.test.ts > gitCommand > execGitShallowClone > should execute commands correctly when branch is specified
AssertionError: expected 1st "spy" call to have been called with [ 'git -C /tmp/repo init' ]

  • Expected
  • Received

    Array [

  • "git -C /tmp/repo init",
  • "git",
  • Array [
  • "-C",
    
  • "/tmp/repo",
    
  • "init",
    
  • ],
    ]

❯ tests/core/file/gitCommand.test.ts:75:33


[failure] 99-99: tests/core/file/gitCommand.test.ts > gitCommand > execGitShallowClone > should throw error when git fetch fails
AssertionError: expected 1st "spy" call to have been called with [ 'git -C /tmp/repo init' ]

  • Expected
  • Received

    Array [

  • "git -C /tmp/repo init",
  • "git",
  • Array [
  • "-C",
    
  • "/tmp/repo",
    
  • "init",
    
  • ],
    ]

❯ tests/core/file/gitCommand.test.ts:99:33


[failure] 122-122: tests/core/file/gitCommand.test.ts > gitCommand > execGitShallowClone > should handle short SHA correctly
AssertionError: expected 1st "spy" call to have been called with [ 'git -C /tmp/repo init' ]

  • Expected
  • Received

    Array [

  • "git -C /tmp/repo init",
  • "git",
  • Array [
  • "-C",
    
  • "/tmp/repo",
    
  • "init",
    
  • ],
    ]

❯ tests/core/file/gitCommand.test.ts:122:33


[failure] 145-145: tests/core/file/gitCommand.test.ts > gitCommand > execGitShallowClone > should throw error when remote ref is not found, and it's not due to short SHA
AssertionError: expected 1st "spy" call to have been called with [ 'git -C /tmp/repo init' ]

  • Expected
  • Received

    Array [

  • "git -C /tmp/repo init",
  • "git",
  • Array [
  • "-C",
    
  • "/tmp/repo",
    
  • "init",
    
  • ],
    ]

❯ tests/core/file/gitCommand.test.ts:145:33

🪛 GitHub Check: Test (ubuntu-latest, 22.x)
tests/core/file/gitCommand.test.ts

[failure] 19-19: tests/core/file/gitCommand.test.ts > gitCommand > isGitInstalled > should return true when git is installed
AssertionError: expected "spy" to be called with arguments: [ 'git --version' ]

Received:

1st spy call:

Array [

  • "git --version",
  • "git",
  • Array [
  • "--version",
    
  • ],
    ]

Number of calls: 1

❯ tests/core/file/gitCommand.test.ts:19:33


[failure] 28-28: tests/core/file/gitCommand.test.ts > gitCommand > isGitInstalled > should return false when git command fails
AssertionError: expected "spy" to be called with arguments: [ 'git --version' ]

Received:

1st spy call:

Array [

  • "git --version",
  • "git",
  • Array [
  • "--version",
    
  • ],
    ]

Number of calls: 1

❯ tests/core/file/gitCommand.test.ts:28:33


[failure] 38-38: tests/core/file/gitCommand.test.ts > gitCommand > isGitInstalled > should return false when git command returns stderr
AssertionError: expected "spy" to be called with arguments: [ 'git --version' ]

Received:

1st spy call:

Array [

  • "git --version",
  • "git",
  • Array [
  • "--version",
    
  • ],
    ]

Number of calls: 1

❯ tests/core/file/gitCommand.test.ts:38:33


[failure] 51-51: tests/core/file/gitCommand.test.ts > gitCommand > execGitShallowClone > should execute without branch option if not specified by user
AssertionError: expected "spy" to be called with arguments: [ Array(1) ]

Received:

1st spy call:

Array [

  • "git",
  • Array [
  • "clone",
    
  • "--depth",
    
  • "1",
    
  • "https://github.com/user/repo.git",
    
  • "/tmp/repo",
    
  • ],
    ]

Number of calls: 1

❯ tests/core/file/gitCommand.test.ts:51:33


[failure] 63-63: tests/core/file/gitCommand.test.ts > gitCommand > execGitShallowClone > should throw error when git clone fails
AssertionError: expected "spy" to be called with arguments: [ Array(1) ]

Received:

1st spy call:

Array [

  • "git",
  • Array [
  • "clone",
    
  • "--depth",
    
  • "1",
    
  • "https://github.com/user/repo.git",
    
  • "/tmp/repo",
    
  • ],
    ]

Number of calls: 1

❯ tests/core/file/gitCommand.test.ts:63:33


[failure] 75-75: tests/core/file/gitCommand.test.ts > gitCommand > execGitShallowClone > should execute commands correctly when branch is specified
AssertionError: expected 1st "spy" call to have been called with [ 'git -C /tmp/repo init' ]

  • Expected
  • Received

    Array [

  • "git -C /tmp/repo init",
  • "git",
  • Array [
  • "-C",
    
  • "/tmp/repo",
    
  • "init",
    
  • ],
    ]

❯ tests/core/file/gitCommand.test.ts:75:33


[failure] 99-99: tests/core/file/gitCommand.test.ts > gitCommand > execGitShallowClone > should throw error when git fetch fails
AssertionError: expected 1st "spy" call to have been called with [ 'git -C /tmp/repo init' ]

  • Expected
  • Received

    Array [

  • "git -C /tmp/repo init",
  • "git",
  • Array [
  • "-C",
    
  • "/tmp/repo",
    
  • "init",
    
  • ],
    ]

❯ tests/core/file/gitCommand.test.ts:99:33


[failure] 122-122: tests/core/file/gitCommand.test.ts > gitCommand > execGitShallowClone > should handle short SHA correctly
AssertionError: expected 1st "spy" call to have been called with [ 'git -C /tmp/repo init' ]

  • Expected
  • Received

    Array [

  • "git -C /tmp/repo init",
  • "git",
  • Array [
  • "-C",
    
  • "/tmp/repo",
    
  • "init",
    
  • ],
    ]

❯ tests/core/file/gitCommand.test.ts:122:33


[failure] 145-145: tests/core/file/gitCommand.test.ts > gitCommand > execGitShallowClone > should throw error when remote ref is not found, and it's not due to short SHA
AssertionError: expected 1st "spy" call to have been called with [ 'git -C /tmp/repo init' ]

  • Expected
  • Received

    Array [

  • "git -C /tmp/repo init",
  • "git",
  • Array [
  • "-C",
    
  • "/tmp/repo",
    
  • "init",
    
  • ],
    ]

❯ tests/core/file/gitCommand.test.ts:145:33

🪛 GitHub Check: Test (ubuntu-latest, 20.x)
tests/core/file/gitCommand.test.ts

[failure] 19-19: tests/core/file/gitCommand.test.ts > gitCommand > isGitInstalled > should return true when git is installed
AssertionError: expected "spy" to be called with arguments: [ 'git --version' ]

Received:

1st spy call:

Array [

  • "git --version",
  • "git",
  • Array [
  • "--version",
    
  • ],
    ]

Number of calls: 1

❯ tests/core/file/gitCommand.test.ts:19:33


[failure] 28-28: tests/core/file/gitCommand.test.ts > gitCommand > isGitInstalled > should return false when git command fails
AssertionError: expected "spy" to be called with arguments: [ 'git --version' ]

Received:

1st spy call:

Array [

  • "git --version",
  • "git",
  • Array [
  • "--version",
    
  • ],
    ]

Number of calls: 1

❯ tests/core/file/gitCommand.test.ts:28:33


[failure] 38-38: tests/core/file/gitCommand.test.ts > gitCommand > isGitInstalled > should return false when git command returns stderr
AssertionError: expected "spy" to be called with arguments: [ 'git --version' ]

Received:

1st spy call:

Array [

  • "git --version",
  • "git",
  • Array [
  • "--version",
    
  • ],
    ]

Number of calls: 1

❯ tests/core/file/gitCommand.test.ts:38:33


[failure] 51-51: tests/core/file/gitCommand.test.ts > gitCommand > execGitShallowClone > should execute without branch option if not specified by user
AssertionError: expected "spy" to be called with arguments: [ Array(1) ]

Received:

1st spy call:

Array [

  • "git",
  • Array [
  • "clone",
    
  • "--depth",
    
  • "1",
    
  • "https://github.com/user/repo.git",
    
  • "/tmp/repo",
    
  • ],
    ]

Number of calls: 1

❯ tests/core/file/gitCommand.test.ts:51:33


[failure] 63-63: tests/core/file/gitCommand.test.ts > gitCommand > execGitShallowClone > should throw error when git clone fails
AssertionError: expected "spy" to be called with arguments: [ Array(1) ]

Received:

1st spy call:

Array [

  • "git",
  • Array [
  • "clone",
    
  • "--depth",
    
  • "1",
    
  • "https://github.com/user/repo.git",
    
  • "/tmp/repo",
    
  • ],
    ]

Number of calls: 1

❯ tests/core/file/gitCommand.test.ts:63:33


[failure] 75-75: tests/core/file/gitCommand.test.ts > gitCommand > execGitShallowClone > should execute commands correctly when branch is specified
AssertionError: expected 1st "spy" call to have been called with [ 'git -C /tmp/repo init' ]

  • Expected
  • Received

    Array [

  • "git -C /tmp/repo init",
  • "git",
  • Array [
  • "-C",
    
  • "/tmp/repo",
    
  • "init",
    
  • ],
    ]

❯ tests/core/file/gitCommand.test.ts:75:33


[failure] 99-99: tests/core/file/gitCommand.test.ts > gitCommand > execGitShallowClone > should throw error when git fetch fails
AssertionError: expected 1st "spy" call to have been called with [ 'git -C /tmp/repo init' ]

  • Expected
  • Received

    Array [

  • "git -C /tmp/repo init",
  • "git",
  • Array [
  • "-C",
    
  • "/tmp/repo",
    
  • "init",
    
  • ],
    ]

❯ tests/core/file/gitCommand.test.ts:99:33


[failure] 122-122: tests/core/file/gitCommand.test.ts > gitCommand > execGitShallowClone > should handle short SHA correctly
AssertionError: expected 1st "spy" call to have been called with [ 'git -C /tmp/repo init' ]

  • Expected
  • Received

    Array [

  • "git -C /tmp/repo init",
  • "git",
  • Array [
  • "-C",
    
  • "/tmp/repo",
    
  • "init",
    
  • ],
    ]

❯ tests/core/file/gitCommand.test.ts:122:33


[failure] 145-145: tests/core/file/gitCommand.test.ts > gitCommand > execGitShallowClone > should throw error when remote ref is not found, and it's not due to short SHA
AssertionError: expected 1st "spy" call to have been called with [ 'git -C /tmp/repo init' ]

  • Expected
  • Received

    Array [

  • "git -C /tmp/repo init",
  • "git",
  • Array [
  • "-C",
    
  • "/tmp/repo",
    
  • "init",
    
  • ],
    ]

❯ tests/core/file/gitCommand.test.ts:145:33

🪛 GitHub Check: Test (ubuntu-latest, 18.x)
tests/core/file/gitCommand.test.ts

[failure] 19-19: tests/core/file/gitCommand.test.ts > gitCommand > isGitInstalled > should return true when git is installed
AssertionError: expected "spy" to be called with arguments: [ 'git --version' ]

Received:

1st spy call:

Array [

  • "git --version",
  • "git",
  • Array [
  • "--version",
    
  • ],
    ]

Number of calls: 1

❯ tests/core/file/gitCommand.test.ts:19:33


[failure] 28-28: tests/core/file/gitCommand.test.ts > gitCommand > isGitInstalled > should return false when git command fails
AssertionError: expected "spy" to be called with arguments: [ 'git --version' ]

Received:

1st spy call:

Array [

  • "git --version",
  • "git",
  • Array [
  • "--version",
    
  • ],
    ]

Number of calls: 1

❯ tests/core/file/gitCommand.test.ts:28:33


[failure] 38-38: tests/core/file/gitCommand.test.ts > gitCommand > isGitInstalled > should return false when git command returns stderr
AssertionError: expected "spy" to be called with arguments: [ 'git --version' ]

Received:

1st spy call:

Array [

  • "git --version",
  • "git",
  • Array [
  • "--version",
    
  • ],
    ]

Number of calls: 1

❯ tests/core/file/gitCommand.test.ts:38:33


[failure] 51-51: tests/core/file/gitCommand.test.ts > gitCommand > execGitShallowClone > should execute without branch option if not specified by user
AssertionError: expected "spy" to be called with arguments: [ Array(1) ]

Received:

1st spy call:

Array [

  • "git",
  • Array [
  • "clone",
    
  • "--depth",
    
  • "1",
    
  • "https://github.com/user/repo.git",
    
  • "/tmp/repo",
    
  • ],
    ]

Number of calls: 1

❯ tests/core/file/gitCommand.test.ts:51:33


[failure] 63-63: tests/core/file/gitCommand.test.ts > gitCommand > execGitShallowClone > should throw error when git clone fails
AssertionError: expected "spy" to be called with arguments: [ Array(1) ]

Received:

1st spy call:

Array [

  • "git",
  • Array [
  • "clone",
    
  • "--depth",
    
  • "1",
    
  • "https://github.com/user/repo.git",
    
  • "/tmp/repo",
    
  • ],
    ]

Number of calls: 1

❯ tests/core/file/gitCommand.test.ts:63:33


[failure] 75-75: tests/core/file/gitCommand.test.ts > gitCommand > execGitShallowClone > should execute commands correctly when branch is specified
AssertionError: expected 1st "spy" call to have been called with [ 'git -C /tmp/repo init' ]

  • Expected
  • Received

    Array [

  • "git -C /tmp/repo init",
  • "git",
  • Array [
  • "-C",
    
  • "/tmp/repo",
    
  • "init",
    
  • ],
    ]

❯ tests/core/file/gitCommand.test.ts:75:33


[failure] 99-99: tests/core/file/gitCommand.test.ts > gitCommand > execGitShallowClone > should throw error when git fetch fails
AssertionError: expected 1st "spy" call to have been called with [ 'git -C /tmp/repo init' ]

  • Expected
  • Received

    Array [

  • "git -C /tmp/repo init",
  • "git",
  • Array [
  • "-C",
    
  • "/tmp/repo",
    
  • "init",
    
  • ],
    ]

❯ tests/core/file/gitCommand.test.ts:99:33


[failure] 122-122: tests/core/file/gitCommand.test.ts > gitCommand > execGitShallowClone > should handle short SHA correctly
AssertionError: expected 1st "spy" call to have been called with [ 'git -C /tmp/repo init' ]

  • Expected
  • Received

    Array [

  • "git -C /tmp/repo init",
  • "git",
  • Array [
  • "-C",
    
  • "/tmp/repo",
    
  • "init",
    
  • ],
    ]

❯ tests/core/file/gitCommand.test.ts:122:33


[failure] 145-145: tests/core/file/gitCommand.test.ts > gitCommand > execGitShallowClone > should throw error when remote ref is not found, and it's not due to short SHA
AssertionError: expected 1st "spy" call to have been called with [ 'git -C /tmp/repo init' ]

  • Expected
  • Received

    Array [

  • "git -C /tmp/repo init",
  • "git",
  • Array [
  • "-C",
    
  • "/tmp/repo",
    
  • "init",
    
  • ],
    ]

❯ tests/core/file/gitCommand.test.ts:145:33

🪛 GitHub Check: Test (ubuntu-latest, 18.20.0)
tests/core/file/gitCommand.test.ts

[failure] 19-19: tests/core/file/gitCommand.test.ts > gitCommand > isGitInstalled > should return true when git is installed
AssertionError: expected "spy" to be called with arguments: [ 'git --version' ]

Received:

1st spy call:

Array [

  • "git --version",
  • "git",
  • Array [
  • "--version",
    
  • ],
    ]

Number of calls: 1

❯ tests/core/file/gitCommand.test.ts:19:33


[failure] 28-28: tests/core/file/gitCommand.test.ts > gitCommand > isGitInstalled > should return false when git command fails
AssertionError: expected "spy" to be called with arguments: [ 'git --version' ]

Received:

1st spy call:

Array [

  • "git --version",
  • "git",
  • Array [
  • "--version",
    
  • ],
    ]

Number of calls: 1

❯ tests/core/file/gitCommand.test.ts:28:33


[failure] 38-38: tests/core/file/gitCommand.test.ts > gitCommand > isGitInstalled > should return false when git command returns stderr
AssertionError: expected "spy" to be called with arguments: [ 'git --version' ]

Received:

1st spy call:

Array [

  • "git --version",
  • "git",
  • Array [
  • "--version",
    
  • ],
    ]

Number of calls: 1

❯ tests/core/file/gitCommand.test.ts:38:33


[failure] 51-51: tests/core/file/gitCommand.test.ts > gitCommand > execGitShallowClone > should execute without branch option if not specified by user
AssertionError: expected "spy" to be called with arguments: [ Array(1) ]

Received:

1st spy call:

Array [

  • "git",
  • Array [
  • "clone",
    
  • "--depth",
    
  • "1",
    
  • "https://github.com/user/repo.git",
    
  • "/tmp/repo",
    
  • ],
    ]

Number of calls: 1

❯ tests/core/file/gitCommand.test.ts:51:33


[failure] 63-63: tests/core/file/gitCommand.test.ts > gitCommand > execGitShallowClone > should throw error when git clone fails
AssertionError: expected "spy" to be called with arguments: [ Array(1) ]

Received:

1st spy call:

Array [

  • "git",
  • Array [
  • "clone",
    
  • "--depth",
    
  • "1",
    
  • "https://github.com/user/repo.git",
    
  • "/tmp/repo",
    
  • ],
    ]

Number of calls: 1

❯ tests/core/file/gitCommand.test.ts:63:33


[failure] 75-75: tests/core/file/gitCommand.test.ts > gitCommand > execGitShallowClone > should execute commands correctly when branch is specified
AssertionError: expected 1st "spy" call to have been called with [ 'git -C /tmp/repo init' ]

  • Expected
  • Received

    Array [

  • "git -C /tmp/repo init",
  • "git",
  • Array [
  • "-C",
    
  • "/tmp/repo",
    
  • "init",
    
  • ],
    ]

❯ tests/core/file/gitCommand.test.ts:75:33


[failure] 99-99: tests/core/file/gitCommand.test.ts > gitCommand > execGitShallowClone > should throw error when git fetch fails
AssertionError: expected 1st "spy" call to have been called with [ 'git -C /tmp/repo init' ]

  • Expected
  • Received

    Array [

  • "git -C /tmp/repo init",
  • "git",
  • Array [
  • "-C",
    
  • "/tmp/repo",
    
  • "init",
    
  • ],
    ]

❯ tests/core/file/gitCommand.test.ts:99:33


[failure] 122-122: tests/core/file/gitCommand.test.ts > gitCommand > execGitShallowClone > should handle short SHA correctly
AssertionError: expected 1st "spy" call to have been called with [ 'git -C /tmp/repo init' ]

  • Expected
  • Received

    Array [

  • "git -C /tmp/repo init",
  • "git",
  • Array [
  • "-C",
    
  • "/tmp/repo",
    
  • "init",
    
  • ],
    ]

❯ tests/core/file/gitCommand.test.ts:122:33


[failure] 145-145: tests/core/file/gitCommand.test.ts > gitCommand > execGitShallowClone > should throw error when remote ref is not found, and it's not due to short SHA
AssertionError: expected 1st "spy" call to have been called with [ 'git -C /tmp/repo init' ]

  • Expected
  • Received

    Array [

  • "git -C /tmp/repo init",
  • "git",
  • Array [
  • "-C",
    
  • "/tmp/repo",
    
  • "init",
    
  • ],
    ]

❯ tests/core/file/gitCommand.test.ts:145:33

⏰ Context from checks skipped due to timeout of 90000ms (3)
  • GitHub Check: Lint Renovate config
  • GitHub Check: Analyze (javascript-typescript)
  • GitHub Check: Cloudflare Pages
🔇 Additional comments (10)
src/core/file/gitCommand.ts (5)

1-1: Switch from exec to execFile looks good.
This is a secure practice as execFile does not spawn a shell, thus mitigating shell-injection risks.


7-7: Promisify usage is appropriate.
Wrapping execFile with promisify to get a promise-based API is a clean approach.


11-11: Dependency injection pattern is consistent.
Passing execFileAsync in deps simplifies testing by allowing mocks to be injected.


28-28: Dependency injection is still consistent.
No concerns here; references to execFileAsync in deps are correct.


59-60: Comprehensive fallback for short SHA scenario.
Continuing to use execFileAsync is safe. Just ensure your test suite is aligned with the new approach.

tests/core/file/gitCommand.test.ts (5)

23-28: Same mismatch in the failing test.
This block also expects 'git --version' as a single string. Apply the same fix.

🧰 Tools
🪛 GitHub Check: Test (macos-latest, 20.x)

[failure] 28-28: tests/core/file/gitCommand.test.ts > gitCommand > isGitInstalled > should return false when git command fails
AssertionError: expected "spy" to be called with arguments: [ 'git --version' ]

Received:

1st spy call:

Array [

  • "git --version",
  • "git",
  • Array [
  • "--version",
    
  • ],
    ]

Number of calls: 1

❯ tests/core/file/gitCommand.test.ts:28:33

🪛 GitHub Check: Test (macos-latest, 18.x)

[failure] 28-28: tests/core/file/gitCommand.test.ts > gitCommand > isGitInstalled > should return false when git command fails
AssertionError: expected "spy" to be called with arguments: [ 'git --version' ]

Received:

1st spy call:

Array [

  • "git --version",
  • "git",
  • Array [
  • "--version",
    
  • ],
    ]

Number of calls: 1

❯ tests/core/file/gitCommand.test.ts:28:33

🪛 GitHub Check: Test (macos-latest, 18.20.0)

[failure] 28-28: tests/core/file/gitCommand.test.ts > gitCommand > isGitInstalled > should return false when git command fails
AssertionError: expected "spy" to be called with arguments: [ 'git --version' ]

Received:

1st spy call:

Array [

  • "git --version",
  • "git",
  • Array [
  • "--version",
    
  • ],
    ]

Number of calls: 1

❯ tests/core/file/gitCommand.test.ts:28:33

🪛 GitHub Check: Test (ubuntu-latest, 23.x)

[failure] 28-28: tests/core/file/gitCommand.test.ts > gitCommand > isGitInstalled > should return false when git command fails
AssertionError: expected "spy" to be called with arguments: [ 'git --version' ]

Received:

1st spy call:

Array [

  • "git --version",
  • "git",
  • Array [
  • "--version",
    
  • ],
    ]

Number of calls: 1

❯ tests/core/file/gitCommand.test.ts:28:33

🪛 GitHub Check: Test (ubuntu-latest, 22.x)

[failure] 28-28: tests/core/file/gitCommand.test.ts > gitCommand > isGitInstalled > should return false when git command fails
AssertionError: expected "spy" to be called with arguments: [ 'git --version' ]

Received:

1st spy call:

Array [

  • "git --version",
  • "git",
  • Array [
  • "--version",
    
  • ],
    ]

Number of calls: 1

❯ tests/core/file/gitCommand.test.ts:28:33

🪛 GitHub Check: Test (ubuntu-latest, 20.x)

[failure] 28-28: tests/core/file/gitCommand.test.ts > gitCommand > isGitInstalled > should return false when git command fails
AssertionError: expected "spy" to be called with arguments: [ 'git --version' ]

Received:

1st spy call:

Array [

  • "git --version",
  • "git",
  • Array [
  • "--version",
    
  • ],
    ]

Number of calls: 1

❯ tests/core/file/gitCommand.test.ts:28:33

🪛 GitHub Check: Test (ubuntu-latest, 18.x)

[failure] 28-28: tests/core/file/gitCommand.test.ts > gitCommand > isGitInstalled > should return false when git command fails
AssertionError: expected "spy" to be called with arguments: [ 'git --version' ]

Received:

1st spy call:

Array [

  • "git --version",
  • "git",
  • Array [
  • "--version",
    
  • ],
    ]

Number of calls: 1

❯ tests/core/file/gitCommand.test.ts:28:33

🪛 GitHub Check: Test (ubuntu-latest, 18.20.0)

[failure] 28-28: tests/core/file/gitCommand.test.ts > gitCommand > isGitInstalled > should return false when git command fails
AssertionError: expected "spy" to be called with arguments: [ 'git --version' ]

Received:

1st spy call:

Array [

  • "git --version",
  • "git",
  • Array [
  • "--version",
    
  • ],
    ]

Number of calls: 1

❯ tests/core/file/gitCommand.test.ts:28:33


33-38: Again, fix the expected arguments.
Your code now calls 'git', ['--version']. The test must match accordingly.

🧰 Tools
🪛 GitHub Check: Test (macos-latest, 20.x)

[failure] 38-38: tests/core/file/gitCommand.test.ts > gitCommand > isGitInstalled > should return false when git command returns stderr
AssertionError: expected "spy" to be called with arguments: [ 'git --version' ]

Received:

1st spy call:

Array [

  • "git --version",
  • "git",
  • Array [
  • "--version",
    
  • ],
    ]

Number of calls: 1

❯ tests/core/file/gitCommand.test.ts:38:33

🪛 GitHub Check: Test (macos-latest, 18.x)

[failure] 38-38: tests/core/file/gitCommand.test.ts > gitCommand > isGitInstalled > should return false when git command returns stderr
AssertionError: expected "spy" to be called with arguments: [ 'git --version' ]

Received:

1st spy call:

Array [

  • "git --version",
  • "git",
  • Array [
  • "--version",
    
  • ],
    ]

Number of calls: 1

❯ tests/core/file/gitCommand.test.ts:38:33

🪛 GitHub Check: Test (macos-latest, 18.20.0)

[failure] 38-38: tests/core/file/gitCommand.test.ts > gitCommand > isGitInstalled > should return false when git command returns stderr
AssertionError: expected "spy" to be called with arguments: [ 'git --version' ]

Received:

1st spy call:

Array [

  • "git --version",
  • "git",
  • Array [
  • "--version",
    
  • ],
    ]

Number of calls: 1

❯ tests/core/file/gitCommand.test.ts:38:33

🪛 GitHub Check: Test (ubuntu-latest, 23.x)

[failure] 38-38: tests/core/file/gitCommand.test.ts > gitCommand > isGitInstalled > should return false when git command returns stderr
AssertionError: expected "spy" to be called with arguments: [ 'git --version' ]

Received:

1st spy call:

Array [

  • "git --version",
  • "git",
  • Array [
  • "--version",
    
  • ],
    ]

Number of calls: 1

❯ tests/core/file/gitCommand.test.ts:38:33

🪛 GitHub Check: Test (ubuntu-latest, 22.x)

[failure] 38-38: tests/core/file/gitCommand.test.ts > gitCommand > isGitInstalled > should return false when git command returns stderr
AssertionError: expected "spy" to be called with arguments: [ 'git --version' ]

Received:

1st spy call:

Array [

  • "git --version",
  • "git",
  • Array [
  • "--version",
    
  • ],
    ]

Number of calls: 1

❯ tests/core/file/gitCommand.test.ts:38:33

🪛 GitHub Check: Test (ubuntu-latest, 20.x)

[failure] 38-38: tests/core/file/gitCommand.test.ts > gitCommand > isGitInstalled > should return false when git command returns stderr
AssertionError: expected "spy" to be called with arguments: [ 'git --version' ]

Received:

1st spy call:

Array [

  • "git --version",
  • "git",
  • Array [
  • "--version",
    
  • ],
    ]

Number of calls: 1

❯ tests/core/file/gitCommand.test.ts:38:33

🪛 GitHub Check: Test (ubuntu-latest, 18.x)

[failure] 38-38: tests/core/file/gitCommand.test.ts > gitCommand > isGitInstalled > should return false when git command returns stderr
AssertionError: expected "spy" to be called with arguments: [ 'git --version' ]

Received:

1st spy call:

Array [

  • "git --version",
  • "git",
  • Array [
  • "--version",
    
  • ],
    ]

Number of calls: 1

❯ tests/core/file/gitCommand.test.ts:38:33

🪛 GitHub Check: Test (ubuntu-latest, 18.20.0)

[failure] 38-38: tests/core/file/gitCommand.test.ts > gitCommand > isGitInstalled > should return false when git command returns stderr
AssertionError: expected "spy" to be called with arguments: [ 'git --version' ]

Received:

1st spy call:

Array [

  • "git --version",
  • "git",
  • Array [
  • "--version",
    
  • ],
    ]

Number of calls: 1

❯ tests/core/file/gitCommand.test.ts:38:33


Line range hint 85-101: Same array mismatch in the fetch tests.
All references to git -C ... fetch ... likewise need updating to ['-C', directory, 'fetch', ...].

🧰 Tools
🪛 GitHub Check: Test (macos-latest, 20.x)

[failure] 99-99: tests/core/file/gitCommand.test.ts > gitCommand > execGitShallowClone > should throw error when git fetch fails
AssertionError: expected 1st "spy" call to have been called with [ 'git -C /tmp/repo init' ]

  • Expected
  • Received

    Array [

  • "git -C /tmp/repo init",
  • "git",
  • Array [
  • "-C",
    
  • "/tmp/repo",
    
  • "init",
    
  • ],
    ]

❯ tests/core/file/gitCommand.test.ts:99:33

🪛 GitHub Check: Test (macos-latest, 18.x)

[failure] 99-99: tests/core/file/gitCommand.test.ts > gitCommand > execGitShallowClone > should throw error when git fetch fails
AssertionError: expected 1st "spy" call to have been called with [ 'git -C /tmp/repo init' ]

  • Expected
  • Received

    Array [

  • "git -C /tmp/repo init",
  • "git",
  • Array [
  • "-C",
    
  • "/tmp/repo",
    
  • "init",
    
  • ],
    ]

❯ tests/core/file/gitCommand.test.ts:99:33

🪛 GitHub Check: Test (macos-latest, 18.20.0)

[failure] 99-99: tests/core/file/gitCommand.test.ts > gitCommand > execGitShallowClone > should throw error when git fetch fails
AssertionError: expected 1st "spy" call to have been called with [ 'git -C /tmp/repo init' ]

  • Expected
  • Received

    Array [

  • "git -C /tmp/repo init",
  • "git",
  • Array [
  • "-C",
    
  • "/tmp/repo",
    
  • "init",
    
  • ],
    ]

❯ tests/core/file/gitCommand.test.ts:99:33

🪛 GitHub Check: Test (ubuntu-latest, 23.x)

[failure] 99-99: tests/core/file/gitCommand.test.ts > gitCommand > execGitShallowClone > should throw error when git fetch fails
AssertionError: expected 1st "spy" call to have been called with [ 'git -C /tmp/repo init' ]

  • Expected
  • Received

    Array [

  • "git -C /tmp/repo init",
  • "git",
  • Array [
  • "-C",
    
  • "/tmp/repo",
    
  • "init",
    
  • ],
    ]

❯ tests/core/file/gitCommand.test.ts:99:33

🪛 GitHub Check: Test (ubuntu-latest, 22.x)

[failure] 99-99: tests/core/file/gitCommand.test.ts > gitCommand > execGitShallowClone > should throw error when git fetch fails
AssertionError: expected 1st "spy" call to have been called with [ 'git -C /tmp/repo init' ]

  • Expected
  • Received

    Array [

  • "git -C /tmp/repo init",
  • "git",
  • Array [
  • "-C",
    
  • "/tmp/repo",
    
  • "init",
    
  • ],
    ]

❯ tests/core/file/gitCommand.test.ts:99:33

🪛 GitHub Check: Test (ubuntu-latest, 20.x)

[failure] 99-99: tests/core/file/gitCommand.test.ts > gitCommand > execGitShallowClone > should throw error when git fetch fails
AssertionError: expected 1st "spy" call to have been called with [ 'git -C /tmp/repo init' ]

  • Expected
  • Received

    Array [

  • "git -C /tmp/repo init",
  • "git",
  • Array [
  • "-C",
    
  • "/tmp/repo",
    
  • "init",
    
  • ],
    ]

❯ tests/core/file/gitCommand.test.ts:99:33

🪛 GitHub Check: Test (ubuntu-latest, 18.x)

[failure] 99-99: tests/core/file/gitCommand.test.ts > gitCommand > execGitShallowClone > should throw error when git fetch fails
AssertionError: expected 1st "spy" call to have been called with [ 'git -C /tmp/repo init' ]

  • Expected
  • Received

    Array [

  • "git -C /tmp/repo init",
  • "git",
  • Array [
  • "-C",
    
  • "/tmp/repo",
    
  • "init",
    
  • ],
    ]

❯ tests/core/file/gitCommand.test.ts:99:33

🪛 GitHub Check: Test (ubuntu-latest, 18.20.0)

[failure] 99-99: tests/core/file/gitCommand.test.ts > gitCommand > execGitShallowClone > should throw error when git fetch fails
AssertionError: expected 1st "spy" call to have been called with [ 'git -C /tmp/repo init' ]

  • Expected
  • Received

    Array [

  • "git -C /tmp/repo init",
  • "git",
  • Array [
  • "-C",
    
  • "/tmp/repo",
    
  • "init",
    
  • ],
    ]

❯ tests/core/file/gitCommand.test.ts:99:33


Line range hint 109-126: Short SHA fallback scenario also needs the updated array arguments.
Your code calls 'git', ['-C', directory, 'fetch', '-depth', '1', ...], but test expects the single-string format.

🧰 Tools
🪛 GitHub Check: Test (macos-latest, 20.x)

[failure] 122-122: tests/core/file/gitCommand.test.ts > gitCommand > execGitShallowClone > should handle short SHA correctly
AssertionError: expected 1st "spy" call to have been called with [ 'git -C /tmp/repo init' ]

  • Expected
  • Received

    Array [

  • "git -C /tmp/repo init",
  • "git",
  • Array [
  • "-C",
    
  • "/tmp/repo",
    
  • "init",
    
  • ],
    ]

❯ tests/core/file/gitCommand.test.ts:122:33

🪛 GitHub Check: Test (macos-latest, 18.x)

[failure] 122-122: tests/core/file/gitCommand.test.ts > gitCommand > execGitShallowClone > should handle short SHA correctly
AssertionError: expected 1st "spy" call to have been called with [ 'git -C /tmp/repo init' ]

  • Expected
  • Received

    Array [

  • "git -C /tmp/repo init",
  • "git",
  • Array [
  • "-C",
    
  • "/tmp/repo",
    
  • "init",
    
  • ],
    ]

❯ tests/core/file/gitCommand.test.ts:122:33

🪛 GitHub Check: Test (macos-latest, 18.20.0)

[failure] 122-122: tests/core/file/gitCommand.test.ts > gitCommand > execGitShallowClone > should handle short SHA correctly
AssertionError: expected 1st "spy" call to have been called with [ 'git -C /tmp/repo init' ]

  • Expected
  • Received

    Array [

  • "git -C /tmp/repo init",
  • "git",
  • Array [
  • "-C",
    
  • "/tmp/repo",
    
  • "init",
    
  • ],
    ]

❯ tests/core/file/gitCommand.test.ts:122:33

🪛 GitHub Check: Test (ubuntu-latest, 23.x)

[failure] 122-122: tests/core/file/gitCommand.test.ts > gitCommand > execGitShallowClone > should handle short SHA correctly
AssertionError: expected 1st "spy" call to have been called with [ 'git -C /tmp/repo init' ]

  • Expected
  • Received

    Array [

  • "git -C /tmp/repo init",
  • "git",
  • Array [
  • "-C",
    
  • "/tmp/repo",
    
  • "init",
    
  • ],
    ]

❯ tests/core/file/gitCommand.test.ts:122:33

🪛 GitHub Check: Test (ubuntu-latest, 22.x)

[failure] 122-122: tests/core/file/gitCommand.test.ts > gitCommand > execGitShallowClone > should handle short SHA correctly
AssertionError: expected 1st "spy" call to have been called with [ 'git -C /tmp/repo init' ]

  • Expected
  • Received

    Array [

  • "git -C /tmp/repo init",
  • "git",
  • Array [
  • "-C",
    
  • "/tmp/repo",
    
  • "init",
    
  • ],
    ]

❯ tests/core/file/gitCommand.test.ts:122:33

🪛 GitHub Check: Test (ubuntu-latest, 20.x)

[failure] 122-122: tests/core/file/gitCommand.test.ts > gitCommand > execGitShallowClone > should handle short SHA correctly
AssertionError: expected 1st "spy" call to have been called with [ 'git -C /tmp/repo init' ]

  • Expected
  • Received

    Array [

  • "git -C /tmp/repo init",
  • "git",
  • Array [
  • "-C",
    
  • "/tmp/repo",
    
  • "init",
    
  • ],
    ]

❯ tests/core/file/gitCommand.test.ts:122:33

🪛 GitHub Check: Test (ubuntu-latest, 18.x)

[failure] 122-122: tests/core/file/gitCommand.test.ts > gitCommand > execGitShallowClone > should handle short SHA correctly
AssertionError: expected 1st "spy" call to have been called with [ 'git -C /tmp/repo init' ]

  • Expected
  • Received

    Array [

  • "git -C /tmp/repo init",
  • "git",
  • Array [
  • "-C",
    
  • "/tmp/repo",
    
  • "init",
    
  • ],
    ]

❯ tests/core/file/gitCommand.test.ts:122:33

🪛 GitHub Check: Test (ubuntu-latest, 18.20.0)

[failure] 122-122: tests/core/file/gitCommand.test.ts > gitCommand > execGitShallowClone > should handle short SHA correctly
AssertionError: expected 1st "spy" call to have been called with [ 'git -C /tmp/repo init' ]

  • Expected
  • Received

    Array [

  • "git -C /tmp/repo init",
  • "git",
  • Array [
  • "-C",
    
  • "/tmp/repo",
    
  • "init",
    
  • ],
    ]

❯ tests/core/file/gitCommand.test.ts:122:33


135-147: Likewise for the remote ref not found scenario.
Ensure toHaveBeenNthCalledWith() matches execFileAsync('git', ['-C', directory, ...]).

🧰 Tools
🪛 GitHub Check: Test (macos-latest, 20.x)

[failure] 145-145: tests/core/file/gitCommand.test.ts > gitCommand > execGitShallowClone > should throw error when remote ref is not found, and it's not due to short SHA
AssertionError: expected 1st "spy" call to have been called with [ 'git -C /tmp/repo init' ]

  • Expected
  • Received

    Array [

  • "git -C /tmp/repo init",
  • "git",
  • Array [
  • "-C",
    
  • "/tmp/repo",
    
  • "init",
    
  • ],
    ]

❯ tests/core/file/gitCommand.test.ts:145:33

🪛 GitHub Check: Test (macos-latest, 18.x)

[failure] 145-145: tests/core/file/gitCommand.test.ts > gitCommand > execGitShallowClone > should throw error when remote ref is not found, and it's not due to short SHA
AssertionError: expected 1st "spy" call to have been called with [ 'git -C /tmp/repo init' ]

  • Expected
  • Received

    Array [

  • "git -C /tmp/repo init",
  • "git",
  • Array [
  • "-C",
    
  • "/tmp/repo",
    
  • "init",
    
  • ],
    ]

❯ tests/core/file/gitCommand.test.ts:145:33

🪛 GitHub Check: Test (macos-latest, 18.20.0)

[failure] 145-145: tests/core/file/gitCommand.test.ts > gitCommand > execGitShallowClone > should throw error when remote ref is not found, and it's not due to short SHA
AssertionError: expected 1st "spy" call to have been called with [ 'git -C /tmp/repo init' ]

  • Expected
  • Received

    Array [

  • "git -C /tmp/repo init",
  • "git",
  • Array [
  • "-C",
    
  • "/tmp/repo",
    
  • "init",
    
  • ],
    ]

❯ tests/core/file/gitCommand.test.ts:145:33

🪛 GitHub Check: Test (ubuntu-latest, 23.x)

[failure] 145-145: tests/core/file/gitCommand.test.ts > gitCommand > execGitShallowClone > should throw error when remote ref is not found, and it's not due to short SHA
AssertionError: expected 1st "spy" call to have been called with [ 'git -C /tmp/repo init' ]

  • Expected
  • Received

    Array [

  • "git -C /tmp/repo init",
  • "git",
  • Array [
  • "-C",
    
  • "/tmp/repo",
    
  • "init",
    
  • ],
    ]

❯ tests/core/file/gitCommand.test.ts:145:33

🪛 GitHub Check: Test (ubuntu-latest, 22.x)

[failure] 145-145: tests/core/file/gitCommand.test.ts > gitCommand > execGitShallowClone > should throw error when remote ref is not found, and it's not due to short SHA
AssertionError: expected 1st "spy" call to have been called with [ 'git -C /tmp/repo init' ]

  • Expected
  • Received

    Array [

  • "git -C /tmp/repo init",
  • "git",
  • Array [
  • "-C",
    
  • "/tmp/repo",
    
  • "init",
    
  • ],
    ]

❯ tests/core/file/gitCommand.test.ts:145:33

🪛 GitHub Check: Test (ubuntu-latest, 20.x)

[failure] 145-145: tests/core/file/gitCommand.test.ts > gitCommand > execGitShallowClone > should throw error when remote ref is not found, and it's not due to short SHA
AssertionError: expected 1st "spy" call to have been called with [ 'git -C /tmp/repo init' ]

  • Expected
  • Received

    Array [

  • "git -C /tmp/repo init",
  • "git",
  • Array [
  • "-C",
    
  • "/tmp/repo",
    
  • "init",
    
  • ],
    ]

❯ tests/core/file/gitCommand.test.ts:145:33

🪛 GitHub Check: Test (ubuntu-latest, 18.x)

[failure] 145-145: tests/core/file/gitCommand.test.ts > gitCommand > execGitShallowClone > should throw error when remote ref is not found, and it's not due to short SHA
AssertionError: expected 1st "spy" call to have been called with [ 'git -C /tmp/repo init' ]

  • Expected
  • Received

    Array [

  • "git -C /tmp/repo init",
  • "git",
  • Array [
  • "-C",
    
  • "/tmp/repo",
    
  • "init",
    
  • ],
    ]

❯ tests/core/file/gitCommand.test.ts:145:33

🪛 GitHub Check: Test (ubuntu-latest, 18.20.0)

[failure] 145-145: tests/core/file/gitCommand.test.ts > gitCommand > execGitShallowClone > should throw error when remote ref is not found, and it's not due to short SHA
AssertionError: expected 1st "spy" call to have been called with [ 'git -C /tmp/repo init' ]

  • Expected
  • Received

    Array [

  • "git -C /tmp/repo init",
  • "git",
  • Array [
  • "-C",
    
  • "/tmp/repo",
    
  • "init",
    
  • ],
    ]

❯ tests/core/file/gitCommand.test.ts:145:33

src/core/file/gitCommand.ts Show resolved Hide resolved
src/core/file/gitCommand.ts Show resolved Hide resolved
src/core/file/gitCommand.ts Show resolved Hide resolved
tests/core/file/gitCommand.test.ts Outdated Show resolved Hide resolved
tests/core/file/gitCommand.test.ts Outdated Show resolved Hide resolved
tests/core/file/gitCommand.test.ts Outdated Show resolved Hide resolved
@yamadashy yamadashy force-pushed the feat/secure-command branch from 14457a2 to 102027b Compare January 6, 2025 14:50
Copy link

cloudflare-workers-and-pages bot commented Jan 6, 2025

Deploying repomix with  Cloudflare Pages  Cloudflare Pages

Latest commit: 91c4b60
Status: ✅  Deploy successful!
Preview URL: https://58857765.repomix.pages.dev
Branch Preview URL: https://feat-secure-command.repomix.pages.dev

View logs

@yamadashy yamadashy force-pushed the feat/secure-command branch from 102027b to 3a16b16 Compare January 6, 2025 14:52
import fs from 'node:fs/promises';
import path from 'node:path';
import { promisify } from 'node:util';
import { logger } from '../../shared/logger.js';

const execAsync = promisify(exec);
const execFileAsync = promisify(execFile);

export const isGitInstalled = async (
Copy link

Choose a reason for hiding this comment

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

Suggested change
export const isGitInstalled = async (
/**
* Checks if Git is installed by executing the 'git --version' command.
*
* @param {Object} deps - Dependencies that can be injected for testing.
* @param {Function} deps.execFileAsync - Function to execute a file asynchronously.
* @returns {Promise<boolean>} - Returns true if Git is installed, false otherwise.
*/
export const isGitInstalled = async (

add docstring to isGitInstalled function

Copy link

codecov bot commented Jan 6, 2025

Codecov Report

Attention: Patch coverage is 77.77778% with 6 lines in your changes missing coverage. Please review.

Project coverage is 92.00%. Comparing base (49b62c5) to head (91c4b60).
Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
src/core/file/gitCommand.ts 77.77% 6 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #270      +/-   ##
==========================================
- Coverage   92.23%   92.00%   -0.23%     
==========================================
  Files          44       44              
  Lines        2125     2140      +15     
  Branches      463      467       +4     
==========================================
+ Hits         1960     1969       +9     
- Misses        165      171       +6     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@yamadashy yamadashy force-pushed the feat/secure-command branch from 3a16b16 to 91c4b60 Compare January 6, 2025 15:23
@yamadashy yamadashy merged commit 48bb8eb into main Jan 6, 2025
42 checks passed
@yamadashy yamadashy deleted the feat/secure-command branch January 6, 2025 15:26
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