Fix Gitea watch branch validation logic

This commit is contained in:
Jason Parks 2025-03-20 13:50:55 -06:00
parent 56d8defebe
commit a4e4d1c467

View File

@ -130,6 +130,21 @@ export default async function handler(
}
} else if (sourceType === "gitea") {
const branchName = extractBranchName(req.headers, req.body);
const normalizedCommits = req.body?.commits?.flatMap(
(commit: any) => commit.modified,
);
const shouldDeployPaths = shouldDeploy(
application.watchPaths,
normalizedCommits,
);
if (!shouldDeployPaths) {
res.status(301).json({ message: "Watch Paths Not Match" });
return;
}
if (!branchName || branchName !== application.giteaBranch) {
res.status(301).json({ message: "Branch Not Match" });
return;
@ -230,12 +245,6 @@ export const extractCommitMessage = (headers: any, body: any) => {
: "NEW COMMIT";
}
if (headers["user-agent"]?.includes("Go-http-client")) {
if (body.push_data && body.repository) {
return `Docker image pushed: ${body.repository.repo_name}:${body.push_data.tag} by ${body.push_data.pusher}`;
}
}
return "NEW CHANGES";
};