Skip to content

Commit 6a59e0d

Browse files
committed
Simplify update_copyright script to just use the new year for tracked files
* The previous logic would also bump the year of files which were changed by the previous year update, which is very complex to fix, or very slow.
1 parent 9936522 commit 6a59e0d

File tree

1 file changed

+4
-35
lines changed

1 file changed

+4
-35
lines changed

tool/update_copyright.rb

Lines changed: 4 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,8 @@
66
# GNU General Public License version 2, or
77
# GNU Lesser General Public License version 2.1.
88

9-
require 'rugged'
10-
11-
abort "USAGE: ruby #{$0} YEAR" unless ARGV.first
9+
abort "USAGE: ruby #{$0} NEW_YEAR" unless ARGV.first
1210
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-
1811
new_copyright_year = year
1912

2013
RB_COPYRIGHT = <<-EOS
@@ -106,35 +99,11 @@
10699
]
107100

108101
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
110103
end
111104

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|
138107
EXTENSIONS.include?(File.extname(path)) &&
139108
truffle_paths.any? { |prefix| path.start_with? prefix } &&
140109
excludes.none? { |prefix| path.start_with? prefix } &&

0 commit comments

Comments
 (0)