Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't set severity for issues of type Task #91

Merged
merged 3 commits into from
Jan 7, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

Simple CLI tool that provides an interactive interface to quickly set priority, severity and story points for your JIRA issues. No need to open the JIRA web interface.

StoryPointer uses base JQL query to fetch issues that are not closed and have no story points or priority set - `Project = RHEL AND ("Story Points" is EMPTY OR priority is EMPTY OR Severity is EMPTY) AND status != Closed`. The query can be customized using the CLI command options or by setting ENV variables.
StoryPointer uses base JQL query to fetch issues that are not closed and have no story points or priority set - `Project = RHEL AND (type in (Story, Task) AND ("Story Points" is EMPTY OR priority is EMPTY) OR type not in (Story, Task) AND ("Story Points" is EMPTY OR priority is EMPTY OR Severity is EMPTY)) AND status != Closed`. The query can be customized using the CLI command options or by setting ENV variables.

## Usage

Expand Down Expand Up @@ -109,7 +109,7 @@ Size all issues of the `curl` component:
storypointer -c curl

JIRA Version: 9.12.10
JQL: Project = RHEL AND ("Story Points" is EMPTY OR priority is EMPTY OR Severity is EMPTY) AND status != Closed AND component = curl ORDER BY id DESC
JQL: Project = RHEL AND (type in (Story, Task) AND ("Story Points" is EMPTY OR priority is EMPTY) OR type not in (Story, Task) AND ("Story Points" is EMPTY OR priority is EMPTY OR Severity is EMPTY)) AND status != Closed AND component = curl ORDER BY id DESC
5 issues are waiting to be sized, prioritized, or set severity.

🐛 RHEL-1234 - In Progress - Assignee
Expand Down
16 changes: 11 additions & 5 deletions src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@
let storyPoints: Size = issue.fields[jira.fields.storyPoints];
const setStoryPoints = !storyPoints;

if (!storyPoints) {
if (setStoryPoints) {

Check warning on line 119 in src/cli.ts

View check run for this annotation

Codecov / codecov/patch

src/cli.ts#L119

Added line #L119 was not covered by tests
const answer: SizeWithControls = await select({
message: 'Story Points',
choices: [
Expand Down Expand Up @@ -177,7 +177,7 @@
let priority = parsedPriority.success ? parsedPriority.data : undefined;
const setPriority = !priority;

if (!priority) {
if (setPriority) {

Check warning on line 180 in src/cli.ts

View check run for this annotation

Codecov / codecov/patch

src/cli.ts#L180

Added line #L180 was not covered by tests
const answer: PriorityWithControls = await select({
message: 'Priority',
choices: [
Expand Down Expand Up @@ -232,10 +232,14 @@
issue.fields[jira.fields.severity]?.value
);
let severity = parsedSeverity.success ? parsedSeverity.data : undefined;
const setSeverity = !severity;
let setSeverity = !severity;

Check warning on line 235 in src/cli.ts

View check run for this annotation

Codecov / codecov/patch

src/cli.ts#L235

Added line #L235 was not covered by tests

// This is workaround, We should use api to determine what values are available on the issue
if (!severity && issue.fields.issuetype.name !== 'Story') {
if (
setSeverity &&
issue.fields.issuetype.name !== 'Story' &&
issue.fields.issuetype.name !== 'Task'
) {

Check warning on line 242 in src/cli.ts

View check run for this annotation

Codecov / codecov/patch

src/cli.ts#L238-L242

Added lines #L238 - L242 were not covered by tests
const answer: SeverityWithControls = await select({
message: 'Severity',
choices: [
Expand Down Expand Up @@ -278,9 +282,11 @@
}

severity = answer;
} else {
setSeverity != setSeverity;

Check warning on line 286 in src/cli.ts

View check run for this annotation

Codecov / codecov/patch

src/cli.ts#L285-L286

Added lines #L285 - L286 were not covered by tests
}

// If both values are already set, skip setting them
// If values are already set, skip setting them
if (!setStoryPoints && !setPriority && !setSeverity) {
logger.log('Nothing to do. Skipping.');
continue;
Expand Down
2 changes: 1 addition & 1 deletion src/jira.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export class Jira {
severity: 'customfield_12316142',
};
readonly baseJQL =
'Project = RHEL AND (type = Story AND ("Story Points" is EMPTY OR priority is EMPTY) OR type != Story AND ("Story Points" is EMPTY OR priority is EMPTY OR Severity is EMPTY)) AND status != Closed';
'Project = RHEL AND (type in (Story, Task) AND ("Story Points" is EMPTY OR priority is EMPTY) OR type not in (Story, Task) AND ("Story Points" is EMPTY OR priority is EMPTY OR Severity is EMPTY)) AND status != Closed';
JQL = '';

constructor(
Expand Down
14 changes: 7 additions & 7 deletions test/unit/jira.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ describe('Jira functions', () => {
it('can be instantiated', () => {
expect(jira).toBeInstanceOf(Jira);
expect(jira.baseJQL).toMatchInlineSnapshot(
`"Project = RHEL AND (type = Story AND ("Story Points" is EMPTY OR priority is EMPTY) OR type != Story AND ("Story Points" is EMPTY OR priority is EMPTY OR Severity is EMPTY)) AND status != Closed"`
`"Project = RHEL AND (type in (Story, Task) AND ("Story Points" is EMPTY OR priority is EMPTY) OR type not in (Story, Task) AND ("Story Points" is EMPTY OR priority is EMPTY OR Severity is EMPTY)) AND status != Closed"`
);
});

Expand Down Expand Up @@ -172,7 +172,7 @@ describe('Jira functions', () => {
undefined
);
expect(jira.JQL).toMatchInlineSnapshot(
`"Project = RHEL AND (type = Story AND ("Story Points" is EMPTY OR priority is EMPTY) OR type != Story AND ("Story Points" is EMPTY OR priority is EMPTY OR Severity is EMPTY)) AND status != Closed ORDER BY id DESC"`
`"Project = RHEL AND (type in (Story, Task) AND ("Story Points" is EMPTY OR priority is EMPTY) OR type not in (Story, Task) AND ("Story Points" is EMPTY OR priority is EMPTY OR Severity is EMPTY)) AND status != Closed ORDER BY id DESC"`
);
expect(mocks.searchForIssuesUsingJqlPost).toHaveBeenCalledWith({
fields: [
Expand All @@ -185,7 +185,7 @@ describe('Jira functions', () => {
'customfield_12310243',
'priority',
],
jql: 'Project = RHEL AND (type = Story AND ("Story Points" is EMPTY OR priority is EMPTY) OR type != Story AND ("Story Points" is EMPTY OR priority is EMPTY OR Severity is EMPTY)) AND status != Closed ORDER BY id DESC',
jql: 'Project = RHEL AND (type in (Story, Task) AND ("Story Points" is EMPTY OR priority is EMPTY) OR type not in (Story, Task) AND ("Story Points" is EMPTY OR priority is EMPTY OR Severity is EMPTY)) AND status != Closed ORDER BY id DESC',
});
expect(issues).toMatchInlineSnapshot(`
[
Expand Down Expand Up @@ -232,7 +232,7 @@ describe('Jira functions', () => {

issues = await jira.getIssues('component', undefined, undefined, undefined);
expect(jira.JQL).toMatchInlineSnapshot(
`"Project = RHEL AND (type = Story AND ("Story Points" is EMPTY OR priority is EMPTY) OR type != Story AND ("Story Points" is EMPTY OR priority is EMPTY OR Severity is EMPTY)) AND status != Closed AND component = component ORDER BY id DESC"`
`"Project = RHEL AND (type in (Story, Task) AND ("Story Points" is EMPTY OR priority is EMPTY) OR type not in (Story, Task) AND ("Story Points" is EMPTY OR priority is EMPTY OR Severity is EMPTY)) AND status != Closed AND component = component ORDER BY id DESC"`
);

issues = await jira.getIssues(
Expand All @@ -242,7 +242,7 @@ describe('Jira functions', () => {
undefined
);
expect(jira.JQL).toMatchInlineSnapshot(
`"Project = RHEL AND (type = Story AND ("Story Points" is EMPTY OR priority is EMPTY) OR type != Story AND ("Story Points" is EMPTY OR priority is EMPTY OR Severity is EMPTY)) AND status != Closed AND component = component AND assignee = "assignee" ORDER BY id DESC"`
`"Project = RHEL AND (type in (Story, Task) AND ("Story Points" is EMPTY OR priority is EMPTY) OR type not in (Story, Task) AND ("Story Points" is EMPTY OR priority is EMPTY OR Severity is EMPTY)) AND status != Closed AND component = component AND assignee = "assignee" ORDER BY id DESC"`
);

issues = await jira.getIssues(
Expand All @@ -252,12 +252,12 @@ describe('Jira functions', () => {
undefined
);
expect(jira.JQL).toMatchInlineSnapshot(
`"Project = RHEL AND (type = Story AND ("Story Points" is EMPTY OR priority is EMPTY) OR type != Story AND ("Story Points" is EMPTY OR priority is EMPTY OR Severity is EMPTY)) AND status != Closed AND component = component AND assignee = "assignee" AND developer = "developer" ORDER BY id DESC"`
`"Project = RHEL AND (type in (Story, Task) AND ("Story Points" is EMPTY OR priority is EMPTY) OR type not in (Story, Task) AND ("Story Points" is EMPTY OR priority is EMPTY OR Severity is EMPTY)) AND status != Closed AND component = component AND assignee = "assignee" AND developer = "developer" ORDER BY id DESC"`
);

issues = await jira.getIssues(undefined, undefined, undefined, 'customJQL');
expect(jira.JQL).toMatchInlineSnapshot(
`"Project = RHEL AND (type = Story AND ("Story Points" is EMPTY OR priority is EMPTY) OR type != Story AND ("Story Points" is EMPTY OR priority is EMPTY OR Severity is EMPTY)) AND status != Closed AND customJQL ORDER BY id DESC"`
`"Project = RHEL AND (type in (Story, Task) AND ("Story Points" is EMPTY OR priority is EMPTY) OR type not in (Story, Task) AND ("Story Points" is EMPTY OR priority is EMPTY OR Severity is EMPTY)) AND status != Closed AND customJQL ORDER BY id DESC"`
);
});

Expand Down
Loading