|
|
|
@ -63,6 +63,7 @@ fi |
|
|
|
# |
|
|
|
# |
|
|
|
# Then paste the commit and hashes below. |
|
|
|
# Then paste the commit and hashes below. |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ZSH_CACHE_DIR="$HOME/.zsh" |
|
|
|
ZSH_CACHE_DIR="$HOME/.zsh" |
|
|
|
mkdir -p "$ZSH_CACHE_DIR" |
|
|
|
mkdir -p "$ZSH_CACHE_DIR" |
|
|
|
|
|
|
|
|
|
|
|
@ -88,23 +89,43 @@ _zshv2_sha256() { |
|
|
|
fi |
|
|
|
fi |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
_zshv2_download_verified() { |
|
|
|
_zshv2_file_has_sha256() { |
|
|
|
local url="$1" |
|
|
|
local file="$1" |
|
|
|
local dest="$2" |
|
|
|
local expected_sha="$2" |
|
|
|
local expected_sha="$3" |
|
|
|
local actual_sha |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
[[ -f "$file" ]] || return 1 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
actual_sha="$(_zshv2_sha256 "$file")" || return 1 |
|
|
|
|
|
|
|
[[ "$actual_sha" == "$expected_sha" ]] |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
_zshv2_install_verified_file() { |
|
|
|
|
|
|
|
local name="$1" |
|
|
|
|
|
|
|
local url="$2" |
|
|
|
|
|
|
|
local dest="$3" |
|
|
|
|
|
|
|
local expected_sha="$4" |
|
|
|
local tmp_file |
|
|
|
local tmp_file |
|
|
|
local actual_sha |
|
|
|
local actual_sha |
|
|
|
|
|
|
|
|
|
|
|
tmp_file="$(mktemp "${dest}.tmp.XXXXXX")" || return 1 |
|
|
|
if [[ -z "$url" || -z "$dest" || -z "$expected_sha" ]]; then |
|
|
|
|
|
|
|
echo "Git completion install misconfigured for $name." >&2 |
|
|
|
|
|
|
|
return 1 |
|
|
|
|
|
|
|
fi |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if _zshv2_file_has_sha256 "$dest" "$expected_sha"; then |
|
|
|
|
|
|
|
return 0 |
|
|
|
|
|
|
|
fi |
|
|
|
|
|
|
|
|
|
|
|
if ! command -v curl >/dev/null 2>&1; then |
|
|
|
if ! command -v curl >/dev/null 2>&1; then |
|
|
|
echo "curl is required to install Git completion files." >&2 |
|
|
|
echo "curl is required to install $name." >&2 |
|
|
|
rm -f "$tmp_file" |
|
|
|
|
|
|
|
return 1 |
|
|
|
return 1 |
|
|
|
fi |
|
|
|
fi |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
tmp_file="$(mktemp "${dest}.tmp.XXXXXX")" || return 1 |
|
|
|
|
|
|
|
|
|
|
|
if ! curl --fail --location --silent --show-error --output "$tmp_file" "$url"; then |
|
|
|
if ! curl --fail --location --silent --show-error --output "$tmp_file" "$url"; then |
|
|
|
echo "Failed to download $url" >&2 |
|
|
|
echo "Failed to download $name from $url" >&2 |
|
|
|
rm -f "$tmp_file" |
|
|
|
rm -f "$tmp_file" |
|
|
|
return 1 |
|
|
|
return 1 |
|
|
|
fi |
|
|
|
fi |
|
|
|
@ -115,7 +136,7 @@ _zshv2_download_verified() { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if [[ "$actual_sha" != "$expected_sha" ]]; then |
|
|
|
if [[ "$actual_sha" != "$expected_sha" ]]; then |
|
|
|
echo "SHA-256 mismatch for $url" >&2 |
|
|
|
echo "SHA-256 mismatch for $name." >&2 |
|
|
|
echo "Expected: $expected_sha" >&2 |
|
|
|
echo "Expected: $expected_sha" >&2 |
|
|
|
echo "Actual: $actual_sha" >&2 |
|
|
|
echo "Actual: $actual_sha" >&2 |
|
|
|
rm -f "$tmp_file" |
|
|
|
rm -f "$tmp_file" |
|
|
|
@ -125,32 +146,21 @@ _zshv2_download_verified() { |
|
|
|
mv "$tmp_file" "$dest" |
|
|
|
mv "$tmp_file" "$dest" |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
_zshv2_file_verified() { |
|
|
|
_zshv2_install_git_completion() { |
|
|
|
local file="$1" |
|
|
|
_zshv2_install_verified_file \ |
|
|
|
local expected_sha="$2" |
|
|
|
"git-completion.bash" \ |
|
|
|
local actual_sha |
|
|
|
"$GIT_COMPLETION_BASH_URL" \ |
|
|
|
|
|
|
|
"$GIT_COMPLETION_BASH_FILE" \ |
|
|
|
[[ -f "$file" ]] || return 1 |
|
|
|
"$GIT_COMPLETION_BASH_SHA256" |
|
|
|
|
|
|
|
|
|
|
|
actual_sha="$(_zshv2_sha256 "$file")" || return 1 |
|
|
|
_zshv2_install_verified_file \ |
|
|
|
|
|
|
|
"git-completion.zsh" \ |
|
|
|
[[ "$actual_sha" == "$expected_sha" ]] |
|
|
|
"$GIT_COMPLETION_ZSH_URL" \ |
|
|
|
|
|
|
|
"$GIT_COMPLETION_ZSH_FILE" \ |
|
|
|
|
|
|
|
"$GIT_COMPLETION_ZSH_SHA256" |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if [[ "$GIT_COMPLETION_COMMIT" != "PUT_PINNED_GIT_COMMIT_HASH_HERE" ]] && |
|
|
|
_zshv2_install_git_completion |
|
|
|
[[ "$GIT_COMPLETION_BASH_SHA256" != "PUT_SHA256_FOR_GIT_COMPLETION_BASH_HERE" ]] && |
|
|
|
|
|
|
|
[[ "$GIT_COMPLETION_ZSH_SHA256" != "PUT_SHA256_FOR_GIT_COMPLETION_ZSH_HERE" ]]; then |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if ! _zshv2_file_verified "$GIT_COMPLETION_BASH_FILE" "$GIT_COMPLETION_BASH_SHA256"; then |
|
|
|
|
|
|
|
_zshv2_download_verified "$GIT_COMPLETION_BASH_URL" "$GIT_COMPLETION_BASH_FILE" "$GIT_COMPLETION_BASH_SHA256" |
|
|
|
|
|
|
|
fi |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if ! _zshv2_file_verified "$GIT_COMPLETION_ZSH_FILE" "$GIT_COMPLETION_ZSH_SHA256"; then |
|
|
|
|
|
|
|
_zshv2_download_verified "$GIT_COMPLETION_ZSH_URL" "$GIT_COMPLETION_ZSH_FILE" "$GIT_COMPLETION_ZSH_SHA256" |
|
|
|
|
|
|
|
fi |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
echo "Git completion auto-install skipped: pinned commit and SHA-256 values are not configured." >&2 |
|
|
|
|
|
|
|
fi |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if [[ -f "$GIT_COMPLETION_BASH_FILE" ]]; then |
|
|
|
if [[ -f "$GIT_COMPLETION_BASH_FILE" ]]; then |
|
|
|
zstyle ':completion:*:*:git:*' script "$GIT_COMPLETION_BASH_FILE" |
|
|
|
zstyle ':completion:*:*:git:*' script "$GIT_COMPLETION_BASH_FILE" |
|
|
|
|