Digital Marketing & Communications

We've seen 1s and 0s you wouldn't believe

Making our Slackbot open source

📥  Development

Back in November, I blogged about writing a Slackbot for our team to provide editorial guidance on request.

We recently decided to make the bot open source. You can now see all the code on Github.

A very brief introduction to open source

'Open source' basically means making your project's code public so people can read and reuse it. This means everyone can use your code themselves if they want, or adapt it to make something new. They might even make their own contributions to your project.

Our team and our users benefit a lot from open-source projects, so it's something we're always keen to do ourselves. One of our digital principles is 'Work in the open', and open-sourcing code is a great way to do that.

We've shared several of our projects on the uniofbathdmc Github.com account, so this was an obvious new home for the bot.

Moving to a public Github repository

Until now, the Slackbot lived in a private repository on the University's Github Enterprise environment. On Github.com, if you want to copy code from one repository to another, you can easily fork it. But moving from Github Enterprise to Github.com is a little more complicated.

Before making any of the code public, I did a little bit of housekeeping, including:

  • adding a LICENSE file with details about the Apache license 2.0
  • updating the README to make the set-up instructions clearer for potential new users
  • reviewing the code and commit history to make sure we wouldn't expose anything that was confidential or a security risk

Once everything was in order, I created a new empty repository for our team's Github.com account.

The next step was to change the remote for my local version of the repository. This meant that any changes I made would be sent to the new repository instead.

Once the remote was updated, a quick git push in the command line uploaded the bot to the new repository. Hey presto, open sourcery!

Rewriting history

I opened up Chrome to look at the new repo on Github.com. All my files, commits and history were there, but all those commits were from my private Github Enterprise account.

That account doesn't exist on Github.com, so it looked like all the code had been written by the mysterious if243, with no indication of who that was. I decided to tweak this so all the commits came from my own Github.com account.

The git-filter-branch command allows you to modify your commit history. I used this to change all the authors and committers from my private account to my public one. As usual, StackOverflow was a big help.

One git push --force later, all the commits had been updated and the project history was much clearer.

The bot's open-source future

The bot is now open source, but that doesn't mean it's finished. Any more changes we make to the bot will be in our public repository. And now that the code is open to all, there's a much bigger opportunity for other people to get involved too.

This also gives us the chance to experiment with some cool tools which are available for free to open-source projects, like CircleCI and Hound.

It's a small offering, but it still feels nice to contribute to the open-source community that's given us so much.

Leave a Reply

  • (will not be published)