home-config/fish/functions/_tide_sub_bug-report.fish
ddd6e973d651b9d9c4d160c8ebb288daa071e259
· 3.1 KB · 73 lines
raw
| 1 | function _tide_sub_bug-report |
| 2 | argparse c/clean v/verbose check -- $argv |
| 3 | |
| 4 | set -l fish_path (status fish-path) |
| 5 | |
| 6 | if set -q _flag_clean |
| 7 | HOME=(mktemp -d) $fish_path --init-command "curl --silent \ |
| 8 | https://raw.githubusercontent.com/jorgebucaran/fisher/main/functions/fisher.fish | |
| 9 | source && fisher install ilancosman/tide@v6" |
| 10 | else if set -q _flag_verbose |
| 11 | set --long | string match -r "^_?tide.*" | # Get only tide variables |
| 12 | string match -r --invert "^_tide_prompt_var.*" # Remove _tide_prompt_var |
| 13 | else |
| 14 | set -l fish_version ($fish_path --version | string match -r "fish, version (\d\.\d\.\d)")[2] |
| 15 | _tide_check_version Fish fish-shell/fish-shell "(\d\.\d\.\d)" $fish_version || return |
| 16 | |
| 17 | set -l tide_version (tide --version | string match -r "tide, version (\d\.\d\.\d)")[2] |
| 18 | _tide_check_version Tide IlanCosman/tide "v(\d\.\d\.\d)" $tide_version || return |
| 19 | |
| 20 | if command --query git |
| 21 | test (git --version | string match -r "git version ([\d\.]*)" | string replace --all . '')[2] -gt 2220 |
| 22 | _tide_check_condition \ |
| 23 | "Your git version is too old." \ |
| 24 | "Tide requires at least version 2.22." \ |
| 25 | "Please update before submitting a bug report." || return |
| 26 | end |
| 27 | |
| 28 | # Check that omf is not installed |
| 29 | not functions --query omf |
| 30 | _tide_check_condition \ |
| 31 | "Tide does not work with oh-my-fish installed." \ |
| 32 | "Please uninstall it before submitting a bug report." || return |
| 33 | |
| 34 | if not set -q _flag_check |
| 35 | set -l fish_startup_time ($fish_path -ic "time $fish_path -c exit" 2>| |
| 36 | string match -r "Executed in(.*)fish" | string trim)[2] |
| 37 | |
| 38 | read --local --prompt-str "What operating system are you using? (e.g Ubuntu 20.04): " os |
| 39 | read --local --prompt-str "What terminal emulator are you using? (e.g Kitty): " terminal_emulator |
| 40 | |
| 41 | printf '%b\n' "\nPlease copy the following information into the issue:\n" \ |
| 42 | "fish version: $fish_version" \ |
| 43 | "tide version: $tide_version" \ |
| 44 | "term: $TERM" \ |
| 45 | "os: $os" \ |
| 46 | "terminal emulator: $terminal_emulator" \ |
| 47 | "fish startup: $fish_startup_time" \ |
| 48 | "fisher plugins: $_fisher_plugins" |
| 49 | end |
| 50 | end |
| 51 | end |
| 52 | |
| 53 | function _tide_check_version -a program_name repo_name regex_to_get_version current_version |
| 54 | curl --silent https://github.com/$repo_name/releases/latest | |
| 55 | string match -r ".*$repo_name/releases/tag/$regex_to_get_version.*" | |
| 56 | read --local --line __ latestVersion |
| 57 | |
| 58 | string match --quiet -r "^$latestVersion" "$current_version" |
| 59 | _tide_check_condition \ |
| 60 | "Your $program_name version is out of date." \ |
| 61 | "The latest is $latestVersion. You have $current_version." \ |
| 62 | "Please update before submitting a bug report." |
| 63 | end |
| 64 | |
| 65 | function _tide_check_condition |
| 66 | if test "$status" != 0 |
| 67 | set_color red |
| 68 | printf '%s\n' $argv |
| 69 | set_color normal |
| 70 | return 1 |
| 71 | end |
| 72 | return 0 |
| 73 | end |