Skip to content
This repository has been archived by the owner on Aug 21, 2024. It is now read-only.

Commit

Permalink
Follow git mv and move subj filtering into Ruby
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
dltj committed Jan 17, 2022
1 parent b52c3c2 commit 98f92a7
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 9 deletions.
21 changes: 13 additions & 8 deletions lib/jekyll-last-modified-at/determinator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion lib/jekyll-last-modified-at/version.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@

module Jekyll
module LastModifiedAt
VERSION = '1.3.0'
VERSION = '1.3.1-PEM1'
end
end

0 comments on commit 98f92a7

Please sign in to comment.