|
6 | 6 | # GNU General Public License version 2, or
|
7 | 7 | # GNU Lesser General Public License version 2.1.
|
8 | 8 |
|
9 |
| -require 'rugged' |
10 |
| - |
11 |
| -abort "USAGE: ruby #{$0} YEAR" unless ARGV.first |
| 9 | +abort "USAGE: ruby #{$0} NEW_YEAR" unless ARGV.first |
12 | 10 | year = Integer(ARGV.first)
|
13 |
| -since = Time.new(year, 1, 1, 0, 0, 0) |
14 |
| -last_day_of_year = Time.new(year+1, 1, 1, 0, 0, 0) |
15 |
| - |
16 |
| -puts "Fixing copyright years for commits between #{since} and #{last_day_of_year}" |
17 |
| - |
18 | 11 | new_copyright_year = year
|
19 | 12 |
|
20 | 13 | RB_COPYRIGHT = <<-EOS
|
|
106 | 99 | ]
|
107 | 100 |
|
108 | 101 | truffle_paths.each do |path|
|
109 |
| - puts "WARNING: incorrect path #{path}" unless File.exist? path |
| 102 | + abort "WARNING: incorrect path #{path}" unless File.exist? path |
110 | 103 | end
|
111 | 104 |
|
112 |
| -repo = Rugged::Repository.new('.') |
113 |
| - |
114 |
| -head_commit = repo.head.target |
115 |
| -last_commit = head_commit |
116 |
| -first_commit = nil |
117 |
| - |
118 |
| -walker = Rugged::Walker.new(repo) |
119 |
| -walker.sorting(Rugged::SORT_DATE) |
120 |
| -walker.push(head_commit.oid) |
121 |
| -walker.each { |commit| |
122 |
| - if commit.time >= last_day_of_year |
123 |
| - last_commit = commit |
124 |
| - end |
125 |
| - break if commit.time < since |
126 |
| - first_commit = commit |
127 |
| -} |
128 |
| - |
129 |
| -abort "No commit in that range" unless first_commit |
130 |
| - |
131 |
| -puts "First commit: #{first_commit.oid} #{first_commit.time}, last commit #{last_commit.oid} #{last_commit.time}" |
132 |
| - |
133 |
| -diff = first_commit.diff(last_commit) |
134 |
| - |
135 |
| -paths = diff.each_delta.to_a.map { |delta| |
136 |
| - delta.new_file[:path] |
137 |
| -}.select { |path| |
| 105 | +paths = `git ls-files`.lines(chomp: true) |
| 106 | +paths = paths.select { |path| |
138 | 107 | EXTENSIONS.include?(File.extname(path)) &&
|
139 | 108 | truffle_paths.any? { |prefix| path.start_with? prefix } &&
|
140 | 109 | excludes.none? { |prefix| path.start_with? prefix } &&
|
|
0 commit comments