Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #345 from rhysd/check-changelog
Check changelog
- Loading branch information
Showing
4 changed files
with
45 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
ChangesPath = ARGV[0] || 'Changes' | ||
raise "#{ChangesPath} does not exist" unless File.exists? ChangesPath | ||
|
||
def git_hash?(hash) | ||
system "git rev-parse --quiet --verify #{hash} > /dev/null" | ||
end | ||
|
||
def check(change) | ||
success = true | ||
git_hash, *description = change | ||
|
||
unless git_hash?(git_hash) | ||
STDERR.puts "Commit '#{git_hash}' does not exist in this repository." | ||
success = false | ||
end | ||
|
||
case | ||
when description.empty? | ||
STDERR.puts "No description for commit '#{git_hash}'" | ||
success = false | ||
when description.first !~ /^\tModules:\s+/ | ||
STDERR.puts "Description must start with 'Modules:': #{description.first}" | ||
success = false | ||
end | ||
|
||
description.each do |line| | ||
unless line =~ /^\t/ | ||
STDERR.puts "All lines of description must start with \\t: #{line}" | ||
success = false | ||
end | ||
end | ||
|
||
success | ||
end | ||
|
||
success = File.foreach(ChangesPath) | ||
.slice_before{|l| l =~ /^\h+$/ } | ||
.map{|b| b.map(&:chop!)} | ||
.map{|c| check c} | ||
.all? | ||
|
||
exit(success ? 0 : 1) |
File renamed without changes.