mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
Introduce VCS::Null
for fallback
This commit is contained in:
parent
f70ba9cf80
commit
5a5644dadc
Notes:
git
2022-09-30 12:49:35 +09:00
3 changed files with 18 additions and 15 deletions
|
@ -32,8 +32,8 @@ OptionParser.new {|opts|
|
||||||
rescue VCS::NotFoundError => e
|
rescue VCS::NotFoundError => e
|
||||||
abort "#{File.basename(Program)}: #{e.message}" unless @suppress_not_found
|
abort "#{File.basename(Program)}: #{e.message}" unless @suppress_not_found
|
||||||
opts.remove
|
opts.remove
|
||||||
|
nil
|
||||||
end
|
end
|
||||||
nil
|
|
||||||
end
|
end
|
||||||
opts.new
|
opts.new
|
||||||
opts.on("--srcdir=PATH", "use PATH as source directory") do |path|
|
opts.on("--srcdir=PATH", "use PATH as source directory") do |path|
|
||||||
|
@ -62,15 +62,11 @@ OptionParser.new {|opts|
|
||||||
opts.order! rescue abort "#{File.basename(Program)}: #{$!}\n#{opts}"
|
opts.order! rescue abort "#{File.basename(Program)}: #{$!}\n#{opts}"
|
||||||
if vcs
|
if vcs
|
||||||
vcs.set_options(vcs_options) # options after --srcdir
|
vcs.set_options(vcs_options) # options after --srcdir
|
||||||
else
|
elsif new_vcs["."]
|
||||||
new_vcs["."]
|
else @suppress_not_found
|
||||||
|
(vcs = VCS::Null.new(nil)).set_options(vcs_options)
|
||||||
end
|
end
|
||||||
}
|
}
|
||||||
unless vcs
|
|
||||||
# Output only release_date when .git is missing
|
|
||||||
puts VCS.release_date if @output == :revision_h
|
|
||||||
exit
|
|
||||||
end
|
|
||||||
|
|
||||||
output =
|
output =
|
||||||
case @output
|
case @output
|
||||||
|
@ -99,10 +95,6 @@ ok = true
|
||||||
begin
|
begin
|
||||||
puts output[*vcs.get_revisions(arg)]
|
puts output[*vcs.get_revisions(arg)]
|
||||||
rescue => e
|
rescue => 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
|
||||||
|
|
|
@ -98,7 +98,7 @@ class VCS
|
||||||
opts
|
opts
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.release_date(time = Time.now - 10) # the same default as make-snapshot
|
def release_date(time)
|
||||||
t = time.utc
|
t = time.utc
|
||||||
[
|
[
|
||||||
t.strftime('#define RUBY_RELEASE_YEAR %Y'),
|
t.strftime('#define RUBY_RELEASE_YEAR %Y'),
|
||||||
|
@ -246,7 +246,7 @@ class VCS
|
||||||
t = release_datetime.utc
|
t = release_datetime.utc
|
||||||
code << t.strftime('#define RUBY_RELEASE_DATETIME "%FT%TZ"')
|
code << t.strftime('#define RUBY_RELEASE_DATETIME "%FT%TZ"')
|
||||||
end
|
end
|
||||||
code += VCS.release_date(release_date)
|
code += self.release_date(release_date)
|
||||||
code
|
code
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -775,4 +775,15 @@ class VCS
|
||||||
true
|
true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
class Null < self
|
||||||
|
def get_revisions(path, srcdir = nil)
|
||||||
|
@modified ||= Time.now - 10
|
||||||
|
return nil, nil, @modified
|
||||||
|
end
|
||||||
|
|
||||||
|
def revision_header(last, release_date, release_datetime = nil, branch = nil, title = nil, limit: 20)
|
||||||
|
self.release_date(release_date)
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -295,7 +295,7 @@ def package(vcs, rev, destdir, tmp = nil)
|
||||||
if info = vcs.get_revisions(url)
|
if info = vcs.get_revisions(url)
|
||||||
modified = info[2]
|
modified = info[2]
|
||||||
else
|
else
|
||||||
modified = Time.now - 10
|
_, _, modified = VCS::Null.new(nil).get_revisions(url)
|
||||||
end
|
end
|
||||||
if !revision and info
|
if !revision and info
|
||||||
revision = info
|
revision = info
|
||||||
|
|
Loading…
Reference in a new issue