From e361a8dec0d02fc56507b657e91521073e5f5b81 Mon Sep 17 00:00:00 2001 From: LoricAndre <57358788+LoricAndre@users.noreply.github.com> Date: Thu, 7 May 2026 14:20:49 +0200 Subject: [PATCH] chore(ci): readd PR check (#1068) * chore(ci): readd PR check * fix(ci): use pull_request event * fix(ci): bash syntax * fix(ci): pass git cliff context as jq-generated file * fix(ci): simpler check for changes * fix(ci): output message if no diff too * fix(ci): rerun on edit * fix(ci): exit codes * chore: fix typos (ci should fail) * chore: generate files --- .github/workflows/pr.yml | 104 ++++++++++++++++++++++++++++++ Cargo.toml | 2 +- benches/cli.rs | 10 +-- flake.nix | 132 ++++++++++++++++++++------------------- man/man1/sk.1 | 40 ++++++------ shell/completion.fish | 6 +- shell/completion.nu | 4 +- shell/completion.zsh | 6 +- src/options.rs | 48 +++++++------- 9 files changed, 231 insertions(+), 121 deletions(-) create mode 100644 .github/workflows/pr.yml diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml new file mode 100644 index 00000000..3fd61c9e --- /dev/null +++ b/.github/workflows/pr.yml @@ -0,0 +1,104 @@ +on: + pull_request: + types: + - opened + - synchronize + - reopened + - edited + +jobs: + check-title: + runs-on: ubuntu-latest + steps: + - name: Create git-cliff mock context + env: + CONTEXT: > + [ + { + "commits": [{ + "id": "foo", + "message": $msg, + "links": [], + "author": { + "name": "", + "timestamp": 1 + }, + "committer": { + "name": "", + "timestamp": 1 + }, + "merge_commit": false, + "github": { + "pr_labels": [], + "is_first_time": false + }, + "gitlab": { + "pr_labels": [], + "is_first_time": false + }, + "gitea": { + "pr_labels": [], + "is_first_time": false + }, + "bitbucket": { + "pr_labels": [], + "is_first_time": false + }, + "azure_devops": { + "pr_labels": [], + "is_first_time": false + }, + }], + "github": { "contributors": [] }, + "gitlab": { "contributors": [] }, + "gitea": { "contributors": [] }, + "bitbucket": { "contributors": [] }, + "azure_devops": { "contributors": [] }, + "submodule_commits": {} + } + ] + PR_TITLE: ${{ github.event.pull_request.title }} + run: | + jq -nc --arg msg "$PR_TITLE" "$CONTEXT" | tee git-cliff-context.json + - name: Generate mock changelog entry + id: git-cliff + uses: orhun/git-cliff-action@v4 + with: + args: > + --from-context git-cliff-context.json -s all + - name: Check generated entry + run: | + echo "Generated:" + cat "${{ steps.git-cliff.outputs.changelog }}" + echo "Checking..." + cat "${{ steps.git-cliff.outputs.changelog }}" | grep -Ev '^(## \[unreleased\]|)$' | grep -q '^.\+$' + check-generated-files: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v6 + - name: Cache + uses: Swatinem/rust-cache@v2 + with: + key: ${{ runner.os }} + add-job-id-key: "false" + add-rust-environment-hash-key: "false" + env-vars: "____" + cache-on-failure: "true" + cache-all-crates: "true" + - name: Generate files + run: | + cargo run -- --man > ./man/man1/sk.1 + cargo run -- --shell bash > ./shell/completion.bash + cargo run -- --shell zsh > ./shell/completion.zsh + cargo run -- --shell fish > ./shell/completion.fish + cargo run -- --shell nushell > ./shell/completion.nu + - name: Check diff + run: | + if git diff --exit-code; then + echo "No changes to generated files found, PR is safe to merge" + exit 0 + else + echo "Found changes to generated files, regenerate them locally and push them using 'just generate-files'" + exit 1 + fi diff --git a/Cargo.toml b/Cargo.toml index ed9b28a0..d11fb67e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -25,7 +25,7 @@ required-features = ["cli"] [features] # Default is destined to the CLI, not to library usage. default = ["cli", "frizbee"] -# Everyting needed to use skim as a cli (argument parsing, shell integrations...). This should not be needed for most libraries. +# Everything needed to use skim as a cli (argument parsing, shell integrations...). This should not be needed for most libraries. cli = ["dep:clap", "dep:clap_complete", "dep:shlex", "dep:env_logger", "dep:clap_mangen"] # Include frizbee as a matching algorithm frizbee = ["dep:frizbee"] diff --git a/benches/cli.rs b/benches/cli.rs index da87c2e9..427ef37e 100644 --- a/benches/cli.rs +++ b/benches/cli.rs @@ -1439,7 +1439,7 @@ fn cmd_plot(args: &PlotArgs) -> std::result::Result<(), Box std::result::Result<(), Box std::result::Result<(), Box std::result::Result<(), Box std::result::Result<(), Box\fR [default: [\\t\\n ]+] Delimiter between fields -In regex format, default to AWK\-style. Escape sequences like \\x00, \\t, \\n are supported. +In regex format, defaults to AWK\-style. Escape sequences like \\x00, \\t, \\n are supported. .TP \fB\-e\fR, \fB\-\-exact\fR Run in exact mode @@ -137,7 +137,7 @@ skim_v2: Previous skim fuzzy matching algorithm (v2) \fB\-\-case\fR \fI\fR [default: smart] Case sensitivity -Determines whether or not to ignore case while matching Note: this is not used for the Frizbee matcher, it uses a penalty system to favor case\-sensitivity without enforcing it +Determines whether or not to ignore case while matching Note: this is not used for the Frizbee matcher, which uses a penalty system to favor case\-sensitivity without enforcing it .br .br @@ -157,7 +157,7 @@ Enable typo\-tolerant matching When passed without a value (\-\-typos), uses adaptive formula (pattern_length / 4). When passed with a value (e.g. \-\-typos=2), uses that exact number as the maximum allowed typos. \-\-typos=0 explicitly disables typo tolerance. Applies to both fzy and frizbee matchers. .TP \fB\-\-no\-typos\fR -Disable typo\-resistant matching +Disable typo\-tolerant matching .TP \fB\-\-normalize\fR Normalize unicode characters @@ -212,19 +212,19 @@ Note: if no argument is supplied to reload, the default command is run. You can use the same placeholder expressions as in \-\-preview. -sk switches to the alternate screen when executing a command. However, if the command is ex‐ -pected to complete quickly, and you are not interested in its output, you might want to use exe‐ -cute\-silent instead, which silently executes the command without the switching. Note that sk +`sk` switches to the alternate screen when executing a command. However, if the command is +expected to complete quickly, and you are not interested in its output, you might want to use +execute\-silent instead, which silently executes the command without the switching. Note that sk will not be responsive until the command is complete. For asynchronous execution, start your -command as a background process (i.e. appending &). +command as a background process (i.e. appending `&`). -With if\-query\-empty and if\-query\-not\-empty action, you could specify the action to execute de‐ -pends on the query condition. For example: +With the `if\-query\-empty` and `if\-query\-not\-empty` actions, you could specify the action to execute +depending on the query condition. For example: `sk \-\-bind \*(Aqctrl\-d:if\-query\-empty(abort)+delete\-char\*(Aq` If the query is empty, skim will execute abort action, otherwise execute delete\-char action. It -is equal to ‘delete\-char/eof‘. +is equal to \*(Aqdelete\-char/eof\*(Aq. .TP \fB\-m\fR, \fB\-\-multi\fR Enable multiple selection @@ -240,7 +240,7 @@ Disable mouse \fB\-c\fR, \fB\-\-cmd\fR \fI\fR Command to invoke dynamically in interactive mode -Will be invoked using sh \-c on unix\-like systems and cmd /c on Windows +Will be invoked using sh \-c on Unix\-like systems and cmd /c on Windows .TP \fB\-i\fR, \fB\-\-interactive\fR Start skim in interactive mode @@ -281,8 +281,8 @@ Do not clear previous line if the command returns an empty result Do not clear previous items if new command returns empty result. This might be useful to reduce flickering when typing new commands and the half\-complete commands are not valid. -This is not the default behavior because similar use cases for grep and rg have already been op‐ -timized where empty query results actually mean "empty" and previous results should be +This is not the default behavior because similar use cases for `grep` and `rg` have already been +optimized where empty query results actually mean "empty" and previous results should be cleared. .TP \fB\-\-no\-clear\-start\fR @@ -357,7 +357,7 @@ Set prompt in command mode Set selected item icon .TP \fB\-\-multi\-selector\fR \fI\fR [default: >] -Set selected item icon +Set multi\-selected item icon .SH DISPLAY .TP \fB\-\-ansi\fR @@ -466,7 +466,7 @@ Run in a tmux or zellij popup Format: `sk \-\-popup [,SIZE[%]][,SIZE[%]]` Note: this will try to detect a Zellij session, then a Tmux session -This means that in nested sesions, skim will prioritize Zellij over Tmux +This means that in nested sessions, `skim` will prioritize Zellij over Tmux .SH HISTORY .TP \fB\-\-history\fR \fI\fR @@ -494,8 +494,8 @@ Maximum number of query history entries to keep Preview command Execute the given command for the current line and display the result on the preview window. {} in the command -is the placeholder that is replaced to the single\-quoted string of the current line. To transform the replace‐ -ment string, specify field index expressions between the braces (See FIELD INDEX EXPRESSION for the details). +is the placeholder that is replaced to the single\-quoted string of the current line. To transform the +replacement string, specify field index expressions between the braces (See FIELD INDEX EXPRESSION for the details). **Examples**: @@ -510,11 +510,11 @@ Format: [up|down|left|right][:SIZE][:hidden][:[no]wrap][:[no]pty][:+SCROLL[\-OFF Determine the layout of the preview window. If the argument ends with: hidden, the preview window will be hidden by default until toggle\-preview action is triggered. Long lines are truncated by default. Line wrap can be enabled with :wrap flag. For more interactive commands or previews that draw complex interfaces, the preview can use a PTY with the :pty flag. -Note: the preview will run in a PTY (interactive session) on linux and when wrap is unset +Note: the preview will run in a PTY (interactive session) on Linux and when wrap is unset SIZE can be either: \- 0, which will hide the preview window \- A positive size (eg 20) \- A percentage of the total size (eg 50%) \- A negative size, which will set the size of everything but the preview to that value -+SCROLL[\-OFFSET] determines the initial scroll offset of the preview window. SCROLL can be either a numeric integer or a single\-field index expression that refers to a numeric integer. The optional \-OFFSET part is for adjusting the base offset so that you can see the text above it. It should be given as a numeric integer (\-INTEGER), or as a denom‐ inator form (\-/INTEGER) for specifying a fraction of the preview window height. ++SCROLL[\-OFFSET] determines the initial scroll offset of the preview window. SCROLL can be either a numeric integer or a single\-field index expression that refers to a numeric integer. The optional \-OFFSET part is for adjusting the base offset so that you can see the text above it. It should be given as a numeric integer (\-INTEGER), or as a denominator form (\-/INTEGER) for specifying a fraction of the preview window height. Examples: @@ -577,7 +577,7 @@ Do not enter the TUI if the query passed in \-q does not match any item \fB\-\-sync\fR Synchronous search for multi\-staged filtering -Synchronous search for multi\-staged filtering. If specified, skim will launch ncurses finder only after the input stream is complete. e.g. sk \-\-multi | sk \-\-sync +Synchronous search for multi\-staged filtering. If specified, skim will launch the TUI finder only after the input stream is complete. e.g. sk \-\-multi | sk \-\-sync .TP \fB\-\-pre\-select\-n\fR \fI\fR [default: 0] Pre\-select the first n items in multi\-selection mode diff --git a/shell/completion.fish b/shell/completion.fish index 0aceeb7c..e9e6ecf5 100644 --- a/shell/completion.fish +++ b/shell/completion.fish @@ -41,7 +41,7 @@ complete -c sk -l margin -d 'Screen margin' -r complete -c sk -s p -l prompt -d 'Set prompt' -r complete -c sk -l cmd-prompt -d 'Set prompt in command mode' -r complete -c sk -l selector -d 'Set selected item icon' -r -complete -c sk -l multi-selector -d 'Set selected item icon' -r +complete -c sk -l multi-selector -d 'Set multi-selected item icon' -r complete -c sk -l tabstop -d 'Number of spaces that make up a tab' -r complete -c sk -l ellipsis -d 'The characters used to display truncated lines' -r complete -c sk -l info -d 'Set matching result count display position' -r @@ -88,7 +88,7 @@ complete -c sk -l remote -d 'Send commands to an IPC socket with optional name ( complete -c sk -l popup -d 'Run in a tmux or zellij popup' -r complete -c sk -l log-level -d 'Set the log level' -r complete -c sk -l log-file -d 'Pipe log output to a file' -r -complete -c sk -l flags -d 'Feature flags' -r -f -a "no-preview-pty\t'Disable preview PTY on linux' +complete -c sk -l flags -d 'Feature flags' -r -f -a "no-preview-pty\t'Disable preview PTY on Linux' show-score\t'Display the item\'s match score before its value in the item list (for matcher debugging)' show-index\t'Display the item\'s index before its value in the item list' single-reader\t'Limit the reader thread pool to a single thread' @@ -132,7 +132,7 @@ complete -c sk -l tac -d 'Show results in reverse order' complete -c sk -l no-sort -d 'Do not sort the results' complete -c sk -s e -l exact -d 'Run in exact mode' complete -c sk -l regex -d 'Start in regex mode instead of fuzzy-match' -complete -c sk -l no-typos -d 'Disable typo-resistant matching' +complete -c sk -l no-typos -d 'Disable typo-tolerant matching' complete -c sk -l normalize -d 'Normalize unicode characters' complete -c sk -l last-match -d 'Highlight the last match found, not the first one This makes tiebreak more pertinent on path items where we want to prioritize a match on the last parts' complete -c sk -s m -l multi -d 'Enable multiple selection' diff --git a/shell/completion.nu b/shell/completion.nu index a435055b..6b3085c0 100644 --- a/shell/completion.nu +++ b/shell/completion.nu @@ -46,7 +46,7 @@ module completions { --algo: string@"nu-complete sk algorithm" # Fuzzy matching algorithm --case: string@"nu-complete sk case" # Case sensitivity --typos: string # Enable typo-tolerant matching - --no-typos # Disable typo-resistant matching + --no-typos # Disable typo-tolerant matching --normalize # Normalize unicode characters --split-match: string # Enable split matching and set delimiter --last-match # Highlight the last match found, not the first one This makes tiebreak more pertinent on path items where we want to prioritize a match on the last parts @@ -78,7 +78,7 @@ module completions { --prompt(-p): string # Set prompt --cmd-prompt: string # Set prompt in command mode --selector: string # Set selected item icon - --multi-selector: string # Set selected item icon + --multi-selector: string # Set multi-selected item icon --ansi # Parse ANSI color codes in input strings --tabstop: string # Number of spaces that make up a tab --ellipsis: string # The characters used to display truncated lines diff --git a/shell/completion.zsh b/shell/completion.zsh index 95757e32..8840012a 100644 --- a/shell/completion.zsh +++ b/shell/completion.zsh @@ -53,7 +53,7 @@ reverse-list\:"Display from the top of the screen, prompt at the bottom"))' \ '--prompt=[Set prompt]:PROMPT:_default' \ '--cmd-prompt=[Set prompt in command mode]:CMD_PROMPT:_default' \ '--selector=[Set selected item icon]:SELECTOR_ICON:_default' \ -'--multi-selector=[Set selected item icon]:MULTI_SELECT_ICON:_default' \ +'--multi-selector=[Set multi-selected item icon]:MULTI_SELECT_ICON:_default' \ '--tabstop=[Number of spaces that make up a tab]:TABSTOP:_default' \ '--ellipsis=[The characters used to display truncated lines]:ELLIPSIS:_default' \ '--info=[Set matching result count display position]:INFO:_default' \ @@ -102,7 +102,7 @@ zsh\:"Zsh"))' \ '--popup=[Run in a tmux or zellij popup]::POPUP:_default' \ '--log-level=[Set the log level]:LOG_LEVEL:_default' \ '--log-file=[Pipe log output to a file]:LOG_FILE:_default' \ -'*--flags=[Feature flags]:FLAGS:((no-preview-pty\:"Disable preview PTY on linux" +'*--flags=[Feature flags]:FLAGS:((no-preview-pty\:"Disable preview PTY on Linux" show-score\:"Display the item'\''s match score before its value in the item list (for matcher debugging)" show-index\:"Display the item'\''s index before its value in the item list" single-reader\:"Limit the reader thread pool to a single thread" @@ -147,7 +147,7 @@ single-matcher\:"Limit the matcher thread pool to a single thread"))' \ '-e[Run in exact mode]' \ '--exact[Run in exact mode]' \ '--regex[Start in regex mode instead of fuzzy-match]' \ -'--no-typos[Disable typo-resistant matching]' \ +'--no-typos[Disable typo-tolerant matching]' \ '--normalize[Normalize unicode characters]' \ '--last-match[Highlight the last match found, not the first one This makes tiebreak more pertinent on path items where we want to prioritize a match on the last parts]' \ '-m[Enable multiple selection]' \ diff --git a/src/options.rs b/src/options.rs index 479ebe3b..175ec403 100644 --- a/src/options.rs +++ b/src/options.rs @@ -156,7 +156,7 @@ pub struct SkimOptions { /// Delimiter between fields /// - /// In regex format, default to AWK-style. Escape sequences like \x00, \t, \n are supported. + /// In regex format, defaults to AWK-style. Escape sequences like \x00, \t, \n are supported. #[cfg_attr( feature = "cli", arg(short, long, default_value = r"[\t\n ]+", value_parser = parse_delimiter_value, help_heading = "Search") @@ -197,7 +197,7 @@ pub struct SkimOptions { /// Case sensitivity /// /// Determines whether or not to ignore case while matching - /// Note: this is not used for the Frizbee matcher, it uses a penalty system to favor + /// Note: this is not used for the Frizbee matcher, which uses a penalty system to favor /// case-sensitivity without enforcing it #[cfg_attr( feature = "cli", @@ -217,7 +217,7 @@ pub struct SkimOptions { )] pub typos: Typos, - /// Disable typo-resistant matching + /// Disable typo-tolerant matching #[cfg_attr(feature = "cli", arg(long, overrides_with = "typos", help_heading = "Search"))] pub no_typos: bool, @@ -277,19 +277,19 @@ pub struct SkimOptions { /// /// You can use the same placeholder expressions as in --preview. /// - /// sk switches to the alternate screen when executing a command. However, if the command is ex‐ - /// pected to complete quickly, and you are not interested in its output, you might want to use exe‐ - /// cute-silent instead, which silently executes the command without the switching. Note that sk + /// `sk` switches to the alternate screen when executing a command. However, if the command is + /// expected to complete quickly, and you are not interested in its output, you might want to use + /// execute-silent instead, which silently executes the command without the switching. Note that sk /// will not be responsive until the command is complete. For asynchronous execution, start your - /// command as a background process (i.e. appending &). + /// command as a background process (i.e. appending `&`). /// - /// With if-query-empty and if-query-not-empty action, you could specify the action to execute de‐ - /// pends on the query condition. For example: + /// With the `if-query-empty` and `if-query-not-empty` actions, you could specify the action to execute + /// depending on the query condition. For example: /// /// `sk --bind 'ctrl-d:if-query-empty(abort)+delete-char'` /// /// If the query is empty, skim will execute abort action, otherwise execute delete-char action. It - /// is equal to ‘delete-char/eof‘. + /// is equal to 'delete-char/eof'. #[cfg_attr( feature = "cli", arg(short, long, help_heading = "Interface", verbatim_doc_comment, default_value = "", num_args=0..) @@ -315,7 +315,7 @@ pub struct SkimOptions { /// Command to invoke dynamically in interactive mode /// - /// Will be invoked using `sh -c` on unix-like systems and `cmd /c` on Windows + /// Will be invoked using `sh -c` on Unix-like systems and `cmd /c` on Windows #[cfg_attr(feature = "cli", arg(short, long, help_heading = "Interface"))] pub cmd: Option, @@ -365,8 +365,8 @@ pub struct SkimOptions { /// Do not clear previous items if new command returns empty result. This might be useful to /// reduce flickering when typing new commands and the half-complete commands are not valid. /// - /// This is not the default behavior because similar use cases for grep and rg have already been op‐ - /// timized where empty query results actually mean "empty" and previous results should be + /// This is not the default behavior because similar use cases for `grep` and `rg` have already been + /// optimized where empty query results actually mean "empty" and previous results should be /// cleared. #[cfg_attr(feature = "cli", arg(long, help_heading = "Interface", verbatim_doc_comment))] pub no_clear_if_empty: bool, @@ -463,7 +463,7 @@ pub struct SkimOptions { )] pub selector_icon: String, - /// Set selected item icon + /// Set multi-selected item icon #[cfg_attr( feature = "cli", arg( @@ -624,8 +624,8 @@ pub struct SkimOptions { /// Preview command /// /// Execute the given command for the current line and display the result on the preview window. {} in the command - /// is the placeholder that is replaced to the single-quoted string of the current line. To transform the replace‐ - /// ment string, specify field index expressions between the braces (See FIELD INDEX EXPRESSION for the details). + /// is the placeholder that is replaced to the single-quoted string of the current line. To transform the + /// replacement string, specify field index expressions between the braces (See FIELD INDEX EXPRESSION for the details). /// /// **Examples**: /// @@ -644,7 +644,7 @@ pub struct SkimOptions { /// Line wrap can be enabled with `:wrap` flag. /// For more interactive commands or previews that draw complex interfaces, the preview can use a PTY with the `:pty` flag. /// - /// Note: the preview will run in a PTY (interactive session) on linux and when `wrap` is unset + /// Note: the preview will run in a PTY (interactive session) on Linux and when `wrap` is unset /// /// SIZE can be either: /// - `0`, which will hide the preview window @@ -652,10 +652,10 @@ pub struct SkimOptions { /// - A percentage of the total size (eg `50%`) /// - A negative size, which will set the size of everything but the preview to that value /// - /// +SCROLL[-OFFSET] determines the initial scroll offset of the preview window. SCROLL can be either a numeric integer - /// or a single-field index expression that refers to a numeric integer. The optional -OFFSET part is for adjusting the - /// base offset so that you can see the text above it. It should be given as a numeric integer (-INTEGER), or as a denom‐ - /// inator form (-/INTEGER) for specifying a fraction of the preview window height. + /// +SCROLL[-OFFSET] determines the initial scroll offset of the preview window. SCROLL can be either a numeric integer + /// or a single-field index expression that refers to a numeric integer. The optional -OFFSET part is for adjusting the + /// base offset so that you can see the text above it. It should be given as a numeric integer (-INTEGER), or as a + /// denominator form (-/INTEGER) for specifying a fraction of the preview window height. /// /// **Examples**: /// ```bash @@ -743,7 +743,7 @@ pub struct SkimOptions { /// Synchronous search for multi-staged filtering /// /// Synchronous search for multi-staged filtering. If specified, - /// skim will launch ncurses finder only after the input stream is complete. + /// `skim` will launch the TUI finder only after the input stream is complete. /// e.g. `sk --multi | sk --sync` #[cfg_attr(feature = "cli", arg(long, help_heading = "Scripting"))] pub sync: bool, @@ -820,7 +820,7 @@ pub struct SkimOptions { /// /// Format: `sk --popup [,SIZE[%]][,SIZE[%]]` /// Note: this will try to detect a Zellij session, then a Tmux session - /// This means that in nested sesions, skim will prioritize Zellij over Tmux + /// This means that in nested sessions, `skim` will prioritize Zellij over Tmux #[cfg_attr(feature = "cli", arg(long, verbatim_doc_comment, help_heading = "Display", default_missing_value = "center,50%", num_args=0.., alias = "tmux"))] pub popup: Option, @@ -1340,7 +1340,7 @@ impl SkimOptions { #[derive(Copy, Clone, Debug, Eq, PartialEq)] #[cfg_attr(feature = "cli", derive(clap::ValueEnum))] pub enum FeatureFlag { - /// Disable preview PTY on linux + /// Disable preview PTY on Linux NoPreviewPty, /// Display the item's match score before its value in the item list (for matcher debugging) ShowScore,