Skip to content

Commit

Permalink
chore: cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
renatav committed Sep 27, 2024
1 parent 3214bfe commit 9da11ab
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 76 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ def test_update_unpushed_commits_auth_repo(origin_auth_repo, client_dir):
],
indirect=True,
)
def test_update_unpushed_commits_auth_repo(origin_auth_repo, client_dir):
def test_update_unpushed_commits_target_repo(origin_auth_repo, client_dir):
clone_repositories(
origin_auth_repo,
client_dir,
Expand Down Expand Up @@ -262,76 +262,6 @@ def test_update_unpushed_commits_auth_repo(origin_auth_repo, client_dir):
)


@pytest.mark.parametrize(
"origin_auth_repo",
[
{
"targets_config": [{"name": "target1"}, {"name": "target2"}],
},
],
indirect=True,
)
def test_update_valid_dirty_index_target_repo(origin_auth_repo, client_dir):
clone_repositories(
origin_auth_repo,
client_dir,
)
client_auth_repo_path = client_dir / origin_auth_repo.name
client_auth_repo = AuthenticationRepository(path=client_auth_repo_path)

setup_manager = SetupManager(client_auth_repo)
setup_manager.add_task(
update_target_repo_without_committing, kwargs={"target_name": "target1"}
)
setup_manager.execute_tasks()

target1 = GitRepository(path=(client_auth_repo_path.parent / "target1"))
assert target1.something_to_commit()

# the update should fail without the force flag
update_invalid_repos_and_check_if_repos_exist(
OperationType.UPDATE,
origin_auth_repo,
client_dir,
FORCED_UPDATE_PATTERN,
True,
)

# now call with the force flag
update_and_check_commit_shas(
OperationType.UPDATE,
origin_auth_repo,
client_dir,
force=True,
)

assert not target1.something_to_commit()

setup_manager.add_task(
add_file_to_target_repo_without_committing, kwargs={"target_name": "target1"}
)
setup_manager.execute_tasks()

assert target1.something_to_commit()

# the update should fail without the force flag
update_invalid_repos_and_check_if_repos_exist(
OperationType.UPDATE,
origin_auth_repo,
client_dir,
FORCED_UPDATE_PATTERN,
True,
)

update_and_check_commit_shas(
OperationType.UPDATE,
origin_auth_repo,
client_dir,
force=True,
)
assert not target1.something_to_commit()


@pytest.mark.parametrize(
"origin_auth_repo",
[
Expand Down
12 changes: 7 additions & 5 deletions taf/updater/updater_pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
from pathlib import Path
import re
import shutil
import tempfile
from typing import Any, Dict, List, Optional

from attr import attrs, define, field
Expand Down Expand Up @@ -595,6 +594,12 @@ def prepare_for_auth_update_and_check_last_validated_commit(self):
else:
self.operation = OperationType.CLONE

def _clear_lvc():
settings.last_validated_commit[
self.state.validation_auth_repo.name
] = None
self.state.last_validated_commit = None

self.state.auth_commits_since_last_validated = None
# set last validated commit before running the updater
# this last validated commit is read from the settings
Expand Down Expand Up @@ -641,10 +646,7 @@ def prepare_for_auth_update_and_check_last_validated_commit(self):
taf_logger.warning(
f"{error_msg}. Starting validation from the first commit"
)
settings.last_validated_commit[
self.state.validation_auth_repo.name
] = None
self.state.last_validated_commit = None
_clear_lvc()
else:
raise UpdateFailedError(
f"{error_msg}\nRun the updater with the --force flag to run the validation from the first commit"
Expand Down

0 comments on commit 9da11ab

Please sign in to comment.