mirror of
https://github.com/AdaCore/git-hooks.git
synced 2026-02-12 12:43:11 -08:00
This commit enhances the hooks to read the repository's configuration
from the most recent version. In particular, if an update is updating
the refs/meta/config reference, then read the configuration from that
update, instead of reading from the existing refs/meta/config reference.
For updates of all other references, the behavior remains unchanged.
A testcase (T227-003__meta_config_is_immediate) is added to verify
that refs/meta/config reference creation works as expected.
Following that change, various testcases also needed to be adapted
as follow:
- MC27-006__meta_config_branch_create: Creating the refs/meta/config
reference now works;
- QC13-022__checker_config_on_its_own: This testcase was pushing
a local branch called "meta-config" to refs/meta/config. This
update introduced a style-checker-config-file configuration. Since
the configuration is now taken into account right away, the update
is was rejected due to the file not existing.
The branch "meta-config" is renamed to "meta-config-missing",
and a new branch "meta-config" was created, containg the missing
file in addition to the configuration changes above.
We first try to push the "meta-config-missing" to verify
that this is rejected. We then try to push the (new) "meta-config"
branch, verifying that the presence of the config file allows
the push to be accepted.
- T209-001__update_hook_not_found: A similar situation to the above,
but with the update hook. The added comments in the testcase
should make the changes self-explanatory.
- T209-001__update_hook_reject: Modify the update-hook, which is
called during reference updates, to not reject the refs/meta/config
update the testcase is doing as part of the preliminary setup phase.
Change-Id: I0bd7bc0801ba08cd281a751759bba8c48ba0c454
TN: T227-003
20 lines
748 B
Python
20 lines
748 B
Python
"""A module related to these hooks's start up phase."""
|
|
|
|
import config
|
|
|
|
|
|
def init_all_globals(updated_refs):
|
|
"""Initialize all the global variables used by these hooks.
|
|
|
|
PARAMETERS
|
|
updated_refs: An OrderedDict, where the key is the name of
|
|
a reference being updated, and the value is a tuple
|
|
with the following elements:
|
|
- The SHA1 of that reference prior to the update;
|
|
- The SHA1 of that reference if the update is accepted.
|
|
"""
|
|
# If config.CONFIG_REF is being modified, tell the config module
|
|
# to use the reference's new value, instead of the old one.
|
|
if config.CONFIG_REF in updated_refs:
|
|
_, config.config_commit = updated_refs[config.CONFIG_REF]
|