Skip to content
Find file
Fetching contributors…
Cannot retrieve contributors at this time
executable file 19 lines (14 sloc) 597 Bytes
#!/usr/bin/env ruby
#
# Usage: project-version-commit HISTORY_FILE
#
# Creates a new commit or updates an existing commit that is labelled with the
# first version and date from the HISTORY_FILE.
#
# Written in 2012 by Suraj N. Kurapati <https://github.com/sunaku>
raise 'nothing staged for commit' if system 'git diff --cached --quiet'
(new_version, new_date) = ARGF.set_encoding('utf-8').read.
scan(/^## Version (\S+) \((\S+?)\)/).first
title = "Version #{new_version} (#{new_date})"
amend = `git log -1 --format=%s`.chomp == title
exec 'git', 'commit', '-m', title, *('--amend' if amend)
Something went wrong with that request. Please try again.