_tide_sub_bug-report.fish 3.1 KB

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