Skip to content

Commit

Permalink
handle in uniform manner subtasks
Browse files Browse the repository at this point in the history
  • Loading branch information
vstirbu committed Mar 23, 2021
1 parent df49aca commit bcb964c
Show file tree
Hide file tree
Showing 8 changed files with 264 additions and 231 deletions.
82 changes: 51 additions & 31 deletions dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

16 changes: 10 additions & 6 deletions features/Issue.instance.feature → features/Issue.feature
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ Feature: Issue instance

@issue-7
@issue-15
@issue-27
Scenario: Changes preserves content outside placeholder
Given event body
"""
Expand All @@ -72,7 +73,7 @@ Feature: Issue instance
{
"id": "3",
"title": "Added",
"closed": false,
"state": "open",
"removed": false,
"repo": "issue-tracer",
"owner": "CompliancePal"
Expand Down Expand Up @@ -101,6 +102,7 @@ Feature: Issue instance
"""

@issue-23
@issue-27
Scenario: Added duplicate cross reference subtask
Given event body
"""
Expand All @@ -110,14 +112,14 @@ Feature: Issue instance
### Related issues
- [x] Closed title (CompliancePal/cross-ref#1)
- [ ] Open title (#2)
"""
# - [ ] Open title (#2)
And existing cross reference subtask
"""
{
"id": "1",
"title": "Closed title",
"closed": true,
"state": "closed",
"removed": false,
"repo": "cross-ref",
"owner": "CompliancePal"
Expand All @@ -132,10 +134,11 @@ Feature: Issue instance
### Related issues
- [x] Closed title (CompliancePal/cross-ref#1)
- [ ] Open title (#2)
"""
# - [ ] Open title (#2)

@issue-11
@issue-27
Scenario: Changes added when the placeholder is at the end of document
Given body
"""
Expand All @@ -150,7 +153,7 @@ Feature: Issue instance
{
"id": "3",
"title": "Added",
"closed": false,
"state": "open",
"removed": false,
"repo": "issue-tracer",
"owner": "CompliancePal"
Expand All @@ -172,6 +175,7 @@ Feature: Issue instance
"""

@issue-9
@issue-27
Scenario: Changes not added on issue without placeholder
Given Issue body without placeholder
"""
Expand All @@ -182,7 +186,7 @@ Feature: Issue instance
{
"id": "3",
"title": "Added",
"closed": false,
"state": "open",
"removed": false,
"repo": "issue-tracer",
"owner": "CompliancePal"
Expand Down
14 changes: 2 additions & 12 deletions src/actions/issues.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import * as core from '@actions/core'
import * as github from '@actions/github'
import {IssuesOpenedEvent} from '@octokit/webhooks-definitions/schema'
import {Issue} from '../domain/Issue'
import {Subtask} from '../domain/Subtask'
import {IssuesRepo} from '../repo/Issues'

export const issuesHandler = async (ghToken: string): Promise<void> => {
Expand Down Expand Up @@ -37,19 +36,10 @@ export const issuesHandler = async (ghToken: string): Promise<void> => {
`Related issue ${relatedIssue.number} has ${relatedIssue.subtasks.size} subtasks`
)

relatedIssue.addSubtask(
Subtask.create({
id: issue.number.toString(),
title: issue.title,
closed: issue.closed,
owner: issue.owner,
repo: issue.repo,
crossReference: relatedIssue.isCrossReference(issue)
})
)
relatedIssue.addSubtask(issue)

await relatedIssue.save(repo)
// await repo.save(relatedIssue)

core.info(`Related issue ${relatedIssue.number} updated sucessfuly`)

core.setOutput('partOf', issue.partOf)
Expand Down
Loading

0 comments on commit bcb964c

Please sign in to comment.