1
0
mirror of https://github.com/ohmyzsh/ohmyzsh.git synced 2026-01-25 01:47:25 +08:00

Compare commits

..

No commits in common. "c44b99e901d7ef58f60247995152de1b937e2e9c" and "e32d4b1e195f4c7777844beea97af42bd93434eb" have entirely different histories.

2 changed files with 28 additions and 43 deletions

View File

@ -11,51 +11,41 @@
## Functions ## Functions
source_env() { source_env() {
if [[ ! -f "$ZSH_DOTENV_FILE" ]]; then if [[ -f $ZSH_DOTENV_FILE ]]; then
return if [[ "$ZSH_DOTENV_PROMPT" != false ]]; then
fi local confirmation dirpath="${PWD:A}"
if [[ "$ZSH_DOTENV_PROMPT" != false ]]; then # make sure there is an (dis-)allowed file
local confirmation dirpath="${PWD:A}" touch "$ZSH_DOTENV_ALLOWED_LIST"
touch "$ZSH_DOTENV_DISALLOWED_LIST"
# make sure there is an (dis-)allowed file # early return if disallowed
touch "$ZSH_DOTENV_ALLOWED_LIST" if grep -q "$dirpath" "$ZSH_DOTENV_DISALLOWED_LIST" &>/dev/null; then
touch "$ZSH_DOTENV_DISALLOWED_LIST" return;
fi
# early return if disallowed # check if current directory's .env file is allowed or ask for confirmation
if command grep -q "$dirpath" "$ZSH_DOTENV_DISALLOWED_LIST" &>/dev/null; then if ! grep -q "$dirpath" "$ZSH_DOTENV_ALLOWED_LIST" &>/dev/null; then
return # print same-line prompt and output newline character if necessary
echo -n "dotenv: found '$ZSH_DOTENV_FILE' file. Source it? ([Y]es/[n]o/[a]lways/n[e]ver) "
read -k 1 confirmation; [[ "$confirmation" != $'\n' ]] && echo
# check input
case "$confirmation" in
[nN]) return ;;
[aA]) echo "$dirpath" >> "$ZSH_DOTENV_ALLOWED_LIST" ;;
[eE]) echo "$dirpath" >> "$ZSH_DOTENV_DISALLOWED_LIST"; return ;;
*) ;; # interpret anything else as a yes
esac
fi
fi fi
# check if current directory's .env file is allowed or ask for confirmation # test .env syntax
if ! command grep -q "$dirpath" "$ZSH_DOTENV_ALLOWED_LIST" &>/dev/null; then zsh -fn $ZSH_DOTENV_FILE || echo "dotenv: error when sourcing '$ZSH_DOTENV_FILE' file" >&2
# get cursor column and print new line before prompt if not at line beginning
local column
echo -ne "\e[6n" > /dev/tty
read -t 1 -s -d R column < /dev/tty
column="${column##*\[*;}"
[[ $column -eq 1 ]] || echo
# print same-line prompt and output newline character if necessary setopt localoptions allexport
echo -n "dotenv: found '$ZSH_DOTENV_FILE' file. Source it? ([Y]es/[n]o/[a]lways/n[e]ver) " source $ZSH_DOTENV_FILE
read -k 1 confirmation
[[ "$confirmation" = $'\n' ]] || echo
# check input
case "$confirmation" in
[nN]) return ;;
[aA]) echo "$dirpath" >> "$ZSH_DOTENV_ALLOWED_LIST" ;;
[eE]) echo "$dirpath" >> "$ZSH_DOTENV_DISALLOWED_LIST"; return ;;
*) ;; # interpret anything else as a yes
esac
fi
fi fi
# test .env syntax
zsh -fn $ZSH_DOTENV_FILE || echo "dotenv: error when sourcing '$ZSH_DOTENV_FILE' file" >&2
setopt localoptions allexport
source $ZSH_DOTENV_FILE
} }
autoload -U add-zsh-hook autoload -U add-zsh-hook

View File

@ -114,11 +114,6 @@ function parse-commit {
fi fi
} }
# Ignore commit if it is a merge commit
if [[ $(command git show -s --format=%p $1 | wc -w) -gt 1 ]]; then
return
fi
# Parse commit with hash $1 # Parse commit with hash $1
local hash="$1" subject body warning rhash local hash="$1" subject body warning rhash
subject="$(command git show -s --format=%s $hash)" subject="$(command git show -s --format=%s $hash)"