Last active
May 7, 2021 12:04
-
-
Save armincerf/51cb4853d51ea273fe957adc40d7a20e to your computer and use it in GitHub Desktop.
Run `git config --global clubhouse.token {token}` to set your ch token, then run `git clubhouse {id}` (make sure git-clubhouse is in your $PATH and executable) to checkout a new branch and push it to trigger the clubhouse hook
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/env bash | |
function main () { | |
local id="$1" | |
local token=$(git config --global --get clubhouse.token) | |
local story=$(curl -s "https://api.clubhouse.io/api/v3/stories/${id}?token=${token}") | |
local username=$(git config --global --get github.user) | |
local name=$(echo "${story}" | jq -r '.name' | iconv -t ascii//TRANSLIT | sed -E s/[^a-zA-Z0-9]+/-/g | sed -E s/^-+\|-+$//g | tr A-Z a-z) | |
local branch="${username}/ch${id}/${name}" | |
git checkout ${branch} 2>/dev/null || git checkout -b ${branch} | |
git push -u origin "${username}/ch${id}/${name}" | |
} | |
main "$@" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defun git-branch-from-clubhouse (num) | |
(interactive | |
(list (read-string "Clubhouse card number: "))) | |
(async-shell-command (format "%s %s" "git clubhouse" num))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
One feature I'd like is for the
git clubhouse XXX
command to checkout to that branch even if it already exists. Currently that causes afatal: A branch named 'Roxolan0/chXXX/my-clubhouse-card' already exists
error and keeps me onto the current branch. I'm forced to typegit checkout Roxolan0/chXXX/my-clubhouse-card
which can be a mouthful with long usernames / CH card names.