From 05a1a7b5eb3a8b8a37ecfb6e8b5801e03f5e47d1 Mon Sep 17 00:00:00 2001 From: Sylvain Gauthier Date: Sun, 14 Mar 2021 13:51:04 +1100 Subject: fix bug when article deleted and re-added later --- Makefile | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/Makefile b/Makefile index 5021f9a68..b835caa61 100644 --- a/Makefile +++ b/Makefile @@ -81,9 +81,10 @@ blog/index.html: $(ARTICLES) $(TAGFILES) $(addprefix templates/,$(addsuffix .htm envsubst < templates/tag_list_footer.html >> $@; \ envsubst < templates/article_list_header.html >> $@; \ first=true; \ + echo $(ARTICLES); \ for f in $(ARTICLES); do \ printf '%s ' "$$f"; \ - git log --diff-filter=A --date="format:%s $(BLOG_DATE_FORMAT_INDEX)" --pretty=format:'%ad%n' -- "$$f"; \ + git log -n 1 --diff-filter=A --date="format:%s $(BLOG_DATE_FORMAT_INDEX)" --pretty=format:'%ad%n' -- "$$f"; \ done | sort -k2nr | cut -d" " -f1,3- | while IFS=" " read -r FILE DATE; do \ "$$first" || envsubst < templates/article_separator.html; \ URL="`printf '%s' "\$$FILE" | sed 's,^$(BLOG_SRC)/\(.*\).md,\1,'`.html" \ @@ -117,7 +118,7 @@ blog/@%.html: $(TAGFILES) $(addprefix templates/,$(addsuffix .html,header tag_in first=true; \ for f in $(shell grep -FH '$*' $(TAGFILES) | sed 's,^tags/\([^:]*\):.*,$(BLOG_SRC)/\1.md,'); do \ printf '%s ' "$$f"; \ - git log --diff-filter=A --date="format:%s $(BLOG_DATE_FORMAT_INDEX)" --pretty=format:'%ad%n' -- "$$f"; \ + git log -n 1 --diff-filter=A --date="format:%s $(BLOG_DATE_FORMAT_INDEX)" --pretty=format:'%ad%n' -- "$$f"; \ done | sort -k2nr | cut -d" " -f1,3- | while IFS=" " read -r FILE DATE; do \ "$$first" || envsubst < templates/article_separator.html; \ URL="`printf '%s' "\$$FILE" | sed 's,^$(BLOG_SRC)/\(.*\).md,\1,'`.html" \ @@ -139,7 +140,7 @@ blog/%.html: $(BLOG_SRC)/%.md $(addprefix templates/,$(addsuffix .html,header ar export PAGE_TITLE; \ AUTHOR="$(shell git log --format="%an" -- "$<" | tail -n 1)"; \ export AUTHOR; \ - DATE_POSTED="$(shell git log --diff-filter=A --date="format:$(BLOG_DATE_FORMAT)" --pretty=format:'%ad' -- "$<")"; \ + DATE_POSTED="$(shell git log -n 1 --diff-filter=A --date="format:$(BLOG_DATE_FORMAT)" --pretty=format:'%ad' -- "$<")"; \ export DATE_POSTED; \ DATE_EDITED="$(shell git log -n 1 --date="format:$(BLOG_DATE_FORMAT)" --pretty=format:'%ad' -- "$<")"; \ export DATE_EDITED; \ @@ -163,7 +164,7 @@ blog/rss.xml: $(ARTICLES) "$(BLOG_TITLE)" "$(BLOG_URL_ROOT)" "$(BLOG_DESCRIPTION)" > $@ for f in $(ARTICLES); do \ printf '%s ' "$$f"; \ - git log --diff-filter=A --date="format:%s %a, %d %b %Y %H:%M:%S %z" --pretty=format:'%ad%n' -- "$$f"; \ + git log -n 1 --diff-filter=A --date="format:%s %a, %d %b %Y %H:%M:%S %z" --pretty=format:'%ad%n' -- "$$f"; \ done | sort -k2nr | head -n $(BLOG_FEED_MAX) | cut -d" " -f1,3- | while IFS=" " read -r FILE DATE; do \ printf '\n%s\n%s\n%s\n%s\n%s\n\n' \ "`head -n 1 $$FILE`" \ @@ -179,7 +180,7 @@ blog/atom.xml: $(ARTICLES) "$(BLOG_TITLE)" "$(BLOG_DESCRIPTION)" "$(shell date +%Y-%m-%dT%H:%M:%SZ)" "$(BLOG_URL_ROOT)" "$(BLOG_URL_ROOT)/atom.xml" "$(BLOG_URL_ROOT)/atom.xml" > $@ for f in $(ARTICLES); do \ printf '%s ' "$$f"; \ - git log --diff-filter=A --date="format:%s %Y-%m-%dT%H:%M:%SZ" --pretty=format:'%ad %aN%n' -- "$$f"; \ + git log -n 1 --diff-filter=A --date="format:%s %Y-%m-%dT%H:%M:%SZ" --pretty=format:'%ad %aN%n' -- "$$f"; \ done | sort -k2nr | head -n $(BLOG_FEED_MAX) | cut -d" " -f1,3- | while IFS=" " read -r FILE DATE AUTHOR; do \ printf '\n%s\n\n%s\n%s\n%s\n%s\n%s\n\n' \ "`head -n 1 $$FILE`" \ -- cgit v1.2.3