Skip to content

Commit

Permalink
Allow deletion of branch builds
Browse files Browse the repository at this point in the history
  • Loading branch information
garethbowen authored and Stefan du Fresne committed Jun 25, 2019
1 parent f6047c2 commit 0df970e
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions ddocs/builds/validate_doc_update.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,16 @@ function(newDoc, oldDoc, userCtx) {
throw({ forbidden: 'Document _id format invalid' });
}

if (newDoc._deleted && version.branch) {
// You are allowed to delete branches, don't worry worry about validating anything
return;
}

if (newDoc._deleted) {
// and you're not allowed to delete anything else!
throw({ forbidden: 'You are not allowed to delete releases or pre-releases'});
}

var meta = newDoc.build_info;
if (meta) {
if (meta.schema_version !== 1) {
Expand All @@ -22,12 +32,7 @@ function(newDoc, oldDoc, userCtx) {
throw({ forbidden: 'neither legacy kanso property nor build_info property exist'});
}

if (version.branch) {
// You can re-write over a branch as much as you like
return;
}

if (oldDoc) {
if (!version.branch && oldDoc) {
throw({ forbidden: 'You are not allowed to overwrite existing releases or pre-releases' });
}
}

0 comments on commit 0df970e

Please sign in to comment.