MCPcopy Index your code
hub / github.com/hunvreus/devpush / project_redeploy

Function project_redeploy

app/routers/project.py:1147–1234  ·  view source on GitHub ↗
(
    request: Request,
    project: Project = Depends(get_project_by_name),
    current_user: User = Depends(get_current_user),
    team_and_membership: tuple[Team, TeamMember] = Depends(get_team_by_slug),
    deployment: Deployment = Depends(get_deployment_by_id),
    db: AsyncSession = Depends(get_db),
    github_service: GitHubService = Depends(get_github_service),
    redis_client: Redis = Depends(get_redis_client),
    queue: ArqRedis = Depends(get_queue),
    github_installation_service: GitHubInstallationService = Depends(
        get_github_installation_service
    ),
)

Source from the content-addressed store, hash-verified

1145 name="project_redeploy",
1146)
1147async def project_redeploy(
1148 request: Request,
1149 project: Project = Depends(get_project_by_name),
1150 current_user: User = Depends(get_current_user),
1151 team_and_membership: tuple[Team, TeamMember] = Depends(get_team_by_slug),
1152 deployment: Deployment = Depends(get_deployment_by_id),
1153 db: AsyncSession = Depends(get_db),
1154 github_service: GitHubService = Depends(get_github_service),
1155 redis_client: Redis = Depends(get_redis_client),
1156 queue: ArqRedis = Depends(get_queue),
1157 github_installation_service: GitHubInstallationService = Depends(
1158 get_github_installation_service
1159 ),
1160):
1161 team, membership = team_and_membership
1162
1163 form: Any = await ProjectDeployForm.from_formdata(request)
1164
1165 environment = get_environment_for_branch(
1166 deployment.branch, project.active_environments
1167 )
1168
1169 if environment and request.method == "POST" and await form.validate_on_submit():
1170 try:
1171 github_installation = (
1172 await github_installation_service.get_or_refresh_installation(
1173 project.github_installation_id, db
1174 )
1175 )
1176 if not github_installation.token:
1177 raise ValueError("GitHub installation token missing.")
1178
1179 commit = await github_service.get_repository_commit(
1180 user_access_token=github_installation.token,
1181 repo_id=project.repo_id,
1182 commit_sha=deployment.commit_sha,
1183 branch=deployment.branch,
1184 )
1185
1186 new_deployment = await DeploymentService().create(
1187 project=project,
1188 branch=deployment.branch,
1189 commit=commit,
1190 current_user=current_user,
1191 db=db,
1192 redis_client=redis_client,
1193 )
1194 job = await queue.enqueue_job("start_deployment", new_deployment.id)
1195 new_deployment.job_id = job.job_id
1196 await db.commit()
1197
1198 flash(
1199 request,
1200 _(
1201 "Deployment %(new_deployment_id)s created.",
1202 new_deployment_id=new_deployment.id,
1203 ),
1204 "success",

Callers

nothing calls this directly

Calls 9

DeploymentServiceClass · 0.90
flashFunction · 0.90
RedirectResponseXFunction · 0.90
TemplateResponseFunction · 0.90
get_repository_commitMethod · 0.80
createMethod · 0.80
_Function · 0.50

Tested by

no test coverage detected