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
# Output only release_date when .git is missing
if @output == :revision_h
puts VCS.release_date(Time.now - 10) # same as make-snapshot
end
puts VCS.release_date if @output == :revision_h
exit
end
@output =
output =
case @output
when :changed, nil
Proc.new {|last, changed|
@ -99,9 +97,12 @@ end
ok = true
(ARGV.empty? ? [nil] : ARGV).each do |arg|
begin
puts @output[*vcs.get_revisions(arg)]
puts output[*vcs.get_revisions(arg)]
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}"
ok = false
end

View File

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