Skip to content

Instantly share code, notes, and snippets.

@joshmanders joshmanders/README.md
Last active Mar 23, 2017

Embed
What would you like to do?
Git Clubhouse.io Command

Git Clubhouse.io Command

This command takes a story ID and connects to the API using your token and gets the story with that ID, determines the type and title of the story.

After it has gathered that, it slugifies the title and creates a branch in the format of {type}/{id}-{title} so for example:

❯ git clubhouse 82
Switched to a new branch 'feature/82-login-my-account-menu-item'

All you have to do is create a token for the org you're in, save git-clubhouse into your $PATH and make it executable with chmod +x git-clubhouse then setup a token in .gitconfig by running:

git config --global clubhouse.token {token}

Now just run git clubhouse {id} and watch your branch be created.

This depends on jq being installed.

#! /usr/bin/env bash
function main () {
local id="$1"
local token=$(git config --globa --get clubhouse.token)
local story=$(curl -s "https://api.clubhouse.io/api/v1/stories/${id}?token=${token}")
local type=$(echo "${story}" | jq -r '.story_type')
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)
git checkout -b "${type}/${id}-${name}"
}
main "$@"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.