Skip to content

Commit

Permalink
fix: set last validated commit correctly (#507)
Browse files Browse the repository at this point in the history
We needed to set the dictionary keys correctly when running taf repo
validate. The current key is the auth_repo_name. Move the logic to it's
own function due to flake8 complexity lint.

Co-authored-by: Renata Vaderna <[email protected]>
  • Loading branch information
n-dusan and renatav authored Aug 20, 2024
1 parent 40fbf85 commit 7f27768
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 10 deletions.
1 change: 0 additions & 1 deletion taf/updater/updater.py
Original file line number Diff line number Diff line change
Expand Up @@ -620,7 +620,6 @@ def validate_repository(
else UpdateType.OFFICIAL
)
settings.overwrite_last_validated_commit = True
settings.last_validated_commit[auth_path] = validate_from_commit
auth_repo_name = None

try:
Expand Down
22 changes: 13 additions & 9 deletions taf/updater/updater_pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,18 @@ def set_existing_repositories(self):
repositoriesdb.clear_repositories_db()
return UpdateStatus.SUCCESS

# return UpdateStatus.SUCCESS if self.state.existing_repo else UpdateStatus.FAILURE
def set_last_validated_commit(self, validation_repo):
if self.operation == OperationType.CLONE:
settings.last_validated_commit = {}
elif not settings.overwrite_last_validated_commit:
users_auth_repo = AuthenticationRepository(path=self.auth_path)
last_validated_commit = users_auth_repo.last_validated_commit
settings.last_validated_commit[validation_repo.name] = last_validated_commit
elif self.validate_from_commit:
settings.last_validated_commit[
validation_repo.name
] = self.validate_from_commit

def check_if_local_repositories_clean(self):
try:
# check if the auth repo is clean first
Expand Down Expand Up @@ -499,14 +510,7 @@ def clone_remote_and_run_tuf_updater(self):

# set last validated commit before running the updater
# this last validated commit is read from the settings
if self.operation == OperationType.CLONE:
settings.last_validated_commit = {}
elif not settings.overwrite_last_validated_commit:
users_auth_repo = AuthenticationRepository(path=self.auth_path)
last_validated_commit = users_auth_repo.last_validated_commit
settings.last_validated_commit[
validation_repo.name
] = last_validated_commit
self.set_last_validated_commit(validation_repo)

# check if auth path is provided and if that is not the case
# check if info.json exists. info.json will be read after validation
Expand Down

0 comments on commit 7f27768

Please sign in to comment.