From a106d8556713fee69b78061264c848da8fad40f2 Mon Sep 17 00:00:00 2001 From: Nemo Date: Wed, 18 May 2022 12:37:03 +0530 Subject: [PATCH] [ci] Fix timezones for dates to use commiter timezones - Add irb as dev dependency --- Gemfile | 3 +++ Gemfile.lock | 12 ++++++++++++ update.rb | 26 ++++++++++++++++++-------- 3 files changed, 33 insertions(+), 8 deletions(-) diff --git a/Gemfile b/Gemfile index e04a678a..4c0909aa 100644 --- a/Gemfile +++ b/Gemfile @@ -4,3 +4,6 @@ source "https://rubygems.org" gem "rugged", "~> 1.4" gem "liquid", "~> 5.3" + +gem "irb", "~> 1.4", :group => [:development] +gem "rdoc", "~> 6.4", :group => [:development] diff --git a/Gemfile.lock b/Gemfile.lock index 5cbc50d2..57e66959 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,14 +1,26 @@ GEM remote: https://rubygems.org/ specs: + io-console (0.5.11) + irb (1.4.1) + reline (>= 0.3.0) liquid (5.3.0) + psych (4.0.4) + stringio + rdoc (6.4.0) + psych (>= 4.0.0) + reline (0.3.1) + io-console (~> 0.5) rugged (1.4.2) + stringio (3.0.2) PLATFORMS x86_64-linux DEPENDENCIES + irb (~> 1.4) liquid (~> 5.3) + rdoc (~> 6.4) rugged (~> 1.4) BUNDLED WITH diff --git a/update.rb b/update.rb index 739fe0ce..ab988b79 100644 --- a/update.rb +++ b/update.rb @@ -18,7 +18,6 @@ DEFAULT_TAG_TEMPLATE = '{{major}}.{{minor}}{% if patch %}.{{patch}}{%endif%}' def fetch_git_releases(repo_dir, url) pwd = Dir.pwd - puts "Fetching #{url}" `git init --bare #{repo_dir}` unless Dir.exist? repo_dir Dir.chdir repo_dir `git fetch --quiet --tags --filter=blob:none "#{url}"` @@ -46,14 +45,23 @@ def update_git_releases(repo_dir, output_file, auto_config) tag_proper_name = render_tag(tag.name, auto_config) - if tag.target.is_a? Rugged::Tag::Annotation - data[tag_proper_name] = tag.target.tagger[:time].strftime('%F') + # If the tag has an annotation, we get accurate time information + # from the tag annotation "tagger" + begin + if tag.annotated? + # We pick the data from the "tagger" which includes offset information + t = tag.annotation.tagger[:time] + data[tag_proper_name] = t.strftime('%F') + puts "#{tag_proper_name}: #{t.strftime('%F %X %z')}" else - begin - data[tag_proper_name] = tag.target.time.strftime('%F') - rescue StandardError - puts "[WARN] No timestamp for #{tag.name}" - end + # In other cases, we de-reference the tag to get the commit + # and use the date of the commit itself + t = tag.target.committer[:time] + data[tag_proper_name] = t.strftime('%F') + puts "#{tag_proper_name}: #{t.strftime('%F %X %z')}" + end + rescue StandardError + puts "::warning No timestamp for #{tag.name}, ignoring" end end File.open(output_file, 'w') do |file| @@ -98,8 +106,10 @@ Dir.glob("#{WEBSITE_DIR}/products/*.md").each do |product_file| next if OPTIONAL_PRODUCT && (OPTIONAL_PRODUCT != product) if data['auto']['git'] + puts "::group::#{product}" fetch_git_releases(get_cache_dir('git', product), data['auto']['git']) update_git_releases(get_cache_dir('git', product), get_output_file('git', product), data['auto']) + puts "::endgroup::" end end