commit-msg-url-shortener

Shortens the urls that may appear in your commit message (and more fun stuff)

Install it

$ gem install commit-msg-url-shortener

Use it

Move to a git-controlled folder and type the command commit-msg-url-shortener to show the help page. Available commands are:

   $ commit-msg-url-shortener use [service]
   $ commit-msg-url-shortener remove
   $ commit-msg-url-shortener status

Example:

   $ commit-msg-url-shortener use tinyurl.com
   > Using "tinyurl.com".
   $ git commit -m "fixes a security flow, see http://railspikes.com/2008/9/22/is-your-rails-application-safe-from-mass-assignment"
   > [master d0adf01] fixes a security flow, see http://tinyurl.com/2g9mqh
     1 files changed, 10 insertions(+), 9 deletions(-)

Hack it

Fork it, and add support for new url-shortener sites. You can also create your own service that pre-process commit messages! For example you can create a must-have service that automatically translate your commit message into leetspeak:

  1. Create a new file called leetspeak.rb in the services folder
  2. Fill the leetspeak.rb file with the following code:

      CommitMsgUrlShortener::Service.define do |commit_message|
        translation = {:a=>4,:b=>8,:e=>3,:i=>'!',
                       :k=>:X,:l=>1,:o=>0,:s=>7,:t=>7,:z=>2}
        new_message = ''
        commit_message.each_char do |c|
          t = translation[c.downcase.to_sym]
          new_message += t ? t.to_s : c
        end
        new_message
      end
    
  3. Rebuild/reinstall the gem:

      $ bundle exec rake install
    
  4. Now you can use your brand new service! Move to your super-secret-git-versioned-project and type:

      $ commit-msg-url-shortener use leetspeak
      > Using "leetspeak".
      $ git commit -am "initial commit!"
      > [master d0adf00] !n!7!41 c0mm!7!
        1 files changed, 4 insertions(+), 4 deletions(-)