[Bug]: gitfs with pygit2 >= 1.20 keeps deleted branches as saltenvs (fetch prune no longer used)
What happened?
pygit2 1.20.0 removed the old GIT_* constants, including GIT_FETCH_PRUNE (it's pygit2.enums.FetchPrune.PRUNE now, available since 1.14.0). salt/utils/gitfs.py still reads pygit2.GIT_FETCH_PRUNE in three places and treats the AttributeError as "this pygit2 is too old to prune":
Pygit2._fetchstops passingprune=toRemote.fetch().Pygit2.clean_stale_refsfalls back togit remote prunefor anonymous remotes, and for remotes with credentials it just logs "The installed version of pygit2 (...) does not support detecting stale refs for authenticated remotes" and returns[].verify_pygit2now requires thegitbinary to be on PATH, otherwise the pygit2 provider is rejected.
So with an authenticated gitfs/git_pillar remote (user/password or SSH key), a branch or tag deleted on the remote stays around as a saltenv forever.
Repro: I drove salt.utils.gitfs.Pygit2 directly against a local repo with master and feature branches, fetched, deleted feature in the remote, and fetched again. "Authenticated" means credentials/remotecallbacks are set the same way salt sets them for gitfs_user/gitfs_password.
pygit2 1.19.2 pygit2 1.20.0
--- anonymous remote --- anonymous remote
after deleting feature: ['base'] after deleting feature: ['base']
prune kwarg: [PRUNE, PRUNE] prune kwarg: [None, None]
--- authenticated remote --- authenticated remote
after deleting feature: ['base'] after deleting feature: ['base', 'feature']
prune kwarg: [PRUNE, PRUNE] prune kwarg: [None, None]
(The anonymous case still works on 1.20 only because it falls back to the git CLI.) Same result on pygit2 1.21.0 once the add_file problem from #70673 is out of the way.
The same debug message shows up in the log in #70298 (pygit2 1.20.0), and #70744 bumps pygit2 to >=1.21.0, so this will hit packaged installs soon.
Expected: pygit2 >= 1.20 prunes on fetch like older releases, and deleted branches stop being saltenvs.
Seen on 3008.x at 987eefd0f3. The code is the same on 3006.x, 3007.x and master, so any install that pulls in pygit2 >= 1.20 is affected.
Type of salt install
pip (git)
Major version
3008.x
What supported OS are you seeing the problem on? Can select multiple. (If bug appears on an unsupported OS, please open a GitHub Discussion instead)
Not OS specific (reproduced on macOS from a git checkout).
salt --versions-report output
Not from a packaged install. Relevant bits: salt 3008.x @ 987eefd0f3, Python 3.11, pygit2 1.20.0 (libgit2 1.9.6) and 1.21.0 (libgit2 1.9.7). pygit2 1.15.1 and 1.19.2 are fine.
Fixed by #70768; will ship in 3008.7.