datopian / ckanext-versioning

Deprecated. See https://github.com/datopian/ckanext-versions. ⏰ CKAN extension providing data versioning (metadata and files) based on git and github.
https://tech.datopian.com/versioning/
GNU Affero General Public License v3.0
7 stars 4 forks source link

[IVT-2794] Adding fix for handling two tags to same revision #50

Closed uwaheed88 closed 4 years ago

uwaheed88 commented 4 years ago

Issue: IVT-2794

This resolves #49

shevron commented 4 years ago

I realize now that this takes more design work and solving it right may be slightly more complex than what has been initially communicated.

I don't think our solution should change any URL structures, and I don't think it should be a superficial change. This is something deeper, and may even require a (small) fix to metastore-lib to handle. What I want is this:

  1. The revision_ref parameter in URLs can specify either a revision ID (typically a sha1 or sha256) or a tag name.
  2. This parameter is passed as-is all the way down to metastore-lib which already makes the distinction between the two by itself when storage.fetch() is called.
  3. Either on the metastore-lib level (which currently will not return any extra information depending on whether a tag or a revision was fetched), or on the ckanext-versioning action level, we put some additional metadata on the revision or tag into the fetched package dict, or we put this information into the context. We can then use this information when rendering templates.

Note that metastore-lib already provides some methods of telling between a revision ID and a tag name, and we can just re-use those in ckanext-versioning if needed. It may even make sense for storage backends to expose a new method, something like is_valid_revision_id(revision_ref: str) -> bool to allow consuming code to check if something will be treated by the storage backend as if it was a revision ID or a tag (anything that is not a valid revision ID is assumed to be a tag).

Let me know if you want to further discuss this and come up with a design together.

uwaheed88 commented 4 years ago

@shevron Can you approve now as the tests have now passed?

shevron commented 4 years ago

Tested locally, works well. As a bonus, using the revision ID in the URL also works. 👍 Good job.