From b14f4b59323468a46d48cc915488b15fe749cd1f Mon Sep 17 00:00:00 2001 From: Razon Yang Date: Tue, 24 Oct 2023 09:11:52 +0800 Subject: [PATCH] Fix build with --enableGitInfo (#57) --- .github/workflows/build.yml | 6 ++++++ docker/hugo/snippets/git | 2 ++ site/layouts/_default/baseof.html | 1 + site/layouts/partials/git.html | 3 +++ 4 files changed, 12 insertions(+) create mode 100644 site/layouts/partials/git.html diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index ec0562a..36da86b 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -207,6 +207,12 @@ jobs: contains(fromJson('["", "git-", "node-git", "go-git", "exts-"]'), matrix.prefix) run: docker run --rm ${{ env.IMAGE_OWNER }}/${{ env.IMAGE_NAME }}:${{ matrix.version }}${{ matrix.prefix }}test git version + - name: Test site build with --enableGitInfo + if: | + steps.check.outputs.exists == 'false' && + contains(fromJson('["", "git-", "node-git", "go-git", "exts-"]'), matrix.prefix) + run: docker run --rm ${{ env.IMAGE_OWNER }}/${{ env.IMAGE_NAME }}:${{ matrix.version }}${{ matrix.prefix }}test hugo --enableGitInfo + - name: Check Go installation if: | steps.check.outputs.exists == 'false' && diff --git a/docker/hugo/snippets/git b/docker/hugo/snippets/git index 0bc1339..5be58cc 100644 --- a/docker/hugo/snippets/git +++ b/docker/hugo/snippets/git @@ -1 +1,3 @@ RUN apk add --no-cache git + +RUN git config --global --add safe.directory /src diff --git a/site/layouts/_default/baseof.html b/site/layouts/_default/baseof.html index 3fd6683..0f3e220 100644 --- a/site/layouts/_default/baseof.html +++ b/site/layouts/_default/baseof.html @@ -2,6 +2,7 @@ {{ .Page.Title }} {{ partial "dart-sass" . }} + {{ partial "git" . }} {{ partial "get-remote" . }} diff --git a/site/layouts/partials/git.html b/site/layouts/partials/git.html new file mode 100644 index 0000000..41a481e --- /dev/null +++ b/site/layouts/partials/git.html @@ -0,0 +1,3 @@ +{{- with .GitInfo }} + {{- warnf "[git] %s: %s" .Hash .Subject }} +{{- end }}