From 2829da09caaafee3c5c01089e9465503be986978 Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Thu, 26 Sep 2024 11:45:04 +0200 Subject: [PATCH 1/3] serve-public: indent using spaces only Signed-off-by: Johannes Schindelin --- script/serve-public.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/script/serve-public.js b/script/serve-public.js index c5b2d7e1e5..eea3379624 100755 --- a/script/serve-public.js +++ b/script/serve-public.js @@ -29,8 +29,8 @@ const handler = (request, response) => { let stats = fs.statSync(filename, { throwIfNoEntry: false }); if (!stats?.isFile() && !filename.match(/\.[A-Za-z0-9]{1,11}$/)) { - filename += ".html"; - stats = fs.statSync(filename, { throwIfNoEntry: false }); + filename += ".html"; + stats = fs.statSync(filename, { throwIfNoEntry: false }); } try{ if (!stats?.isFile()) throw new Error(`Not a file: ${filename}`); From 6958dd956662b62e74e5450a7510e8b6f9659964 Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Thu, 26 Sep 2024 14:25:35 +0200 Subject: [PATCH 2/3] update-book2: do allow the fallback for old image locations to work Recent revisions of the ProGit book have their images in the `images/` directory located at the top-level, but older revisions had them next to the chapters that referenced those images. The `update-book2.rb` script has a fall-back to allow those images to be copied from the old-style locations. This fall-back relies on an exception to be raised when an image does not show up in the new-style location, but we returned a warning instead. Let's not. Let's raise that exception again. Signed-off-by: Johannes Schindelin --- script/update-book2.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/script/update-book2.rb b/script/update-book2.rb index 36baea4b52..dcf09c8896 100644 --- a/script/update-book2.rb +++ b/script/update-book2.rb @@ -291,9 +291,9 @@ def local_genbook2(language_code, worktree_path) if language_code && worktree_path book = genbook(language_code) do |filename| File.open(File.join(worktree_path, filename), "r") { |infile| File.read(infile) } - rescue + rescue => e puts "::error::#{filename} is missing!" - "**ERROR**: _#{filename} is missing_" + raise e end book.sha = `git -C "#{worktree_path}" rev-parse HEAD`.chomp if language_code == 'en' From 63d13824c49f6771770a4400cfbc313fa40220de Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Thu, 26 Sep 2024 14:28:35 +0200 Subject: [PATCH 3/3] update-book2: avoid bogus warnings about missing images When an image is not found in the new-style location (i.e. in the `images/` folder at the top level of the worktree), we want to fall back to the old-style location _and not warn anybody about it_! Signed-off-by: Johannes Schindelin --- script/update-book2.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/script/update-book2.rb b/script/update-book2.rb index dcf09c8896..c040387ef8 100644 --- a/script/update-book2.rb +++ b/script/update-book2.rb @@ -196,7 +196,7 @@ def genbook(language_code, &get_content) end images.each do |path| - content = get_content.call(path) + content = get_content.call(path, :gently => true) csection.saveImage(path, content) rescue Errno::ENOENT begin @@ -289,10 +289,10 @@ def remote_genbook2(language_code) # Generate book html directly from local git repo" def local_genbook2(language_code, worktree_path) if language_code && worktree_path - book = genbook(language_code) do |filename| + book = genbook(language_code) do |filename, options={}| File.open(File.join(worktree_path, filename), "r") { |infile| File.read(infile) } rescue => e - puts "::error::#{filename} is missing!" + puts "::error::#{filename} is missing!" unless options[:gently] raise e end book.sha = `git -C "#{worktree_path}" rev-parse HEAD`.chomp