docker: git Date filter

This commit is contained in:
dongdigua 2023-06-27 11:39:39 +08:00
parent 1566d6a9dc
commit a49b18355f
3 changed files with 21 additions and 5 deletions

View File

@ -2,14 +2,16 @@ FROM alpine:latest
RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.tuna.tsinghua.edu.cn/g' /etc/apk/repositories \
&& sed -i 'a https://mirrors.tuna.tsinghua.edu.cn/alpine/edge/testing' /etc/apk/repositories \
&& apk add agate git python3 \
&& touch /var/log/git.log
RUN git clone https://github.com/dongdigua/dongdigua.github.io.git --depth 1 \
&& apk add agate git python3 perl \
&& touch /var/log/git.log \
&& echo "0 * * * * run-parts /etc/periodic/hourly" > /var/spool/cron/crontabs/root
RUN git clone https://github.com/dongdigua/dongdigua.github.io.git --depth 1 \
&& cd dongdigua.github.io \
&& git config filter.dater.smudge 'perl -pe "\$last_date = `git log --pretty=format:\\"%ad\\" -1`;s/\\\$Date\\\$/\\\$Date: \$last_date\\\$/"' \
&& git config filter.dater.clean 'perl -pe "s/\\\$Date[^\\\$]*\\\$/\\\$Date\\\$/"' \
COPY run-wrapper.sh .
# https://weinan.io/2019/04/06/cron.html
COPY update-git.sh /etc/periodic/hourly/
# for testing purpose only

View File

@ -1,5 +1,9 @@
# Docker & Gemini
## System
alpine linux
=> https://weinan.io/2019/04/06/cron.html cron
## Server Program
=> https://github.com/mbrubeck/agate agate

10
gmi/git_filter_dater.gmi Normal file
View File

@ -0,0 +1,10 @@
# gitattributes filter=dater
better than the ruby solution in ProGit
=> https://git-scm.com/book/en/v2/Customizing-Git-Git-Attributes 8.2 Customizing Git - Git Attributes
(do not run it in fish shell, use bash/ksh instead)
```
git config filter.dater.smudge 'perl -pe "\$last_date = `git log --pretty=format:\\"%ad\\" -1`;s/\\\$Date\\\$/\\\$Date: \$last_date\\\$/"'
git config filter.dater.clean 'perl -pe "s/\\\$Date[^\\\$]*\\\$/\\\$Date\\\$/"'
```