twpayne/chezmoi

`gitHub.refreshPeriod` not work

chuxubank opened this issue · 1 comments

Describe the bug

I add

[gitHub]
    refreshPeriod = "24h"

to my ~/.local/share/chezmoi/.chezmoi.toml.tmpl

apply it with chezmoi init

but when I run chezmoi list twice, it still call api.github.com each time, which make the command much slow.

Proxifier log:
image

To reproduce

Use

{{- if eq .chezmoi.os "darwin" }}
[".rime/dist"]
    type = "archive"
    url = "{{ (gitHubLatestReleaseAssetURL "rime/librime" "rime-*-macOS-universal.tar.bz2") }}"
    exact = true
    stripComponents = 1
{{- end }}

["bin/jar/pdf-unstamper.jar"]
    type = "file"
    url = "{{ (gitHubLatestReleaseAssetURL "hwding/pdf-unstamper" "pdf-unstamper.jar") }}"

in ~/.local/share/chezmoi/.chezmoiexternal.toml.tmpl

I previously use "{{ (first (gitHubLatestRelease "rime/librime").Assets).BrowserDownloadURL }}" but no luck.

run chezmoi list or may other cmds twice within the time specified by gitHub.refreshPeriod.

Expected behavior

No api call to api.github.com when the second time run the chezmoi command within the gitHub.refreshPeriod, otherwise it is easy to achieve github api rate limit.

Output of command with the --verbose flag

$ chezmoi --verbose list
.chezmoiscripts/darwin-setup.sh
.chezmoiscripts/install-packages-darwin.sh
.chezmoiscripts/restart-emacs.sh
.chezmoiscripts/rime-install.sh
.chezmoiscripts/setup-logrotate.sh
.chezmoiscripts/setup-xray.sh
.config
.config
.config/btop
.config/btop/btop.conf
.config/btop/themes
.config/btop/themes/gruvbox_dark.theme
.config/btop/themes/gruvbox_light.theme
.config/karabiner
.config/karabiner/karabiner.json
.config/logrotate.conf
.config/logrotate.d
.config/logrotate.d/xray
.config/proxy
.config/pypoetry
.config/pypoetry/config.toml
.config/rclone
.config/rclone/rclone.conf
.config/shell-proxy.sh
.config/starship.toml
.config/via
.config/via/CIDOO ABM066-USB.JSON
.config/via/cidoo_abm066.layout.json
.config/wezterm
.config/wezterm/keys.lua
.config/wezterm/launch.lua
.config/wezterm/theme.lua
.config/wezterm/wezterm.lua
.emacs.d
.gitconfig
.gitconfig_aa
.gitignore_global
.gnupg
.gnupg/gpg-agent.conf
.mbsyncrc
.password-store
.plum
.rime
.rime
.rime/data
.rime/data/default.custom.yaml
.rime/data/installation.yaml
.rime/dist
.rime/dist/bin
.rime/dist/bin/rime_deployer
.rime/dist/bin/rime_dict_manager
.rime/dist/bin/rime_patch
.rime/dist/bin/rime_table_decompiler
.rime/dist/include
.rime/dist/include/rime_api.h
.rime/dist/include/rime_levers_api.h
.rime/dist/lib
.rime/dist/lib/librime.1.11.2.dylib
.rime/dist/lib/librime.1.dylib
.rime/dist/lib/librime.dylib
.rime/dist/lib/pkgconfig
.rime/dist/lib/pkgconfig/rime.pc
.rime/dist/lib/rime-plugins
.rime/dist/lib/rime-plugins/librime-lua.dylib
.rime/dist/lib/rime-plugins/librime-octagram.dylib
.rime/dist/lib/rime-plugins/librime-predict.dylib
.rime/dist/share
.rime/dist/share/cmake
.rime/dist/share/cmake/rime
.rime/dist/share/cmake/rime/RimeConfig.cmake
.ssh
.ssh/config
.ssh/work_aa
.zprofile
.zshenv
.zshrc
Documents
Documents/PowerShell
Documents/PowerShell/Microsoft.PowerShell_profile.ps1
Library
Library/Application Support
Library/Application Support/Microsoft Edge
Library/Application Support/Microsoft Edge/Default
Library/Application Support/Microsoft Edge/Default/Preferences
Library/LaunchAgents
Library/LaunchAgents/gitwatch.org.plist
Library/Rime
Library/Rime/default.custom.yaml
Library/Rime/installation.yaml
bin
bin/jar
bin/jar
bin/jar/pdf-unstamper.jar
bin/mutool
bin/mutool/script
bin/mutool/script/.dir-locals.el
bin/mutool/script/unstamp.js
bin/unstamp
org
org-roam

When no network

$ chezmoi --verbose list
chezmoi: /Users/xuchu1/.local/share/chezmoi/.chezmoiexternal.toml.tmpl: template: /Users/xuchu1/.local/share/chezmoi/.chezmoiexternal.toml.tmpl:29:15: executing "/Users/xuchu1/.local/share/chezmoi/.chezmoiexternal.toml.tmpl" at <gitHubLatestReleaseAssetURL "rime/librime" "rime-*-macOS-universal.tar.bz2">: error calling gitHubLatestReleaseAssetURL: Get "https://api.github.com/repos/rime/librime/releases/latest": dial tcp: lookup api.github.com: no such host

Output of chezmoi doctor

$ chezmoi doctor
RESULT    CHECK                       MESSAGE
ok        version                     v2.52.0, commit Homebrew, built at 2024-08-07T20:11:15Z, built by Homebrew
ok        latest-version              v2.52.0
ok        os-arch                     darwin/arm64
ok        uname                       Darwin CNSHBL0520 23.5.0 Darwin Kernel Version 23.5.0: Wed May  1 20:13:18 PDT 2024; root:xnu-10063.121.3~5/RELEASE_ARM64_T6030 arm64
ok        go-version                  go1.22.6 (gc)
ok        executable                  /opt/homebrew/bin/chezmoi
ok        upgrade-method              brew-upgrade
ok        config-file                 ~/.config/chezmoi/chezmoi.toml, last modified 2024-08-09T09:46:14+08:00
warning   source-dir                  ~/.local/share/chezmoi is a git working tree (dirty)
ok        suspicious-entries          no suspicious entries
warning   working-tree                ~/.local/share/chezmoi is a git working tree (dirty)
ok        dest-dir                    ~ is a directory
ok        umask                       022
ok        cd-command                  found /bin/zsh
ok        cd-args                     /bin/zsh
info      diff-command                not set
ok        edit-command                found /opt/homebrew/bin/emacsclient
ok        edit-args                   emacsclient -a=
ok        git-command                 found /opt/homebrew/bin/git, version 2.46.0
ok        merge-command               found /usr/bin/vimdiff
ok        shell-command               found /bin/zsh
ok        shell-args                  /bin/zsh
info      age-command                 age not found in $PATH
ok        gpg-command                 found /opt/homebrew/bin/gpg, version 2.4.5
info      pinentry-command            not set
info      1password-command           op not found in $PATH
info      bitwarden-command           bw not found in $PATH
info      bitwarden-secrets-command   bws not found in $PATH
info      dashlane-command            dcli not found in $PATH
info      doppler-command             doppler not found in $PATH
info      gopass-command              gopass not found in $PATH
info      keepassxc-command           keepassxc-cli not found in $PATH
info      keepassxc-db                not set
info      keeper-command              keeper not found in $PATH
info      lastpass-command            lpass not found in $PATH
ok        pass-command                found /opt/homebrew/bin/pass, version 1.7.4
info      passhole-command            ph not found in $PATH
info      rbw-command                 rbw not found in $PATH
info      vault-command               vault not found in $PATH
info      vlt-command                 vlt not found in $PATH
info      secret-command              not set

Additional context

My config repo: https://github.com/chuxubank/dotfiles

Thanks for reporting this. The underlying problem was that the chezmoi list command was configured to not write any changes to disk, including not recording that it had recently made a call to the GitHub API. #4034 should fix it.