Skip to content

Commit

Permalink
feat(issue): checkout existing linked branch if exists
Browse files Browse the repository at this point in the history
  • Loading branch information
benelan committed May 17, 2024
1 parent f2b4bb9 commit ecfd426
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions gh-fzf
Original file line number Diff line number Diff line change
Expand Up @@ -201,13 +201,17 @@ $global_binds
)+refresh-preview" \
--bind="enter:execute(gh issue edit {1} $repo_flag)+refresh-preview" \
--bind='alt-o:execute(
prefix="$GH_FZF_BRANCH_PREFIX"
num="${GH_FZF_BRANCH_ADD_ISSUE_NUMBER:+{1}$GH_FZF_BRANCH_ADD_ISSUE_NUMBER}"
num=$(tr -d "#'\''" <<< ${num// /})
printf "Enter branch name for {1}: ${prefix}${num}";
read -r name;
branch="${prefix}${num}${name// /-}"
gh issue develop {1} --checkout ${branch:+--name "$branch"} '"$repo_flag"'
branch="$(gh issue develop --list {1} | tail | cut -f1)"
if git show-ref --quiet "refs/heads/$branch"; then
git checkout "$branch"
else
num="${GH_FZF_BRANCH_ADD_ISSUE_NUMBER:+{1}$GH_FZF_BRANCH_ADD_ISSUE_NUMBER}"
num=$(tr -d "#'\''" <<< ${num// /})
printf "Enter branch name for {1}: ${GH_FZF_BRANCH_PREFIX}${num}";
read -r name;
branch="${GH_FZF_BRANCH_PREFIX}${num}${name// /-}"
gh issue develop {1} --checkout ${branch:+--name "$branch"} '"$repo_flag"'
fi
)+abort' \
--bind="alt-c:execute(gh issue comment {1} $repo_flag)+refresh-preview" \
--bind='alt-l:execute(
Expand Down

0 comments on commit ecfd426

Please sign in to comment.