Skip to content

Commit

Permalink
chore: empty by default, allow start if empty
Browse files Browse the repository at this point in the history
  • Loading branch information
Keyrxng committed Nov 7, 2024
1 parent 474881b commit 00c8675
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 17 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ To configure your Ubiquibot to run this plugin, add the following to the `.ubiqu
startRequiresWallet: true # default is true
emptyWalletText: "Please set your wallet address with the /wallet command first and try again."
rolesWithReviewAuthority: ["MEMBER", "OWNER"]
requiredLabelsToStart: ["Priority: 5 (Emergency)"]
```
# Testing
Expand Down
17 changes: 3 additions & 14 deletions manifest.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,7 @@
{
"name": "Start | Stop",
"description": "Assign or un-assign yourself from an issue.",
"ubiquity:listeners": [
"issue_comment.created",
"issues.assigned",
"issues.unassigned",
"pull_request.opened",
"pull_request.edited"
],
"ubiquity:listeners": ["issue_comment.created", "issues.assigned", "issues.unassigned", "pull_request.opened", "pull_request.edited"],
"commands": {
"start": {
"ubiquity:example": "/start",
Expand Down Expand Up @@ -51,12 +45,7 @@
"type": "string"
},
"rolesWithReviewAuthority": {
"default": [
"COLLABORATOR",
"OWNER",
"MEMBER",
"ADMIN"
],
"default": ["COLLABORATOR", "OWNER", "MEMBER", "ADMIN"],
"type": "array",
"items": {
"type": "string"
Expand All @@ -79,4 +68,4 @@
"requiredLabelsToStart"
]
}
}
}
4 changes: 2 additions & 2 deletions src/handlers/shared/start.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ export async function start(
teammates: string[]
): Promise<Result> {
const { logger, config } = context;
const { taskStaleTimeoutDuration } = config;
const { taskStaleTimeoutDuration, requiredLabelsToStart } = config;

const issueLabels = issue.labels.map((label) => label.name);

if (!config.requiredLabelsToStart.some((label) => issueLabels.includes(label))) {
if (requiredLabelsToStart.length && !requiredLabelsToStart.some((label) => issueLabels.includes(label))) {
// The "Priority" label must reflect a business priority, not a development one.
throw new Error("This task does not reflect a business priority at the moment and cannot be started. This will be reassessed in the coming weeks.");
}
Expand Down
2 changes: 1 addition & 1 deletion src/types/plugin-input.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export const pluginSettingsSchema = T.Object(
rolesWithReviewAuthority: T.Transform(rolesWithReviewAuthority)
.Decode((value) => value.map((role) => role.toUpperCase()))
.Encode((value) => value.map((role) => role.toUpperCase())),
requiredLabelsToStart: T.Array(T.String()), // no default, must be in the config
requiredLabelsToStart: T.Array(T.String(), { default: [] }),
},
{
default: {},
Expand Down

0 comments on commit 00c8675

Please sign in to comment.