fix: derive prompt author from git config instead of log to handle empty emails
This commit is contained in:
1 file changed
+11
-3
+11
-3
@@ -12,11 +12,19 @@ create-prompt() {
|
||||
local repo_path="${2:-.}"
|
||||
local prompt_file="$repo_path/prompt.md"
|
||||
|
||||
local git_author
|
||||
git_author="$(git log --format="%an <%ae>" -1 2>/dev/null || echo '')"
|
||||
local git_author git_email
|
||||
git_author="$(git config --get user.name 2>/dev/null || echo '')"
|
||||
git_email="$(git config --get user.email 2>/dev/null || echo '')"
|
||||
|
||||
export PROMPT_TITLE="$title"
|
||||
export PROMPT_AUTHOR="${git_author:-}"
|
||||
|
||||
local prompt_author
|
||||
if [[ -n "$git_email" ]]; then
|
||||
prompt_author="${git_author} <${git_email}>"
|
||||
else
|
||||
prompt_author="$git_author"
|
||||
fi
|
||||
export PROMPT_AUTHOR="$prompt_author"
|
||||
|
||||
envsubst < "$HOME/taskfile.build/prompt.md.template" > "$prompt_file"
|
||||
|
||||
|
||||
Reference in new issue
Block a user