Skip to content

Commit

Permalink
Merge pull request #334 from crs-k/Output-totals-update
Browse files Browse the repository at this point in the history
Output totals update
  • Loading branch information
crs-k authored Feb 26, 2022
2 parents da086e0 + dec0313 commit 584f88d
Show file tree
Hide file tree
Showing 7 changed files with 70 additions and 10 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Stale Branches
uses: crs-k/stale-branches@v1.0.0
uses: crs-k/stale-branches@v1.3.2
with:
repo-token: "${{ secrets.GITHUB_TOKEN }}"
```
Expand Down
51 changes: 47 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/logging/log-max-issues.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ export function logMaxIssues(issueBudgetRemaining): string {

//color group based on age of branch
if (issueBudgetRemaining < 1) {
maxIssues = `[${styles.redBright.open}${issueBudgetRemaining}${styles.redBright.close}] max-issues budget remaining.`
maxIssues = `${styles.bold.open}[${styles.redBright.open}${issueBudgetRemaining}${styles.redBright.close}] ${styles.blueBright.open}max-issues budget remaining${styles.blueBright.close}.${styles.bold.close}`
} else if (issueBudgetRemaining < 5) {
maxIssues = `[${styles.yellowBright.open}${issueBudgetRemaining}${styles.yellowBright.close}] max-issues budget remaining.`
maxIssues = `${styles.bold.open}[${styles.yellowBright.open}${issueBudgetRemaining}${styles.yellowBright.close}] ${styles.blueBright.open}max-issues budget remaining${styles.blueBright.close}.${styles.bold.close}`
}

return maxIssues
Expand Down
7 changes: 7 additions & 0 deletions src/functions/logging/log-total-assessed.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import styles from 'ansi-styles'

export function logTotalAssessed(outputStales, outputTotal): string {
const totalAssessed = `${styles.bold.open}${styles.blueBright.open}Stale Branches Assessed${styles.blueBright.close}: [${styles.yellowBright.open}${outputStales}${styles.yellowBright.close}/${styles.magenta.open}${outputTotal}${styles.magenta.close}]${styles.bold.close}`

return totalAssessed
}
7 changes: 7 additions & 0 deletions src/functions/logging/log-total-deleted.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import styles from 'ansi-styles'

export function logTotalDeleted(outputDeletes, outputStales): string {
const totalDeleted = `${styles.bold.open}${styles.blueBright.open}Stale Branches Deleted${styles.blueBright.close}: [${styles.redBright.open}${outputDeletes}${styles.redBright.close}/${styles.yellowBright.open}${outputStales}${styles.yellowBright.close}]${styles.bold.close}`

return totalDeleted
}
7 changes: 5 additions & 2 deletions src/stale-branches.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ import {logActiveBranch} from './functions/logging/log-active-branch'
import {logBranchGroupColor} from './functions/logging/log-branch-group-color'
import {logLastCommitColor} from './functions/logging/log-last-commit-color'
import {logMaxIssues} from './functions/logging/log-max-issues'
import {logTotalAssessed} from './functions/logging/log-total-assessed'
import {logTotalDeleted} from './functions/logging/log-total-deleted'
import {updateIssue} from './functions/update-issue'

export async function run(): Promise<void> {
Expand All @@ -21,6 +23,7 @@ export async function run(): Promise<void> {
try {
//Collect Branches & budget
const branches = await getBranches()
const outputTotal = branches.length
let issueBudgetRemaining = await getIssueBudget()
const existingIssue = await getIssues()

Expand Down Expand Up @@ -86,8 +89,8 @@ export async function run(): Promise<void> {
}
core.setOutput('stale-branches', JSON.stringify(outputStales))
core.setOutput('deleted-branches', JSON.stringify(outputDeletes))
core.info(`Stale Branches: ${outputStales.length}`)
core.info(`Deleted Branches: ${outputDeletes.length}`)
core.info(logTotalAssessed(outputStales.length, outputTotal))
core.info(logTotalDeleted(outputDeletes.length, outputStales.length))
} catch (error) {
if (error instanceof Error) core.setFailed(`Action failed. Error: ${error.message}`)
}
Expand Down

0 comments on commit 584f88d

Please sign in to comment.