Skip to content

Commit 945bfff

Browse files
committed
fix: forking when GITHUB_TOKEN set via other method than zshenv
1 parent 280f264 commit 945bfff

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

scripts/clone-repo.sh

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,11 +100,20 @@ fi
100100
#───────────────────────────────────────────────────────────────────────────────
101101
# FORKING
102102

103-
# INFO Alfred stores checkbox settings as `"1"` or `"0"`, and variables in stringified form.
103+
# INFO Alfred stores checkbox settings as `"1"` or `"0"` (stringified)
104104
if [[ "$github_username" != "$owner" && "$fork_on_clone" == "1" ]]; then
105105

106106
if [[ -x "$(command -v gh)" ]]; then
107-
gh repo fork --remote=false &> /dev/null
107+
token=$github_token_from_alfred_prefs
108+
[[ -z "$token" ]] && token=$(zsh -c "$github_token_shell_cmd")
109+
# shellcheck disable=1091
110+
[[ -z "$token" ]] && token=$(test -e "$HOME"/.zshenv && source "$HOME/.zshenv" && echo "$GITHUB_TOKEN")
111+
if [[ -n "$token" ]]; then
112+
export GITHUB_TOKEN="$token"
113+
gh repo fork --remote=false &> /dev/null
114+
else
115+
echo "ERROR: Cannot fork, \`GITHUB_TOKEN\` not found." >&2
116+
fi
108117
else
109118
echo "ERROR: Cannot fork, \`gh\` not installed."
110119
fi

0 commit comments

Comments
 (0)