Skip to content

Commit

Permalink
chore: update Links in comments and small touchups
Browse files Browse the repository at this point in the history
  • Loading branch information
LangLangBart committed Nov 10, 2024
1 parent ec85a75 commit 80eac30
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 11 deletions.
26 changes: 15 additions & 11 deletions gh-find-code
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ if ((GHFC_DEBUG_MODE)); then
PS4='+ $(zsh -c "print -Pr -- %D{%T:%3.}") [${BASH_SOURCE[0]:+${BASH_SOURCE[0]##*/}}:${FUNCNAME[0]:+${FUNCNAME[0]}():}${LINENO}]: '
fi
set -o xtrace

: "$BASH" "$BASH_VERSION"
# Ensure xtrace is enabled in all child processes started by 'fzf'; 'errexit' is too strict
execution_shell="$(which bash) -o xtrace -o nounset -o pipefail -c"
fi
Expand Down Expand Up @@ -95,8 +95,9 @@ error_handler() {
--highlight-line "$lineno" \
--language bash \
--line-range $((lineno - 3)):+7 \
--paging never \
--style numbers \
--terminal-width $((${COLUMNS:-$(tput cols)} - 4)) \
--terminal-width $((${COLUMNS:-$(command tput cols)} - 4)) \
--wrap never -- "${BASH_SOURCE[0]}" |
command sed 's/^/ /;4s/ />>/'
} >&2
Expand Down Expand Up @@ -142,12 +143,13 @@ gh_accept_raw="Accept: application/vnd.github.raw"
gh_accept_text_match="Accept: application/vnd.github.text-match+json"
gh_rest_api_version="X-GitHub-Api-Version:2022-11-28"

# https://github.com/junegunn/fzf/releases/tag/0.52.0
min_fzf_version="0.54.0"
# a bug with 'gh-browse' with relative paths was fixed
# This version fixed a bug where the item list didn't always update on the latest query version.
# https://github.com/junegunn/fzf/releases/tag/v0.56.1
min_fzf_version="0.56.1"
# A bug with 'gh-browse' with relative paths was fixed
# https://github.com/cli/cli/issues/7674
min_gh_version="2.37.0"
# requires 'urllib.parse'
# Requires 'urllib.parse'
# https://docs.python.org/3/library/urllib.parse.html
min_python_version="3.0.0"
python_executable=""
Expand All @@ -157,6 +159,7 @@ multiline_grep_executable=""
# filename in child processes.

# Default directory for trivial files
# https://dotat.at/@/2024-10-22-tmp.html#mktemp-in-shell
scratch_directory=$(command mktemp -d)
store_bat_langs="${scratch_directory}/bat_langs"
store_input_list="${scratch_directory}/input_list"
Expand Down Expand Up @@ -254,7 +257,7 @@ validate_environment() {
command awk -F ":" '{print $2}' | command tr ',' '\n' >"$store_bat_langs"

# Rule of Thumb: If it's listed under 'Utilities' in this link, don't check for it
# https://pubs.opengroup.org/onlinepubs/9699919799/utilities/contents.html
# https://pubs.opengroup.org/onlinepubs/9699919799.2016edition/utilities/contents.html
for value in column curl fzf gh; do
if ! command -v $value >/dev/null; then
die "'$value' was not found."
Expand Down Expand Up @@ -605,7 +608,7 @@ EOF
# the command outputs to stdout: https://tldp.org/LDP/abs/html/x9644.html#WAITHANG
(
# Run gh api commands with lower priority using nice
# https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap03.html#tag_03_244
# https://pubs.opengroup.org/onlinepubs/9699919799.2016edition/basedefs/V1_chap03.html#tag_03_244
if command nice -n 20 gh api "repos/${sanitized_owner_repo_name}/contents/${sanitized_file_path}" \
--cache "$gh_default_cache_time" \
--header "$gh_accept_raw" \
Expand Down Expand Up @@ -726,8 +729,9 @@ EOF

# TODO: Read up on how the GitHub Search API works and provide a better
# explanation of why some patterns contain newline characters.
# https://github.blog/engineering/the-technology-behind-githubs-new-code-search/
for pattern in "${pattern_array[@]}"; do
sanitized_patterns=$(command sed 's/[][?*+.$^(){}]/\\&/g' <<<"$pattern")
sanitized_patterns=$(command sed 's/[][?*+.$^(){}|]/\\&/g' <<<"$pattern")
grep_args+=("--regexp=${sanitized_patterns///\\n}")
done
command "$multiline_grep_executable" --multiline "${grep_args[@]}" -- \
Expand All @@ -738,8 +742,8 @@ EOF
grep_args+=("--regexp=$pattern")
done

# Use the '--text' flag, as grep will simply print 'Binary file … matches' if
# the file contains binary characters. It won't even throw an error.
# Use the '--text' flag, as grep will simply print 'Binary file … matches'
# if the file contains binary characters. It won't even throw an error.
# https://unix.stackexchange.com/questions/19907
command grep --fixed-strings "${grep_args[@]}" -- \
"${store_file_contents}_${index}_fetched" 2>"${redirect_location}" |
Expand Down
7 changes: 7 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -211,3 +211,10 @@ pre-commit install --hook-type commit-msg --hook-type pre-commit
# pre-commit installed at .git/hooks/commit-msg
# pre-commit installed at .git/hooks/pre-commit
```

---

## Noteworthy Projects
- [Official GitHub Search](https://github.com/search?type=code)
- [grep.app | code search](https://grep.app/)
- [k1LoW/gh-grep](https://github.com/k1LoW/gh-grep)

0 comments on commit 80eac30

Please sign in to comment.