Skip to content

Commit

Permalink
fix: move _tuf_patches to repository lib (#296)
Browse files Browse the repository at this point in the history
* fix: move _tuf_patches to repository lib

This needs to be run before a TUF repositry is instantiated. However,
it was causing issues with installation of TAF.
tuf.repository_lib.get_targets_metadata_fileinfo does not exist in older
versions of TUF, so TUF had to be manually updated before TAF could be
installed

* chore: update changelog and bump version
  • Loading branch information
renatav committed Dec 14, 2022
1 parent 29cca19 commit 5e0f400
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 2 deletions.
20 changes: 19 additions & 1 deletion CHANGELOG.md
Expand Up @@ -5,14 +5,31 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog][keepachangelog],
and this project adheres to [Semantic Versioning][semver].


## [Unreleased]

### Added

### Changed


### Fixed


## [0.22.1] - 12/09/2022

### Added

### Changed

### Fixed

- Move _tuf_patches to repository lib ([296])


[296]: https://github.com/openlawlibrary/taf/pull/296


## [0.22.0] - 12/09/2022

### Added
Expand Down Expand Up @@ -777,7 +794,8 @@ and this project adheres to [Semantic Versioning][semver].

[keepachangelog]: https://keepachangelog.com/en/1.0.0/
[semver]: https://semver.org/spec/v2.0.0.html
[unreleased]: https://github.com/openlawlibrary/taf/compare/v0.22.0...HEAD
[unreleased]: https://github.com/openlawlibrary/taf/compare/v0.22.1...HEAD
[0.22.1]: https://github.com/openlawlibrary/taf/compare/v0.22.0...v0.22.1
[0.22.0]: https://github.com/openlawlibrary/taf/compare/v0.21.1...v0.22.0
[0.21.1]: https://github.com/openlawlibrary/taf/compare/v0.20.0...v0.21.1
[0.21.0]: https://github.com/openlawlibrary/taf/compare/v0.20.0...v0.21.0
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Expand Up @@ -2,7 +2,7 @@
from importlib.util import find_spec

PACKAGE_NAME = "taf"
VERSION = "0.22.0"
VERSION = "0.22.1"
AUTHOR = "Open Law Library"
AUTHOR_EMAIL = "info@openlawlib.org"
DESCRIPTION = "Implementation of archival authentication"
Expand Down
31 changes: 31 additions & 0 deletions taf/repository_tool.py
Expand Up @@ -1594,3 +1594,34 @@ def writeall(self):
have the minimum threshold of signatures.
"""
self._repository.writeall()


def _tuf_patches():
from functools import wraps
import tuf.repository_lib
import tuf.repository_tool

from taf.utils import normalize_file_line_endings

# Replace staging metadata directory name
tuf.repository_tool.METADATA_STAGED_DIRECTORY_NAME = (
tuf.repository_tool.METADATA_DIRECTORY_NAME
)

# Replace get_metadata_fileinfo with file-endings normalization
def get_targets_metadata_fileinfo(get_targets_metadata_fileinfo_fn):
@wraps(get_targets_metadata_fileinfo_fn)
def normalized(filename, storage_backend, custom=None):
normalize_file_line_endings(filename)
return get_targets_metadata_fileinfo_fn(
filename, storage_backend, custom=None
)

return normalized

tuf.repository_lib.get_targets_metadata_fileinfo = get_targets_metadata_fileinfo(
tuf.repository_lib.get_targets_metadata_fileinfo
)


_tuf_patches()

0 comments on commit 5e0f400

Please sign in to comment.