Skip to content

Instantly share code, notes, and snippets.

@armincerf
Last active May 7, 2021 12:04
Show Gist options
  • Save armincerf/51cb4853d51ea273fe957adc40d7a20e to your computer and use it in GitHub Desktop.
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
#! /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 "$@"
(defun git-branch-from-clubhouse (num)
(interactive
(list (read-string "Clubhouse card number: ")))
(async-shell-command (format "%s %s" "git clubhouse" num)))
@armincerf
Copy link
Author

fixed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment