mirror of
https://github.com/alibaba/open-code-review.git
synced 2026-08-10 17:25:09 +00:00
Some checks are pending
CI / cross-compile (arm64, darwin) (push) Waiting to run
CI / cross-compile (arm64, linux) (push) Waiting to run
CI / cross-compile (arm64, windows) (push) Waiting to run
CI / test (push) Waiting to run
CI / cross-compile (amd64, darwin) (push) Waiting to run
CI / cross-compile (amd64, windows) (push) Waiting to run
CodeQL Advanced / Analyze (go) (push) Waiting to run
CodeQL Advanced / Analyze (actions) (push) Waiting to run
CodeQL Advanced / Analyze (javascript-typescript) (push) Waiting to run
Deploy Pages / build (push) Waiting to run
Deploy Pages / deploy (push) Blocked by required conditions
* chore: add SPDX license headers to all source files
Add Apache-2.0 SPDX license identifiers and copyright notices to all
tracked .go, .sh, .js, .mjs, .ts, and .tsx source files.
Introduce scripts/verify-license.sh and scripts/add-license.sh for
automated verification and bulk addition of license headers. Integrate
the check into CI (ci.yml) and the Makefile (license-check target as
a prerequisite of the existing check target).
This satisfies the OpenSSF Best Practices Badge requirements for
copyright_per_file and license_per_file.
* fix: restore execute permissions on scripts
* docs: add license header instructions to CONTRIBUTING guides
* docs: add license header instructions to pages contributing guides
* fix(pages): strip unclosed HTML comment markers to satisfy CodeQL
* fix: apply code review suggestions for license scripts
- Fix portability: detect macOS vs Linux stat for permission copy
- Fix has_header: check both SPDX and copyright (match verify logic)
- Fix is_ignored: match on path boundaries to avoid false positives
- Fix year extraction: use consistent pipeline across both scripts
- Fix Bash 3.2 compat: quote array length expansion for set -u
* fix(pages): use loop-until-clean for HTML comment stripping (CodeQL)
* fix(pages): use split/join instead of replace to avoid CodeQL false positive
CodeQL's js/incomplete-multi-character-sanitization rule flags any
.replace() that removes multi-character sequences like '<!--...-->',
regardless of context. The data here comes from readFileSync on the
project's own index.html (no untrusted input), making this a false
positive. Using split(regex).join('') achieves the same result without
triggering the taint-tracking rule.
64 lines
1.9 KiB
Go
64 lines
1.9 KiB
Go
// SPDX-License-Identifier: Apache-2.0
|
|
// Copyright 2026 alibaba/open-code-review Contributors
|
|
|
|
package main
|
|
|
|
import (
|
|
"fmt"
|
|
"os"
|
|
|
|
"github.com/spf13/cobra"
|
|
)
|
|
|
|
var completionCmd = &cobra.Command{
|
|
Use: "completion [bash|zsh|fish|powershell]",
|
|
Short: "Generate shell completion scripts",
|
|
Long: completionLongHelp,
|
|
ValidArgs: []string{"bash", "zsh", "fish", "powershell"},
|
|
Args: cobra.MatchAll(cobra.ExactArgs(1), cobra.OnlyValidArgs),
|
|
RunE: func(cmd *cobra.Command, args []string) error {
|
|
switch args[0] {
|
|
case "bash":
|
|
return rootCmd.GenBashCompletionV2(os.Stdout, true)
|
|
case "zsh":
|
|
return rootCmd.GenZshCompletion(os.Stdout)
|
|
case "fish":
|
|
return rootCmd.GenFishCompletion(os.Stdout, true)
|
|
case "powershell":
|
|
return rootCmd.GenPowerShellCompletionWithDesc(os.Stdout)
|
|
default:
|
|
return fmt.Errorf("unsupported shell: %s", args[0])
|
|
}
|
|
},
|
|
}
|
|
|
|
const completionLongHelp = `Generate shell completion scripts for OCR.
|
|
|
|
To load completions:
|
|
|
|
Bash:
|
|
$ source <(ocr completion bash)
|
|
# To load completions for each session, execute once:
|
|
# Linux:
|
|
$ ocr completion bash > /etc/bash_completion.d/ocr
|
|
# macOS:
|
|
$ ocr completion bash > $(brew --prefix)/etc/bash_completion.d/ocr
|
|
|
|
Zsh:
|
|
# If shell completion is not already enabled in your environment,
|
|
# you will need to enable it. You can execute the following once:
|
|
$ echo "autoload -U compinit; compinit" >> ~/.zshrc
|
|
# To load completions for each session, execute once:
|
|
$ ocr completion zsh > "${fpath[1]}/_ocr"
|
|
# You will need to start a new shell for this setup to take effect.
|
|
|
|
Fish:
|
|
$ ocr completion fish | source
|
|
# To load completions for each session, execute once:
|
|
$ ocr completion fish > ~/.config/fish/completions/ocr.fish
|
|
|
|
PowerShell:
|
|
PS> ocr completion powershell | Out-String | Invoke-Expression
|
|
# To load completions for every new session, run:
|
|
PS> ocr completion powershell > ocr.ps1
|
|
# and source this file from your PowerShell profile.`
|