#!/usr/bin/ruby require 'time' old_branch = ARGV[0] new_branch = ARGV[1] branch_checkout = ARGV[2] old_branch = `git name-rev #{old_branch}`.strip.split(/\s/).last new_branch = `git name-rev #{new_branch}`.strip.split(/\s/).last if branch_checkout == '1' unless File.exists?(".git/timelogs") Dir.mkdir(".git/timelogs") end unless old_branch == 'master' open(".git/timelogs/#{old_branch}", "a") do |file| file.puts "out #{Time.now.iso8601}" end end unless new_branch == 'master' open(".git/timelogs/#{new_branch}", "a") do |file| file.puts "in #{Time.now.iso8601}" end end end