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
|
||||
abort "#{File.basename(Program)}: #{e.message}" unless @suppress_not_found
|
||||
opts.remove
|
||||
nil
|
||||
end
|
||||
nil
|
||||
end
|
||||
opts.new
|
||||
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}"
|
||||
if vcs
|
||||
vcs.set_options(vcs_options) # options after --srcdir
|
||||
else
|
||||
new_vcs["."]
|
||||
elsif new_vcs["."]
|
||||
else @suppress_not_found
|
||||
(vcs = VCS::Null.new(nil)).set_options(vcs_options)
|
||||
end
|
||||
}
|
||||
unless vcs
|
||||
# Output only release_date when .git is missing
|
||||
puts VCS.release_date if @output == :revision_h
|
||||
exit
|
||||
end
|
||||
|
||||
output =
|
||||
case @output
|
||||
|
@ -99,10 +95,6 @@ ok = true
|
|||
begin
|
||||
puts output[*vcs.get_revisions(arg)]
|
||||
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}"
|
||||
ok = false
|
||||
end
|
||||
|
|
|
@ -98,7 +98,7 @@ class VCS
|
|||
opts
|
||||
end
|
||||
|
||||
def self.release_date(time = Time.now - 10) # the same default as make-snapshot
|
||||
def release_date(time)
|
||||
t = time.utc
|
||||
[
|
||||
t.strftime('#define RUBY_RELEASE_YEAR %Y'),
|
||||
|
@ -246,7 +246,7 @@ class VCS
|
|||
t = release_datetime.utc
|
||||
code << t.strftime('#define RUBY_RELEASE_DATETIME "%FT%TZ"')
|
||||
end
|
||||
code += VCS.release_date(release_date)
|
||||
code += self.release_date(release_date)
|
||||
code
|
||||
end
|
||||
|
||||
|
@ -775,4 +775,15 @@ class VCS
|
|||
true
|
||||
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
|
||||
|
|
|
@ -295,7 +295,7 @@ def package(vcs, rev, destdir, tmp = nil)
|
|||
if info = vcs.get_revisions(url)
|
||||
modified = info[2]
|
||||
else
|
||||
modified = Time.now - 10
|
||||
_, _, modified = VCS::Null.new(nil).get_revisions(url)
|
||||
end
|
||||
if !revision and info
|
||||
revision = info
|
||||
|
|
Loading…
Reference in a new issue