chlab very irregular posts about web development

Connecting BitBucket with ActiveCollab

It’s a common practice to reference issues in the commit messages of version control systems. It’s great to see which issue was the reason a certain change was made to the codebase.

At my former workplace, we were using BitBucket (BB) for hosting our git repos and ActiveCollab (AC) for our issue tracking. BB allows you to reference issues in your commit messages - but only if you’re using their issue tracker. AC allows you to import git repositories and scan them, but configuring and maintaining them is a pain. Also, we had in place the workflow that when an issue was fixed, you had to reassign it to the user who opened it in AC. This seemed like an unnecessary manual step to me that begged to be automated, so I automated it: meet acbb_connector (great name, I know).

acbb_connector is a little tool that you deploy on your AC server that receives a webhook callback from BB every time a commit is made and uses the AC API to manage the issue. So you push a commit like:

fixed syntax error
fixes #188

and it gets parsed, fixes issue 188 of the project that corresponds to the BB repo the commit is coming from and reassigns it to the user that opened the issue.

Documentation on how to install and configure is on the github page.

Show changed files between two git commits

Sometimes I want to get a list of files I changed within the history of a branch (or between two commits). To find out which commits I want to use I just refer to the graph, you can use any number of tools for this such as gitx, sourcetree or even git log –graph –oneline –all.

Run this command to add a git alias:

git config --global alias.changed-between '!f() { git log --pretty="%H" --author="$(git config" $1..$2 | while read commit_hash; do git show --oneline --name-only $commit_hash | tail -n+2; done | xargs ls 2>/dev/null | sort | uniq; }; f'

Then use it like this

git changed-between 07d2882 4881cdd

Which will give you an output like: