Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gitinfo doesn't work #27

Closed
Xuezenghuigithub opened this issue Nov 29, 2019 · 11 comments
Closed

gitinfo doesn't work #27

Xuezenghuigithub opened this issue Nov 29, 2019 · 11 comments

Comments

@Xuezenghuigithub
Copy link

Hey yixiuer, I've been using MemE for a long time. but I found another problem: If my Github's post name(post's filename) is English, then my gitinfo will work, for instance: 组件管理工具 Bit; But if Github's post name(post's filename) have Chinese...gitinfo will not display(like my blog's another most posts)😔I've also checked your blog's writing methods. There are no similarities and differences. I don't know why....

@reuixiy
Copy link
Owner

reuixiy commented Nov 29, 2019

git config --global core.quotePath false

gohugoio/hugo#3071

https://github.com/reuixiy/io-oi.me/blob/9fb993d94f8fdd84faba145da4870a9219128827/package.json#L8

@Xuezenghuigithub
Copy link
Author

Wow, thx!!!

@ichenh
Copy link
Contributor

ichenh commented Dec 11, 2020

同样是 gitinfo 无法显示,设置了 git config --global core.quotePath false 还是不行,查阅了几个相关的 issue 也看不懂,请问怎么解决?这是网站的仓库地址 https://github.com/ichenh/ichenh.com

@reuixiy
Copy link
Owner

reuixiy commented Dec 11, 2020

@ichenh

看了一下,你使用了 checkout 这个 action,根据其 README 中的描述:

    # Number of commits to fetch. 0 indicates all history for all branches and tags.
    # Default: 1
    fetch-depth: ''

默认只会 fetch 最新的一条 commit,所以导致 Hugo 在 build 的时候无法生成 GitInfo。

解决方法是,在你的 workflow 文件中

https://github.com/ichenh/ichenh.com/blob/e3c1a4d7066437e01e1a0600e4868fbdb7377242/.github/workflows/blank.yml#L24

的下一行,加上

fetch-depth: 0

@ichenh
Copy link
Contributor

ichenh commented Dec 11, 2020

@reuixiy

你好,我更改之后依然不行:只有 /content/cn-about.md 正常,而 /content/cn/ 目录下的文章无法显示。此外,虽然在本地测试正常显示,但 /content/cn/ 中文章的 editurl 会变成 /content/cn\ 导致错误。我所使用的是 Win10。

@he-sb
Copy link

he-sb commented Dec 11, 2020

@reuixiy

你好,我更改之后依然不行:只有 /content/cn-about.md 正常,而 /content/cn/ 目录下的文章无法显示。此外,虽然在本地测试正常显示,但 /content/cn/ 中文章的 editurl 会变成 /content/cn\ 导致错误。我所使用的是 Win10。

@ichenh 参考下 #107 结尾我的解决办法试试,应该是 git checkout 这个操作导致的问题。

@ichenh

看了一下,你使用了 checkout 这个 action,根据其 README 中的描述:

    # Number of commits to fetch. 0 indicates all history for all branches and tags.
    # Default: 1
    fetch-depth: ''

默认只会 fetch 最新的一条 commit,所以导致 Hugo 在 build 的时候无法生成 GitInfo。

解决方法是,在你的 workflow 文件中

https://github.com/ichenh/ichenh.com/blob/e3c1a4d7066437e01e1a0600e4868fbdb7377242/.github/workflows/blank.yml#L24

的下一行,加上

fetch-depth: 0

这个办法我也试过了,并不能解决问题(参考 我的 action 历史 ),我的尝试结果是,只要不执行 git checkout 操作就不会有问题。

@ichenh
Copy link
Contributor

ichenh commented Dec 12, 2020

@he-sb @reuixiy

感谢你们的帮助,我已经解决了。

首先,修改 checkout 的思路是对的:

@ichenh

看了一下,你使用了 checkout 这个 action,根据其 README 中的描述:

    # Number of commits to fetch. 0 indicates all history for all branches and tags.
    # Default: 1
    fetch-depth: ''

默认只会 fetch 最新的一条 commit,所以导致 Hugo 在 build 的时候无法生成 GitInfo。

解决方法是,在你的 workflow 文件中

https://github.com/ichenh/ichenh.com/blob/e3c1a4d7066437e01e1a0600e4868fbdb7377242/.github/workflows/blank.yml#L24

的下一行,加上

fetch-depth: 0

其次,如果文件名称包含中文的话就无法显示 gitinfo,我原本按照以下提醒在本地执行命令 git config --global core.quotePath false

git config --global core.quotePath false

gohugoio/hugo#3071

https://github.com/reuixiy/io-oi.me/blob/9fb993d94f8fdd84faba145da4870a9219128827/package.json#L8

但在服务器部署的时候就失败了,我重新查看以上链接,受到启发,在我的 Workflow 中添加 git config --global core.quotePath false,终于成功了。因为我是部署在服务器,而不是 GitHub Pages,又看不懂代码,所以就没有使用你们的 Workflow 文件。但我的 Workflow 配置有个问题,得把 resources 文件夹一起推送到仓库,不然会部署失败,我不知该如何处理。详情见我的 action 历史,部分错误提醒如下:

Error: Error building site: TOCSS: failed to transform "zh/styles/main-rendered.scss" (text/x-scss): resource "scss/scss/main.scss_a059ebc49e8302e6cfbf0e02020b9d85" not found in file cache

最后,还有一个问题。在 Windows 系统上生成的 editURL 带有反斜杠 \,即 https://仓库名/content/文件夹\文件名.md,导致链接打开错误,而在 Linux 上就是正常的斜杆 /。我看到 Hugo 的官方指南说会自动把 \ 转换成 /,因此很迷惑是不是系统问题。如果是的话,是否可以在 MemE 的 post-gitinfo.html 文件中设置自动转换?

@he-sb
Copy link

he-sb commented Dec 12, 2020

@he-sb @reuixiy

感谢你们的帮助,我已经解决了。

首先,修改 checkout 的思路是对的:

@ichenh
看了一下,你使用了 checkout 这个 action,根据其 README 中的描述:

    # Number of commits to fetch. 0 indicates all history for all branches and tags.
    # Default: 1
    fetch-depth: ''

默认只会 fetch 最新的一条 commit,所以导致 Hugo 在 build 的时候无法生成 GitInfo。
解决方法是,在你的 workflow 文件中
https://github.com/ichenh/ichenh.com/blob/e3c1a4d7066437e01e1a0600e4868fbdb7377242/.github/workflows/blank.yml#L24
的下一行,加上

fetch-depth: 0

其次,如果文件名称包含中文的话就无法显示 gitinfo,我原本按照以下提醒在本地执行命令 git config --global core.quotePath false

git config --global core.quotePath false

gohugoio/hugo#3071
https://github.com/reuixiy/io-oi.me/blob/9fb993d94f8fdd84faba145da4870a9219128827/package.json#L8

但在服务器部署的时候就失败了,我重新查看以上链接,受到启发,在我的 Workflow 中添加 git config --global core.quotePath false,终于成功了。因为我是部署在服务器,而不是 GitHub Pages,又看不懂代码,所以就没有使用你们的 Workflow 文件。但我的 Workflow 配置有个问题,得把 resources 文件夹一起推送到仓库,不然会部署失败,我不知该如何处理。详情见我的 action 历史,部分错误提醒如下:

Error: Error building site: TOCSS: failed to transform "zh/styles/main-rendered.scss" (text/x-scss): resource "scss/scss/main.scss_a059ebc49e8302e6cfbf0e02020b9d85" not found in file cache

最后,还有一个问题。在 Windows 系统上生成的 editURL 带有反斜杠 \,即 https://仓库名/content/文件夹\文件名.md,导致链接打开错误,而在 Linux 上就是正常的斜杆 /。我看到 Hugo 的官方指南说会自动把 \ 转换成 /,因此很迷惑是不是系统问题。如果是的话,是否可以在 MemE 的 post-gitinfo.html 文件中设置自动转换?

我之前一直是 Windwos 10,现在使用的是 Manjaro 这个基于 Arch 的 Linux 发行版,如果不取消 checkout 的话 git info 依然是有问题的。

@ichenh
Copy link
Contributor

ichenh commented Dec 12, 2020

@he-sb 我刚尝试将 fetch-depth: 0 注释掉,依然能够生成 gitinfo,目前看来是正常的,可能会出现 #107 中的“修改时间”错误?我不懂怎么配置 Workflow,只能先放置了。

我另有个问题想请教一下,在本地有一些文章不想公开,也就是设置了 draft = true,但它们也会一起同步到 GitHub 仓库,这样就变相地公开了。请问怎样让 git 忽略他们?

@reuixiy
Copy link
Owner

reuixiy commented Dec 12, 2020

@ichenh

这个报错是因为使用的不是扩展版的 Hugo,可能 peaceiris/actions-hugo@v2 默认安装的不是扩展版,要手动配置一下:https://github.com/peaceiris/actions-hugo#%EF%B8%8F-use-hugo-extended

斜杆的问题,应该是一个 bug,我新建了一个工单来追踪,见 #279

@reuixiy
Copy link
Owner

reuixiy commented Dec 12, 2020

@ichenh

修改 .gitignore 即可

另,还有问题的话,请到 Discussions 处提问

谢谢

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants