postUpgradeTasks fileFilters do not preserve the executable bit #44214
Unanswered
richard-kramer
asked this question in
Request Help
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
How are you running Renovate?
Self-hosted Renovate CLI
Which platform you running Renovate on?
GitLab (.com or self-hosted)
Which version of Renovate are you using?
43.234.0
Please tell us more about your question or problem
When
postUpgradeTasksruns a command that sets the executable bit on a file (e.g.chmod +xor a generator script that creates files with mode755), Renovate detects the file as changed viafileFilters, but commits it with mode644. The execute bit is silently dropped.Root cause (suspected)
In
execute-post-upgrade-commands.js, files picked up fromgit statusafter the post-upgrade command runs are pushed ontoupdatedArtifactswith onlycontents:readLocalFileonly reads file content — it doesn't stat the file, so there's no way to know the mode at this point.Later, in
prepareCommit(util/git/index.js), the artifact is written and staged using that missing flag:Since
isExecutableis never set for artifacts collected frompostUpgradeTasks, the file is always written/staged as non-executable, regardless of its actual mode on disk after the task ran.This is despite
isExecutablealready being a supported mechanism elsewhere in the codebase (e.g.hermit/artifacts.js,npm/post-update/index.jsboth set it explicitly when needed) —execute-post-upgrade-commands.jsis just never wired up to populate it.Minimal reproduction
644, e.g.scripts/run.sh.renovate.json:{ "packageRules": [ { "matchManagers": ["npm"], "postUpgradeTasks": { "commands": ["chmod +x scripts/run.sh"], "fileFilters": ["scripts/run.sh"], "executionMode": "branch" } } ] }scripts/run.sh— but the commit still has mode100644, not100755.scripts/run.shloses its executable bit relative to what the post-upgrade command actually produced in the working tree.Expected behavior
If a file picked up via
fileFiltershas the executable bit set on disk after the post-upgrade command runs, Renovate should commit it with that mode preserved (isExecutable: true), the same way it already does for hermit/npm artifacts.Suggested fix
Stat the file when collecting it instead of relying solely on
readLocalFile:statLocalFileis already implemented and exported inutil/fs/index.js, so this would not require a new dependency.Environment
Workaround attempted
Setting
core.fileMode=trueglobally before Renovate runs does not fix this — it only affects whethergit statusreports mode changes asmodified, not whether Renovate'sprepareCommitactually preserves the mode when writing/staging the artifact. The bug is in the artifact layer, not in git's diff detection.Logs (if relevant)
No response
Beta Was this translation helpful? Give feedback.
All reactions