def parse_distgit_event(event) -> Optional[DistGitEvent]: """ this corresponds to dist-git event when someone pushes new commits """ topic = event.get("topic") if topic == NewDistGitCommit.topic: logger.info(f"Dist-git commit event, topic: {topic}") repo_namespace = nested_get(event, "msg", "commit", "namespace") repo_name = nested_get(event, "msg", "commit", "repo") ref = nested_get(event, "msg", "commit", "branch") if not (repo_namespace and repo_name): logger.warning("No full name of the repository.") return None if not ref: logger.warning("Target branch for the new commits is not set.") return None logger.info( f"New commits added to dist-git repo {repo_namespace}/{repo_name}, branch {ref}." ) msg_id = event.get("msg_id") logger.info(f"msg_id = {msg_id}") branch = nested_get(event, "msg", "commit", "branch") return DistGitEvent(topic, repo_namespace, repo_name, ref, branch, msg_id) return None
def __init__( self, config: ServiceConfig, job_config: JobConfig, event: DistGitEvent ): super().__init__(config=config, job_config=job_config, event=event) self.distgit_event = event self.project = event.get_project() self.package_config = get_package_config_from_repo(self.project, event.git_ref) if not self.package_config: raise ValueError(f"No config file found in {self.project.full_repo_name}")
def parse_distgit_event(event) -> Optional[DistGitEvent]: """ this corresponds to dist-git event when someone pushes new commits """ topic = event.get("topic") if topic != NewDistGitCommit.topic: return None logger.info(f"Dist-git commit event, topic: {topic}") repo_namespace = nested_get(event, "msg", "commit", "namespace") repo_name = nested_get(event, "msg", "commit", "repo") if not (repo_namespace and repo_name): logger.warning("No full name of the repository.") return None branch = nested_get(event, "msg", "commit", "branch") rev = nested_get(event, "msg", "commit", "rev") if not branch or not rev: logger.warning("Target branch/rev for the new commits is not set.") return None msg_id = event.get("msg_id") logger.info( f"New commits added to dist-git repo {repo_namespace}/{repo_name}," f"rev: {rev}, branch: {branch}, msg_id: {msg_id}" ) # TODO: get the right hostname without hardcoding project_url = f"https://src.fedoraproject.org/{repo_namespace}/{repo_name}" return DistGitEvent( topic=topic, repo_namespace=repo_namespace, repo_name=repo_name, ref=rev, branch=branch, msg_id=msg_id, project_url=project_url, )