moved definition of class to separate file
This commit is contained in:
+6
-15
@@ -1,25 +1,13 @@
|
||||
import uvicorn
|
||||
from fastapi import FastAPI, Request
|
||||
from fastapi import FastAPI, Request, HTTPException
|
||||
from dotenv import load_dotenv
|
||||
import logging
|
||||
from pydantic import BaseModel
|
||||
from typing import List
|
||||
import os
|
||||
|
||||
from utils import clone_repository
|
||||
from setup_logging import setup_logging
|
||||
|
||||
class GiteaRequest(BaseModel):
|
||||
ref: str
|
||||
before: str
|
||||
after: str
|
||||
compare_url: str
|
||||
commits: List[dict]
|
||||
total_commits: int
|
||||
head_commit: dict
|
||||
repository: dict
|
||||
pusher: dict
|
||||
sender: dict
|
||||
from gitea_request import GiteaRequest
|
||||
|
||||
app = FastAPI()
|
||||
|
||||
@@ -39,7 +27,10 @@ def handle_event(request: GiteaRequest):
|
||||
# stop early if allowed
|
||||
commit_msg = request.head_commit['message']
|
||||
if commit_msg.lower().startswith('[skip ci]'):
|
||||
return {'status': 'received task'}
|
||||
raise HTTPException(
|
||||
status_code=200,
|
||||
detail='skipping ci'
|
||||
)
|
||||
# clone repository
|
||||
repo_url = request.repository['clone_url']
|
||||
logging.info('cloning repository: {repo_url}')
|
||||
|
||||
Reference in New Issue
Block a user