Skip to content

fix: use grep -E + sed instead of grep -P in sync-compat.sh for macOS compatibility - #49127

Merged
pelikhan merged 1 commit into
mainfrom
copilot/fix-github-actions-job
Jul 30, 2026
Merged

fix: use grep -E + sed instead of grep -P in sync-compat.sh for macOS compatibility#49127
pelikhan merged 1 commit into
mainfrom
copilot/fix-github-actions-job

Conversation

Copilot AI commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

make build fails on macOS because BSD grep doesn't support -P (Perl regex). The sync-compat.sh script used grep -oP to extract DefaultCopilotVersion from the Go constants file.

Changes

  • scripts/sync-compat.sh: Replace grep -oP '...\K[^"]+' with grep -E '^\s*const DefaultCopilotVersion' | sed -E 's/.*"([^"]+)".*/\1/'
    • The ^ anchor is required to exclude the commented-out example line (// const DefaultCopilotVersion ...) which would otherwise be matched and return the wrong version
-COPILOT_VERSION=$(grep -oP '^\s*const DefaultCopilotVersion\s+Version\s*=\s*"\K[^"]+' "$CONSTANTS_FILE")
+COPILOT_VERSION=$(grep -E '^\s*const DefaultCopilotVersion' "$CONSTANTS_FILE" | sed -E 's/.*"([^"]+)".*/\1/')

…nc-compat.sh

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot AI changed the title fix: replace grep -P with grep -E + sed for macOS compatibility in sync-compat.sh fix: use grep -E + sed instead of grep -P in sync-compat.sh for macOS compatibility Jul 30, 2026
Copilot AI requested a review from pelikhan July 30, 2026 12:18
@pelikhan
pelikhan marked this pull request as ready for review July 30, 2026 12:19
Copilot AI review requested due to automatic review settings July 30, 2026 12:19
@pelikhan
pelikhan merged commit 658fecc into main Jul 30, 2026
39 of 51 checks passed
@pelikhan
pelikhan deleted the copilot/fix-github-actions-job branch July 30, 2026 12:19
@github-actions

github-actions Bot commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

PR Code Quality Reviewer completed the code quality review.

Warning

threat detection engine error
The threat detection engine encountered an error and could not complete analysis. This is a tooling failure, not a security finding.

Details

The threat detection engine failed to produce results.

Review the workflow run logs for details.

@github-actions

github-actions Bot commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

🧠 Matt Pocock Skills Reviewer has completed the skills-based review. ✅

Warning

threat detection engine error
The threat detection engine encountered an error and could not complete analysis. This is a tooling failure, not a security finding.

Details

The threat detection engine failed to produce results.

Review the workflow run logs for details.

@github-actions

github-actions Bot commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

Test Quality Sentinel completed test quality analysis.

Warning

threat detection engine error
The threat detection engine encountered an error and could not complete analysis. This is a tooling failure, not a security finding.

Details

The threat detection engine failed to produce results.

Review the workflow run logs for details.

No test files were added or modified in this PR. Test Quality Sentinel skipped.

@github-actions

github-actions Bot commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

Design Decision Gate 🏗️ completed the design decision gate check.

No ADR enforcement needed: PR #49127 does not have the 'implementation' label and has 0 new lines of code in business logic directories (threshold: 100).

Copilot AI 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.

Pull request overview

Updates compatibility syncing to avoid GNU-only grep -P.

Changes:

  • Replaces Perl-regex extraction with grep -E and sed -E.
  • Anchors matching to exclude commented examples.
Show a summary per file
File Description
scripts/sync-compat.sh Revises Copilot version extraction for macOS compatibility.

Review details

Tip

Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

  • Files reviewed: 1/1 changed files
  • Comments generated: 1
  • Review effort level: Medium

Comment thread scripts/sync-compat.sh

# Extract DefaultCopilotVersion from Go constants file
COPILOT_VERSION=$(grep -oP '^\s*const DefaultCopilotVersion\s+Version\s*=\s*"\K[^"]+' "$CONSTANTS_FILE")
COPILOT_VERSION=$(grep -E '^\s*const DefaultCopilotVersion' "$CONSTANTS_FILE" | sed -E 's/.*"([^"]+)".*/\1/')

@github-actions github-actions 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.

Warning

threat detection engine error
The threat detection engine encountered an error and could not complete analysis. This is a tooling failure, not a security finding.

Details

The threat detection engine failed to produce results.

Review the workflow run logs for details.

Verdict: Approve

Single-line, well-scoped fix. Verified the new grep -E ... | sed -E pipeline correctly extracts 1.0.75 from pkg/constants/version_constants.go and correctly skips the commented-out example line (// const DefaultCopilotVersion ...) thanks to the ^ anchor. No correctness, security, or maintainability issues found in the diff.

Analysis notes
  • Tested the exact replacement command against the current constants file; it returns the correct version.
  • The ^\s*const anchor properly excludes the //-prefixed doc-comment example, preserving the original script's intended behavior.
  • No test coverage exists for this script either before or after the change, but that's pre-existing and out of scope for this minimal portability fix.

🔎 Code quality review by PR Code Quality Reviewer · auto · 13.9 AIC · ⊞ 7.8K
Comment /review to run again

@github-actions github-actions 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.

Warning

threat detection engine error
The threat detection engine encountered an error and could not complete analysis. This is a tooling failure, not a security finding.

Details

The threat detection engine failed to produce results.

Review the workflow run logs for details.

The fix correctly replaces grep -P (Perl regex, unavailable on macOS) with a portable grep -E | sed pipeline. The sed pattern accurately extracts the version string. Change is minimal, correct, and POSIX-compatible.

🧵 Reviewed using Impeccable skills by Impeccable Skills Reviewer · sonnet46 · 9.92 AIC · ⊞ 5.3K

@github-actions github-actions 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.

Warning

threat detection engine error
The threat detection engine encountered an error and could not complete analysis. This is a tooling failure, not a security finding.

Details

The threat detection engine failed to produce results.

Review the workflow run logs for details.

Skills-Based Review 🧠

Applied /diagnosing-bugs — the fix is correct and well-scoped.

📋 Key Themes & Highlights

Key Themes

  • Root cause addressed: BSD grep on macOS does not support -P; replacing with grep -E | sed is the right POSIX-compatible approach.
  • ^ anchor is essential: The commented example line in version_constants.go (// const DefaultCopilotVersion Version = "0.0.369") would have matched without the anchor, returning the wrong version. The PR description correctly calls this out.
  • Missing regression test: There is no shell-based test that verifies sync-compat.sh extracts the correct version. If the regex ever regresses, CI on Linux would still pass silently.

Positive Highlights

  • ✅ Minimal, targeted one-line change — no collateral changes
  • ✅ Good PR description explains both the macOS compat issue and the ^ anchor rationale
  • sed -E used consistently, avoiding GNU-only extensions

🧠 Reviewed using Matt Pocock's skills by Matt Pocock Skills Reviewer · sonnet46 · 24.2 AIC · ⊞ 7K
Comment /matt to run again

@github-actions

Copy link
Copy Markdown
Contributor

🎉 This pull request is included in a new release.

Release: v0.84.1

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.

3 participants