diff --git a/Dockerfile b/Dockerfile index 138414522e..7a015513e7 100644 --- a/Dockerfile +++ b/Dockerfile @@ -11,6 +11,7 @@ ARG BUNDLER_VERSION=2.3.13 ARG JEKYLL_ENV=development ARG DOCS_URL=http://localhost:4000 +ARG DOCS_ENFORCE_GIT_LOG_HISTORY=0 # Base stage for building FROM ruby:${RUBY_VERSION}-alpine AS base @@ -45,6 +46,7 @@ COPY --from=vendored /out / FROM gem AS generate ARG JEKYLL_ENV ARG DOCS_URL +ARG DOCS_ENFORCE_GIT_LOG_HISTORY ENV TARGET=/out RUN --mount=type=bind,target=.,rw \ --mount=type=cache,target=/tmp/docker-docs-clone \ diff --git a/_plugins/fetch_remote.rb b/_plugins/fetch_remote.rb index ace1149cfd..afc189037e 100644 --- a/_plugins/fetch_remote.rb +++ b/_plugins/fetch_remote.rb @@ -41,7 +41,7 @@ module Jekyll beginning_time = Time.now puts "Starting plugin fetch_remote.rb..." - fetch_depth = get_docs_url == "http://localhost:4000" ? 1 : 0 + fetch_depth = get_docs_url == "http://localhost:4000" && ENV['DOCS_ENFORCE_GIT_LOG_HISTORY'] == "0" ? 1 : 0 site.config['fetch-remote'].each do |entry| puts " Repo #{entry['repo']}" @@ -51,10 +51,16 @@ module Jekyll puts " Opening #{clonedir}" begin git = Git.open(clonedir) - puts " Fetching #{entry['ref']}" - git.fetch - git.checkout(entry['ref']) + puts " Fetch repository" + if fetch_depth > 0 + git.fetch('origin', prune: true, depth: fetch_depth) + else + git.fetch('origin', prune: true) + end + puts " Checkout #{entry['ref']}" + git.checkout(entry['ref'], force: true) rescue => e + puts " WARNING: #{e}" FileUtils.rm_rf(clonedir) puts " Cloning repository into #{clonedir}" git = Git.clone("#{entry['repo']}.git", Pathname.new(clonedir), branch: entry['ref'], depth: fetch_depth) diff --git a/_plugins/last_modified_at.rb b/_plugins/last_modified_at.rb index 09bddfd1d9..765f8d55da 100644 --- a/_plugins/last_modified_at.rb +++ b/_plugins/last_modified_at.rb @@ -5,27 +5,51 @@ require 'octopress-hooks' module Jekyll class LastModifiedAt < Octopress::Hooks::Site DATE_FORMAT = '%Y-%m-%d %H:%M:%S %z' - def pre_render(site) - if get_docs_url == "http://localhost:4000" - # Do not generate last_modified_at for local development - return - end + def current_last_modified_at(site, page) + if page.data.key?('last_modified_at') + return page.data['last_modified_at'] + end + site.config['defaults'].map do |set| + if set['values'].key?('last_modified_at') && set['scope']['path'].include?(page.relative_path) + return set['values']['last_modified_at'] + end + end.compact + nil + end + + def pre_render(site) beginning_time = Time.now Jekyll.logger.info "Starting plugin last_modified_at.rb..." git = Git.open(site.source) - site.pages.each do |page| + use_file_mtime = get_docs_url == "http://localhost:4000" && ENV['DOCS_ENFORCE_GIT_LOG_HISTORY'] == "0" + site.pages.sort!{|l,r| l.relative_path <=> r.relative_path }.each do |page| next if page.relative_path == "redirect.html" next unless File.extname(page.relative_path) == ".md" || File.extname(page.relative_path) == ".html" - unless page.data.key?('last_modified_at') + page.data['last_modified_at'] = current_last_modified_at(site, page) + set_mode = "frontmatter" + path_override = "" + if page.data['last_modified_at'].nil? + page_relative_path = page.relative_path + if page.data.key?('datafolder') && page.data.key?('datafile') + page_relative_path = File.join('_data', page.data['datafolder'], "#{page.data['datafile']}.yaml") + path_override = "\n override: #{page_relative_path}" + end begin - page.data['last_modified_at'] = git.log.path(page.relative_path).first.date.strftime(DATE_FORMAT) + if use_file_mtime + # Use file's mtime for local development + page.data['last_modified_at'] = File.mtime(page_relative_path).strftime(DATE_FORMAT) + set_mode = "mtime" + else + page.data['last_modified_at'] = git.log.path(page_relative_path).first.date.strftime(DATE_FORMAT) + set_mode = "git" + end rescue => e # Ignored end end - puts" #{page.relative_path}\n last_modified_at: #{page.data['last_modified_at']}" + puts" #{page.relative_path}#{path_override}\n last_modified_at(#{set_mode}): #{page.data['last_modified_at']}" end end_time = Time.now diff --git a/docker-bake.hcl b/docker-bake.hcl index 4f19155b3b..eb6843bfb3 100644 --- a/docker-bake.hcl +++ b/docker-bake.hcl @@ -7,11 +7,15 @@ variable "DOCS_URL" { variable "DOCS_SITE_DIR" { default = "_site" } +variable "DOCS_ENFORCE_GIT_LOG_HISTORY" { + default = "0" +} target "_common" { args = { JEKYLL_ENV = JEKYLL_ENV DOCS_URL = DOCS_URL + DOCS_ENFORCE_GIT_LOG_HISTORY = DOCS_ENFORCE_GIT_LOG_HISTORY } no-cache-filter = ["generate"] } diff --git a/docker-compose.yml b/docker-compose.yml index 6e9c5f8f5d..1cbb82cc32 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -11,6 +11,7 @@ services: args: - JEKYLL_ENV - DOCS_URL + - DOCS_ENFORCE_GIT_LOG_HISTORY context: . image: docs/docstage ports: diff --git a/subscription/faq.md b/subscription/faq.md index b85069a6bf..4eccfff77c 100644 --- a/subscription/faq.md +++ b/subscription/faq.md @@ -96,7 +96,7 @@ When you downgrade your Pro or Team plan, changes are applied at the end of your ### How do I downgrade from a Team plan to a Free Team plan? -Before you downgrade to a Free plan, ensure that your organization details are updated to reflect features available in the Free plan. For example, you may need to reduce the number of team members and convert any private repositories to public repositories. For information on what’s included in the Free plan, see the [billing](index.md#pricing-plans){:target="blank" rel="noopener" class=""} page. +Before you downgrade to a Free plan, ensure that your organization details are updated to reflect features available in the Free plan. For example, you may need to reduce the number of team members and convert any private repositories to public repositories. For information on what’s included in the Free plan, see the [billing](index.md){:target="blank" rel="noopener" class=""} page. ### How do I downgrade from Pro to a Free plan? @@ -141,8 +141,7 @@ Team starts at $25 per month for the first five users and $7 per month for each ### How will the new pricing plan impact existing Docker Hub customers? Legacy individual and organizational repository customers have until their January 2021 billing cycle to switch to the new pricing plans. -To view the status of your individual repository plan, see [the billing](https:// -hub.docker.com/billing/plan/update){:target="blank" rel="noopener" class=""} page. +To view the status of your individual repository plan, see [the billing](https://hub.docker.com/billing/plan/update){:target="blank" rel="noopener" class=""} page. To view the status of your organizational repository plan, see [Docker Hub Orgs](https://hub.docker.com/orgs){:target="blank" rel="noopener" class=""} page. ### What is the difference between the legacy repository plans and the newly announced plans?