Tuesday, September 6, 2016

Improving the user experience of hub

I can't remember things well,  So when possible rely tools (like bash completion) to help me complete or explore commands with linux so that I don't have to remember every commands 100+ options.

With hub, the same applies and you may not have bash-completion for this new tool. If you install it directly from the hub site. 

To help you solve that, you can do:
if [[ -f /usr/share/bash-completion/completions/hub ]]; then echo "hub bash-completion already installed"; else  sudo curl -o /usr/share/bash-completion/completions/hub https://raw.githubusercontent.com/github/hub/master/etc/hub.bash_completion.sh; fi
This relies on the bash-completion construct but its the simplest way to add completion commands to this new tool.
  • This also updates your "completion" commands for git so be aware that if you have not aliased "git > hub" your completion commands may not correctly display your available options.
It should also be noted that if your not installing the hub tooling from the project site directly (but instead using your OS's package manger), bash completion may already come with the software. Be sure to explore this (and reload your shell after installing). 

Simplifying your github workflow with "hub"

As a support engineering / software maintenance engineer, I spend a lot of time looking at code, reading code, searching code, etc. So needless to say I have a few git repos's sitting arround. 

In most cases, I use these repositories to help me understand errors, or issues that customers see when using a product or library, that I am supporting. However in some situations, the problems once identified are simple to fix, it becomes time for me to change hats and become an contributor.

In most cases contributing its a pain because it involves understanding parts of the SCM (git) tooking that can be difficult to understand (when your first getting started). Depending on the project, contributing, or the workflow in how you provide contributions to the project can be "challenging". Luckily services like github have arisen to make the sharing / hosting of OpenSource projects simple. They have also worked to make "contributing" to projects simple (however these efforts of go with out praise).

One such example is github's invention of the "pull request". While this is a source control concept for "git", however its workflow definition has fundamentally altered, how contributions to projects work because it defined tooling to unify and simplify the process of contributions.


One of the complications with the "pull request" is that it, with out "sevice tooling" (Github) you are more or less providing "patches" that have to be manualy managed. The biggest complication caues by this "sevice tooling" (Github) is that you have to use the "web ui" to create / submitt a PR.

Not any more. With "hub" you can remove this complication, and move back to the terminal.

To get started you will need to install the "hub tooling", in my case on fedora I can just run.
sudo yum install hub
I can then use the use hub like 'git'.
hub clone https://github.com/openshift/openshift-docs
cd openshift-docs/
Except now, I have new options that integrate directly with the github service.
hub fork
git remote -v
From here on out, most of the "contribution process" is likely the same as what you do in for any git project. Branch -> Modify - > Commit - > Push.
git checkout -b typos
< make changes > 
git add install_config/install/prerequisites.adoc install_config/install/disconnected_install.adoc
 

<confirm changes> 
git diff master
git status
git commit -m "fixing typos"

git push <GITHUB_USER> typos
With you changes now in your "fork" and "feature branch" you can switch back to hub to complete your PR and contribute to the project.
git pull-request
  •  Note: you need to ensure that you setup your github ssh key, or you set on your git configuration:

    git config --global hub.protocol https 

Its the little things (like opening a web browser)

Sometimes as your developing a solution/script for a problem your faced with interesting challenges where the dumbest workaround (opening a ...