Fallback to VCS.release_date on VCS::NotFoundError

when -q is given.

One of the RubyCI servers, freebsd12, had a broken git environment:

```
$ git show
fatal: detected dubious ownership in repository at '/usr/home/chkbuild/chkbuild/tmp/build/20220917T123002Z/ruby'
To add an exception for this directory, call:

        git config --global --add safe.directory /usr/home/chkbuild/chkbuild/tmp/build/20220917T123002Z/ruby
```

tool/lib/vcs.rb doesn't work normally for that server.
Even for such cases, we'd like to generate a usable revision.h.

So this patch lets revision.h fallback to default VCS.release_date
when VCS::NotFoundError is raised.
This commit is contained in:
Takashi Kokubun 2022-09-17 22:24:09 +09:00
parent 1825d3673f
commit 33c6dd2cc8
No known key found for this signature in database
GPG Key ID: 6FFC433B12EE23DD
2 changed files with 8 additions and 7 deletions

View File

@ -68,13 +68,11 @@ OptionParser.new {|opts|
} }
unless vcs unless vcs
# Output only release_date when .git is missing # Output only release_date when .git is missing
if @output == :revision_h puts VCS.release_date if @output == :revision_h
puts VCS.release_date(Time.now - 10) # same as make-snapshot
end
exit exit
end end
@output = output =
case @output case @output
when :changed, nil when :changed, nil
Proc.new {|last, changed| Proc.new {|last, changed|
@ -99,9 +97,12 @@ end
ok = true ok = true
(ARGV.empty? ? [nil] : ARGV).each do |arg| (ARGV.empty? ? [nil] : ARGV).each do |arg|
begin begin
puts @output[*vcs.get_revisions(arg)] puts output[*vcs.get_revisions(arg)]
rescue => e rescue => e
next if @suppress_not_found and VCS::NotFoundError === e if @suppress_not_found and VCS::NotFoundError === e
puts VCS.release_date if @output == :revision_h
next
end
warn "#{File.basename(Program)}: #{e.message}" warn "#{File.basename(Program)}: #{e.message}"
ok = false ok = false
end end

View File

@ -95,7 +95,7 @@ class VCS
opts opts
end end
def self.release_date(time) def self.release_date(time = Time.now - 10) # the same default as make-snapshot
t = time.utc t = time.utc
[ [
t.strftime('#define RUBY_RELEASE_YEAR %Y'), t.strftime('#define RUBY_RELEASE_YEAR %Y'),