Browse files

verify.rb: make it extensible by using a per-repository reserved range.

  • Loading branch information...
1 parent 938c63e commit a693d3e9452cd084e9a8da43fdde87993d0c5caa @Flameeyes committed Oct 17, 2012
Showing with 7 additions and 2 deletions.
  1. +1 −0 id-range
  2. +6 −2 verify.rb
View
1 id-range
@@ -0,0 +1 @@
+430000-439999
View
8 verify.rb
@@ -21,6 +21,10 @@
seen_ids = Set.new
res = 0
+# read reserved id range from the id-range file so that it can be
+# configured on a per-repository basis.
+range = Range.new(*File.read('id-range').rstrip.split('-').map(&:to_i))
+
# open all the rule files
Dir["*/*.conf"].each do |rulefile|
# read the content
@@ -97,8 +101,8 @@
$stderr.puts "#{rulefile}:#{lineno} rule missing id (#{rule.join(',')})"
res = 1
next
- elsif id < 430000 || id > 439999
- $stderr.puts "#{rulefile}:#{lineno} rule with id outside of reserved range"
+ elsif ! range.include?(id)
+ $stderr.puts "#{rulefile}:#{lineno} rule with id #{id} outside of reserved range #{range}"
res = 1
elsif seen_ids.include?(id)
$stderr.puts "#{rulefile}:#{lineno} rule with duplicated id #{id}"

0 comments on commit a693d3e

Please sign in to comment.