Skip to content

Commit

Permalink
Merge pull request #283 from crs-k/documentation-cleanup
Browse files Browse the repository at this point in the history
documentation cleanup
  • Loading branch information
crs-k authored Feb 17, 2022
2 parents d109828 + fdfcd02 commit 215da38
Show file tree
Hide file tree
Showing 9 changed files with 24 additions and 16 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ Inputs are defined in [`action.yml`](action.yml):
| `days-before-delete` | `No` | Number of days a branch has been inactive before it is deleted. | 180 days |
| `comment-updates` | `No` | If this is enabled, a comment with updated information will be added to existing issues each workflow run. | false |
| `max-issues` | `No` | This is the maximum number of branches that this action will assess per workflow run. | 20 |
| `tag-committer` | `No` | When an issue is opened, this will tag the stale branchs last committer in the comments. | false |

### Outputs
Outputs are defined in [`action.yml`](action.yml):
Expand Down
4 changes: 2 additions & 2 deletions __tests__/functions/create-issue.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@ let lastCommitter = 'crs-k'

describe('Create Issue Function', () => {
test('createIssue endpoint is called with tag committer enabled', async () => {
Object.defineProperty(context, 'tagLastComitter', {value: true})
Object.defineProperty(context, 'tagLastCommitter', {value: true})
await createIssue(branchName, commitAge, lastCommitter)
expect(github.rest.issues.create).toHaveBeenCalled()
})

test('createIssue endpoint is called with tag committer disabled', async () => {
Object.defineProperty(context, 'tagLastComitter', {value: false})
Object.defineProperty(context, 'tagLastCommitter', {value: false})
await createIssue(branchName, commitAge, lastCommitter)
expect(github.rest.issues.create).toHaveBeenCalled()
})
Expand Down
4 changes: 2 additions & 2 deletions __tests__/functions/update-issue.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@ let lastCommitter = 'crs-k'
describe('Get Commits Function', () => {
test('updateIssue endpoint is called with tag committer enabled', async () => {
Object.defineProperty(context, 'commentUpdates', {value: true})
Object.defineProperty(context, 'tagLastComitter', {value: true})
Object.defineProperty(context, 'tagLastCommitter', {value: true})
await updateIssue(issueNumber, branchName, commitAge, lastCommitter)
expect(github.rest.issues.createComment).toHaveBeenCalled()
})

test('updateIssue endpoint is called with tag committer disabled', async () => {
Object.defineProperty(context, 'commentUpdates', {value: true})
Object.defineProperty(context, 'tagLastComitter', {value: false})
Object.defineProperty(context, 'tagLastCommitter', {value: false})
await updateIssue(issueNumber, branchName, commitAge, lastCommitter)
expect(github.rest.issues.createComment).toHaveBeenCalled()
})
Expand Down
4 changes: 2 additions & 2 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ inputs:
required: false
default: '20'
tag-committer:
description: 'When an issue is opened, this will tag the stale branchs last comitter in the comments.'
description: 'When an issue is opened, this will tag the stale branchs last committer in the comments.'
required: false
default: false
outputs:
Expand All @@ -33,5 +33,5 @@ runs:
using: 'node12'
main: 'dist/index.js'
branding:
icon: 'save'
icon: 'delete'
color: 'blue'
8 changes: 4 additions & 4 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.

4 changes: 2 additions & 2 deletions src/functions/create-issue.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as assert from 'assert'
import * as core from '@actions/core'
import {daysBeforeDelete, github, owner, repo, tagLastComitter} from './get-context'
import {daysBeforeDelete, github, owner, repo, tagLastCommitter} from './get-context'

export async function createIssue(
branch: string,
Expand All @@ -11,7 +11,7 @@ export async function createIssue(
let bodyString: string
const daysUntilDelete = Math.max(0, daysBeforeDelete - commitAge)

switch (tagLastComitter) {
switch (tagLastCommitter) {
case true:
bodyString = `@${lastCommitter}, \r \r ${branch} has had no activity for ${commitAge.toString()} days. \r \r This branch will be automatically deleted in ${daysUntilDelete.toString()} days.`
break
Expand Down
2 changes: 1 addition & 1 deletion src/functions/get-context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ export const daysBeforeStale = Number(core.getInput('days-before-stale', {requir
export const daysBeforeDelete = Number(core.getInput('days-before-delete', {required: false}))
export const commentUpdates = core.getBooleanInput('comment-updates', {required: false})
export const maxIssues = Number(core.getInput('max-issues', {required: false}))
export const tagLastComitter = core.getBooleanInput('tag-committer', {required: false})
export const tagLastCommitter = core.getBooleanInput('tag-committer', {required: false})
11 changes: 9 additions & 2 deletions src/functions/update-issue.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
import * as assert from 'assert'
import * as core from '@actions/core'
import {commentUpdates, daysBeforeDelete, github, owner, repo, tagLastComitter} from './get-context'
import {
commentUpdates,
daysBeforeDelete,
github,
owner,
repo,
tagLastCommitter
} from './get-context'

export async function updateIssue(
issueNumber: number,
Expand All @@ -14,7 +21,7 @@ export async function updateIssue(
const daysUntilDelete = Math.max(0, daysBeforeDelete - commitAge)

if (commentUpdates === true) {
switch (tagLastComitter) {
switch (tagLastCommitter) {
case true:
bodyString = `@${lastCommitter}, \r \r ${branch} has had no activity for ${commitAge.toString()} days. \r \r This branch will be automatically deleted in ${daysUntilDelete.toString()} days. \r \r This issue was last updated on ${new Date().toString()}`
break
Expand Down

0 comments on commit 215da38

Please sign in to comment.