Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Automatically check whether the repository needs to be updated #873

Merged
merged 2 commits into from
Jun 3, 2023

Conversation

gouttegd
Copy link
Contributor

This PR implements the behaviour suggested in #856.

That is, when a repository is initialised or updated, the ODK configuration file is hashed and the hash value is baked in the generated Makefile. A new config_check rule (called as a dependency to the all_odk rule) then compares the stored hash with a freshly computed hash on the current configuration file, and prints a message warning the user that their repository is out-of-date if the two hashes do not match.

closes #856

gouttegd added 2 commits May 23, 2023 13:48
When we seed a new repository (or update an existing one) from a
configuration file, compute a SHA2-256 fingerprint of the configuration
file and make it available to templates through the
`project.config_hash` variable.
If a fingerprint of the configuration file is available, then we store
it into the generated Makefile and we add a rule that compares the
stored fingerprint with the fingerprint of the current configuration
file as found in the repository. If the two fingerprints do not match,
this means the configuration file has been modified since the Makefile
was last generated, and therefore we print a message reminding the user
that an 'update_repo' step might be needed.
@gouttegd gouttegd requested a review from matentzn May 23, 2023 14:31
@gouttegd gouttegd self-assigned this May 26, 2023
Copy link
Contributor

@matentzn matentzn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From just reading this it is super amazing; I am missing a bit the config_hash parameter and default value in the dataclass https://github.com/INCATools/ontology-development-kit/blob/master/odk/odk.py#L452,

This is also used to generate the documentation

@gouttegd
Copy link
Contributor Author

gouttegd commented Jun 2, 2023

config_hash is not a parameter. It is not supposed to be set by the user. Its value is automatically generated by the seeding script. I don’t see the point of setting a “default value” in the data class – a default value would make no sense, it would always be overwritten by the seeding script.

Likewise I don’t think it’s useful for this variable to be documented. Users should not have to care about it. They don’t even have to know it exists. It’s purely an internal variable to make the up-to-date check work.

Copy link
Contributor

@matentzn matentzn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NOW I get it! genius! Sorry I didnt read it correctly, I missed this row:

https://github.com/INCATools/ontology-development-kit/pull/873/files#diff-ee525c96b3878b3e521023193d220a8e146ff4d1fe8f9348b75690d97af54d8fR723

And got confused.

Super!

@gouttegd gouttegd merged commit fd9857e into master Jun 3, 2023
@gouttegd gouttegd deleted the check-for-update-repo branch June 3, 2023 09:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Warn when update_repo should be run
2 participants