def _run_sync(self): self.refresh_betka_yaml() for self.image in self.get_synced_images(): self.pagure_api.set_image(self.image) # Checks if pagure already contains a fork for the image self.image # The image name is defined in the betka.yaml configuration file # variable dist_git_repos if not self.pagure_api.get_pagure_fork(): UMBSender.send_umb_message_skip(self.msg_artifact, "not-applicable", "pagure fork not found") continue self.info("Trying to sync image %r.", self.image) os.chdir(self.betka_tmp_dir.name) self.clone_url = self.pagure_api.get_clone_url() # after downstream is cloned then # new cwd is self.downstream_dir if not self.prepare_downstream_git(): UMBSender.send_umb_message_skip( self.msg_artifact, "not-applicable", "Failed cloning downstream repository", ) continue # This function updates fork based on the upstream Git.get_changes_from_distgit( url=self.pagure_api.full_downstream_url) # Branches are taken from upstream repository like # https://src.fedoraproject.org/container/nginx not from fork all_branches = self.pagure_api.get_branches() # Filter our branches before checking bot-cfg.yml files branch_list_to_sync = Git.branches_to_synchronize( self.betka_config, all_branches=all_branches) self.debug(f"Branches to sync {branch_list_to_sync}") Git.sync_fork_with_upstream(branch_list_to_sync) valid_branches = self.pagure_api.get_valid_branches( self.downstream_dir, branch_list_to_sync) if not valid_branches: msg = "There are no valid branches with bot-cfg.yaml file" self.info(msg) UMBSender.send_umb_message_skip(self.msg_artifact, "not-applicable", msg) if self.downstream_dir.is_dir(): shutil.rmtree(str(self.downstream_dir)) continue try: self._sync_valid_branches(valid_branches) finally: self.delete_cloned_directories() self.send_umb_message_complete() # Deletes temporary directory. # It is created during each upstream2downstream task. if Path(self.betka_tmp_dir.name).is_dir(): self.betka_tmp_dir.cleanup()
def test_is_branch_synced(all_branches, expected): betka_config = betka_yaml() assert (Git.branches_to_synchronize(betka_config=betka_config, all_branches=all_branches) == expected)