Recently internal automated testing began failing because rhpkg was generating a .git/hooks/pre-push script, which in turn calls rhpkg pre-push-check.
rhpkg
.git/hooks/pre-push
rhpkg pre-push-check
The problem is we run rhpkg in a fake environment, complete with fake dist-git, fake koji, fake everything! Think CI/CD stuff...
So we obviously run the tool like: rhpkg --config=/path/to/fake-rpkg-production.conf, and the the generated hook script doesn't have any of our custom configs, because it generates the script without any respect to CLI options.
rhpkg --config=/path/to/fake-rpkg-production.conf
The long term fix might involve passing forward any pertinent arguments. For example, if the program is called with --config, -C then maybe that should be passed through, or maybe you decided to make the hook script override only the dist-git name, or just guess the git from git config --local --get remote.origin.url
--config, -C
git config --local --get remote.origin.url
The short term work around involves truncating that hook script to zero-bytes, and that's working for us right now. We are carrying a patch to work-around the bug, so we are eager to get this fixed ASAP.
I'd be happy to send a patch if you like? (but it probably won't have awesome testing)
I would probably pass the args (argparse) object over to whatever object holds the Commands, and then the _add_git_pre_push_hook() method would have access to everything it needs without needing to read sys.argv[] like it does now. But I will leave you to decide how best to move forward.
args
_add_git_pre_push_hook()
sys.argv[]
Thanks!
Hi,
if the pre-push hook script contains this, would it work for you?
rhpkg -C "/path/to/fake-rpkg-production.conf" pre-push-check "$local_sha"
Btw, I can't easily omit the argv[0]. Because some users call the clone method directly from the other (custom) script: https://github.com/fedora-copr/copr/blob/fceb79456e7f7e9a41562f58d0903a262566b505/dist-git/copr_dist_git/package_import.py#L193
argv[0]
clone
The suggested solution is here: #673.
Commit 1f03eb91 fixes this issue
Hi, Hey Ondrej!
Hey Ondrej!
Firstly, My big apologies for the very late reply. I got really distracted with work stuff, end-of-quarter rush to finish goals, etc..
So here is a posthumous response to your question...
if the pre-push hook script contains this, would it work for you? ~~~~~ rhpkg -C "/path/to/fake-rpkg-production.conf" pre-push-check "$local_sha" ~~~~~
Yes! The .git/hooks/pre-push script should probably have:
x-pkg --config [config_file_path] pre-push-check ...
Or even use an ENV variable that specifies the config path. Maybe in the future we look into having RPKG_CONFIG_PATH env var that corresponds to x-pkg --config=[path]. That way nothing special needs to happen with generated scripts that embed x-pkg features. The CI could set the ENV and/or the CLI argparse options, etc...
RPKG_CONFIG_PATH
x-pkg --config=[path]
x-pkg
Just a thought
But I digress... this was already fixed. Thanks a bunch! -Jon
Metadata Update from @onosek: - Issue set to the milestone: 1.67