Skip to content

Commit

Permalink
feat: update site main branch when none is defined
Browse files Browse the repository at this point in the history
  • Loading branch information
Geoffroy Empain committed Dec 10, 2020
1 parent c0d853e commit 9377e81
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion src/entities/sites/handlers/releases/upload-release.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,21 @@ async function handler(req: Request, res: Response): Promise<void> {
}),
);

if (!site.mainBranch) {
const mainBranch = branches[0]._id;

await Sites().updateOne({
_id: siteId,
mainBranch: null,
}, {
$set: {
mainBranch,
},
});

site.mainBranch = mainBranch;
}

configureSiteInCaddy(site).catch(err => {
logger.error(err);
});
Expand All @@ -129,7 +144,8 @@ export const uploadRelease = [
upload.single('file'),
body(object({
release: string().optional().max(STRING_MAX_LENGTH),
branches: string().trim().required().max(STRING_MAX_LENGTH)
branches: string().trim().required().min(1)
.max(STRING_MAX_LENGTH)
.custom(str => (
str.split(',')
)),
Expand Down

0 comments on commit 9377e81

Please sign in to comment.