From b52c3c2b01efbbc48e03555f51a844cdc24322fa Mon Sep 17 00:00:00 2001 From: Peter Murray Date: Fri, 23 Jul 2021 16:53:26 -0400 Subject: [PATCH 1/2] Ignore commits starting with "META" --- lib/jekyll-last-modified-at/determinator.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/jekyll-last-modified-at/determinator.rb b/lib/jekyll-last-modified-at/determinator.rb index 8c5138b..d0ed6c0 100644 --- a/lib/jekyll-last-modified-at/determinator.rb +++ b/lib/jekyll-last-modified-at/determinator.rb @@ -40,6 +40,8 @@ def last_modified_at_unix '--git-dir', git.top_level_directory, 'log', + '--grep=^META', + '--invert-grep', '-n', '1', '--format="%ct"', From 98f92a7888f98ae95b402d931cfb38174c63fc5a Mon Sep 17 00:00:00 2001 From: Peter Murray Date: Sun, 16 Jan 2022 21:26:26 -0500 Subject: [PATCH 2/2] Follow `git mv` and move subj filtering into Ruby For reasons I couldn't determine, adding --follow to `git log` did incompatable things with `--grep` ... the git command returned NO entries. In other words: git log --follow --grep "^META" --invert-grep -- {file} ...didn't work. --- lib/jekyll-last-modified-at/determinator.rb | 21 +++++++++++++-------- lib/jekyll-last-modified-at/version.rb | 2 +- 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/lib/jekyll-last-modified-at/determinator.rb b/lib/jekyll-last-modified-at/determinator.rb index d0ed6c0..a507548 100644 --- a/lib/jekyll-last-modified-at/determinator.rb +++ b/lib/jekyll-last-modified-at/determinator.rb @@ -35,19 +35,24 @@ def last_modified_at_time def last_modified_at_unix if git.git_repo? - last_commit_date = Executor.sh( + last_commit_date_log = Executor.sh( 'git', '--git-dir', git.top_level_directory, 'log', - '--grep=^META', - '--invert-grep', - '-n', - '1', - '--format="%ct"', + '--follow', + '--format="%ct %s"', '--', - relative_path_from_git_dir - )[/\d+/] + relative_path_from_git_dir, + ) + last_commit_date_array = last_commit_date_log.split("\n") + last_commit_date = nil + last_commit_date_array.each do |i| + commit_date, commit_subject_first_word = i.delete_prefix('"').delete_suffix('"').split + next if commit_subject_first_word.eql? 'META' + last_commit_date = commit_date + break + end # last_commit_date can be nil iff the file was not committed. last_commit_date.nil? || last_commit_date.empty? ? mtime(absolute_path_to_article) : last_commit_date else diff --git a/lib/jekyll-last-modified-at/version.rb b/lib/jekyll-last-modified-at/version.rb index d752be2..385b54a 100644 --- a/lib/jekyll-last-modified-at/version.rb +++ b/lib/jekyll-last-modified-at/version.rb @@ -2,6 +2,6 @@ module Jekyll module LastModifiedAt - VERSION = '1.3.0' + VERSION = '1.3.1-PEM1' end end