diff --git a/.github/workflows/cr.yml b/.github/workflows/cr.yml index 98d2e30..cb19bcb 100644 --- a/.github/workflows/cr.yml +++ b/.github/workflows/cr.yml @@ -8,7 +8,7 @@ on: - opened # Triggers when a PR is opened - reopened # Triggers when a PR is reopened - synchronize # Triggers when a commit is pushed to the PR - # - labeled # Triggers when a label is added to the PR + # - labeled # Triggers when a label is added to the PR # fix: GraphQL: Resource not accessible by integration (addComment) error permissions: @@ -16,7 +16,7 @@ permissions: jobs: setup-deepseek-review: - runs-on: ubuntu-latest + runs-on: macos-latest name: Code Review # Make sure the code review happens only when the PR has the label 'ai review' # if: contains(github.event.pull_request.labels.*.name, 'ai review') diff --git a/nu/review.nu b/nu/review.nu index ea0ec7d..c6ee61f 100644 --- a/nu/review.nu +++ b/nu/review.nu @@ -196,17 +196,31 @@ export def get-diff [ if ($content | is-empty) { print $'(ansi g)Nothing to review.(ansi reset)'; exit $ECODE.SUCCESS } + let awk_bin = (prepare-awk) if ($include | is-not-empty) { let patterns = $include | split row ',' - $content = $content | awk (generate-include-regex $patterns) + $content = $content | ^$awk_bin (generate-include-regex $patterns) } if ($exclude | is-not-empty) { let patterns = $exclude | split row ',' - $content = $content | awk (generate-exclude-regex $patterns) + $content = $content | ^$awk_bin (generate-exclude-regex $patterns) } $content } +# Prepare gawk for macOS +export def prepare-awk [] { + if (is-installed awk) { + print $'Current awk version: (awk --version | lines | first)' + } + if ($env.GITHUB_ACTIONS? != 'true') { return 'awk' } + if (sys host | get name) == 'Darwin' { + brew install gawk + print $'Current gawk version: (gawk --version | lines | first)' + } + 'gawk' +} + # Compact the record by removing empty columns export def compact-record []: record -> record { let record = $in