#667 pre-push-check should respect --config
Closed: Fixed by onosek. Opened by parasense.

Recently internal automated testing began failing because rhpkg was generating a .git/hooks/pre-push script, which in turn calls 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.

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

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.

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

The suggested solution is here: #673.

Commit 1f03eb91 fixes this issue

Hi,

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...

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

Metadata
Related Pull Requests