tide/functions/_tide_sub_bug-report.fish

74 lines
3.0 KiB
Fish
Raw Normal View History

function _tide_sub_bug-report
2022-06-23 21:32:53 +03:00
argparse c/clean v/verbose check -- $argv
2022-04-22 22:47:38 +03:00
set -l fish_path (status fish-path)
2021-02-03 23:57:13 +03:00
if set -q _flag_clean
2022-04-22 22:47:38 +03:00
HOME=(mktemp -d) $fish_path --init-command "curl --silent \
2021-02-03 23:57:13 +03:00
https://raw.githubusercontent.com/jorgebucaran/fisher/main/functions/fisher.fish |
2023-10-04 07:16:59 +03:00
source && fisher install ilancosman/tide@v6"
2021-02-03 23:57:13 +03:00
else if set -q _flag_verbose
set --long | string match -r "^_?tide.*" | # Get only tide variables
string match -r --invert "^_tide_prompt_var.*" # Remove _tide_prompt_var
2021-02-03 23:57:13 +03:00
else
2024-01-06 21:16:33 +03:00
$fish_path --version | string match -qr "fish, version (?<fish_version>.*)"
_tide_check_version Fish fish-shell/fish-shell "(?<v>[\d.]+)" $fish_version || return
2024-01-06 21:16:33 +03:00
tide --version | string match -qr "tide, version (?<tide_version>.*)"
_tide_check_version Tide IlanCosman/tide "v(?<v>[\d.]+)" $tide_version || return
2021-04-13 02:48:01 +03:00
2022-06-23 21:38:28 +03:00
if command --query git
2024-01-06 20:57:55 +03:00
test (path sort (git --version) "git version 2.22.0")[1] = "git version 2.22.0"
2022-06-23 21:38:28 +03:00
_tide_check_condition \
"Your git version is too old." \
"Tide requires at least version 2.22." \
"Please update before submitting a bug report." || return
end
2021-05-26 19:12:21 +03:00
2021-04-13 02:48:01 +03:00
# Check that omf is not installed
2021-04-13 03:35:35 +03:00
not functions --query omf
2021-04-13 02:48:01 +03:00
_tide_check_condition \
"Tide does not work with oh-my-fish installed." \
2021-04-13 03:35:35 +03:00
"Please uninstall it before submitting a bug report." || return
2022-06-23 21:32:53 +03:00
if not set -q _flag_check
2024-01-06 21:16:33 +03:00
$fish_path -ic "time $fish_path -c exit" 2>|
string match -rg "Executed in(.*)fish" |
string trim | read -l fish_startup_time
2021-09-04 05:32:14 +03:00
2024-01-06 21:16:33 +03:00
read -l --prompt-str "What operating system are you using? (e.g Ubuntu 20.04): " os
read -l --prompt-str "What terminal emulator are you using? (e.g Kitty): " terminal_emulator
2021-09-04 05:39:44 +03:00
2022-06-23 21:32:53 +03:00
printf '%b\n' "\nPlease copy the following information into the issue:\n" \
"fish version: $fish_version" \
"tide version: $tide_version" \
"term: $TERM" \
"os: $os" \
"terminal emulator: $terminal_emulator" \
"fish startup: $fish_startup_time" \
"fisher plugins: $_fisher_plugins"
end
end
2021-03-02 20:46:40 +03:00
end
2024-01-06 20:49:37 +03:00
function _tide_check_version -a program_name repo_name regex_to_get_v installed_version
curl -sL https://github.com/$repo_name/releases/latest |
string match -qr "https://github.com/$repo_name/releases/tag/$regex_to_get_v"
2024-01-06 20:49:37 +03:00
string match -qr "^$v" "$installed_version" # Allow git versions, e.g 3.3.1-701-gceade1629
2021-04-13 02:48:01 +03:00
_tide_check_condition \
2021-05-12 23:13:51 +03:00
"Your $program_name version is out of date." \
2024-01-06 20:49:37 +03:00
"The latest is $v. You have $installed_version." \
2021-04-13 02:48:01 +03:00
"Please update before submitting a bug report."
end
function _tide_check_condition
2021-04-13 03:35:35 +03:00
if test "$status" != 0
2021-03-31 01:29:21 +03:00
set_color red
2021-04-13 03:35:35 +03:00
printf '%s\n' $argv
set_color normal
return 1
2021-03-31 01:29:21 +03:00
end
2021-04-13 03:35:35 +03:00
return 0
end