Skip to content

Commit

Permalink
feat: check if repos are in sync after partial update with exclude ta…
Browse files Browse the repository at this point in the history
…rgets
  • Loading branch information
renatav committed Oct 22, 2024
1 parent 75a5e92 commit 9ae8866
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 11 deletions.
12 changes: 6 additions & 6 deletions taf/auth_repo.py
Original file line number Diff line number Diff line change
Expand Up @@ -329,8 +329,8 @@ def auth_repo_commits_after_repos_last_validated(self, target_repos: List) -> Tu
traversed_commits.append(commit_id)
if not len(last_validated_target_commits):
break

return reversed(traversed_commits), last_commit_per_repo
traversed_commits.reverse()
return traversed_commits, last_commit_per_repo

def targets_data_by_auth_commits(
self,
Expand Down Expand Up @@ -473,7 +473,8 @@ def targets_at_revisions(self, commits, target_repos=None, default_branch=None,
default_branch = self.default_branch
previous_metadata = []
new_files = []
for commit in commits:
repos_to_skip = []
for commit in reversed(commits):
# repositories.json might not exit, if the current commit is
# the initial commit
repositories_at_revision = self.safely_get_json(
Expand All @@ -496,7 +497,6 @@ def targets_at_revisions(self, commits, target_repos=None, default_branch=None,
with self.repository_at_revision(commit):
roles_at_revision = self.get_all_targets_roles()

repos_to_skip = []
for role_name in roles_at_revision:
# targets metadata files corresponding to the found roles must exist
targets_at_revision = self.safely_get_json(
Expand All @@ -514,6 +514,8 @@ def targets_at_revisions(self, commits, target_repos=None, default_branch=None,
# the repo is addes to the repos_to_skip list
if target_path in repos_to_skip:
continue
if last_commits_per_repos and last_commits_per_repos.get(target_path) == commit:
repos_to_skip.append(target_path)
if target_path not in repositories_at_revision:
# we only care about repositories
continue
Expand All @@ -526,8 +528,6 @@ def targets_at_revisions(self, commits, target_repos=None, default_branch=None,
)
if target_content is not None:
target_commit = target_content.pop("commit")
if last_commits_per_repos and last_commits_per_repos.get(target_path) == target_commit:
repos_to_skip.append(target_path)
target_branch = target_content.pop("branch", default_branch)
targets[commit][target_path] = {
"branch": target_branch,
Expand Down
8 changes: 3 additions & 5 deletions taf/updater/updater_pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -1050,10 +1050,8 @@ def determine_start_commits(self):
# validated up to an older commit, or never validated at all
# that means that different repositories need to be validated from different start commits


try:


last_validated_target_commits = list(set(
self.state.users_auth_repo.get_last_validated_for_repo(repo_name) for repo_name in self.state.users_target_repositories
))
Expand All @@ -1068,7 +1066,7 @@ def determine_start_commits(self):
)
partially_validated_commits, last_commits_per_repos = self.state.partially_validated_repos_data
all_auth_commits = partially_validated_commits
for commit in self.state.auth_commits_since_last_validated:
for commit in self.state.auth_commits_since_last_validated:
if commit not in all_auth_commits:
all_auth_commits.append(commit)
else:
Expand All @@ -1080,7 +1078,6 @@ def determine_start_commits(self):
all_auth_commits, last_commits_per_repos=last_commits_per_repos
)
)

self.state.old_heads_per_target_repos_branches = defaultdict(dict)
is_initial_state_in_sync = True
# if last validated commit was not manually modified (set to a newer commit)
Expand All @@ -1103,7 +1100,8 @@ def determine_start_commits(self):
)

if last_validated_repository_commits_data:
if repository.name in self.state.repos_not_on_disk:
if repository.name in self.state.repos_not_on_disk and \
self.state.users_auth_repo.get_last_validated_for_repo(repository.name) is not None:
is_initial_state_in_sync = False
break
if not self._is_repository_in_sync(
Expand Down

0 comments on commit 9ae8866

Please sign in to comment.