Skip to content

Commit 22c613f

Browse files
committed
Allow named now-nows
1 parent 0e3d8a6 commit 22c613f

9 files changed

Lines changed: 200 additions & 121 deletions

File tree

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ Ensure you add:
4444
4545
To your daily `porter.yml`.
4646

47+
See [`action.yml`](./action.yml) for additional options.
48+
4749
### Using This Action to Git Things Done
4850

4951
**Right Now** items are considered so urgent they should be done today.

action.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,12 @@ inputs:
1515
Today’s entry issue number.
1616
If unset we use `$GTD_TODAY`.
1717
required: false
18+
name:
19+
description: >
20+
Look for a comment with this title.
21+
eg. `foo` will look for a comment that *begins* with `# foo`.
22+
Defaults to a comment titled “Now Now” or “Right Now”.
23+
required: false
1824
runs:
1925
using: node16
2026
main: dist/index.js

dist/index.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/index.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package-lock.json

Lines changed: 50 additions & 42 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,16 @@
44
"dist": "ncc build src/index.ts --minify --source-map"
55
},
66
"dependencies": {
7-
"marked": "^4.0.0"
7+
"marked": "^4.0.12"
88
},
99
"devDependencies": {
1010
"@actions/core": "^1.6.0",
1111
"@actions/github": "^5.0.0",
12-
"@types/marked": "^3.0.2",
13-
"@types/node": "^16.11.6",
12+
"@types/marked": "^4.0.1",
13+
"@types/node": "^17.0.13",
1414
"@vercel/ncc": "^0.33.1",
1515
"ts-node": "^10.3.1",
16-
"typescript": "^4.4.3"
16+
"typescript": "^4.5.5"
1717
},
1818
"type": "module"
1919
}

src/index.test.ts

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,14 +53,40 @@ test("zwsps are added to count “just now“ overdue days", () => {
5353
})
5454
})
5555

56+
test("comment-title works", () => {
57+
const output = parse([{
58+
id: 1,
59+
body: x(`
60+
# just now
61+
- [ ] task 3
62+
- [ ] task 4
63+
`)
64+
}, {
65+
id: 2,
66+
body: x(`
67+
# foo
68+
## right now
69+
- [ ] task 1
70+
- [ ] task 2
71+
`)
72+
}], "foo")
73+
74+
assertEquals(output, {
75+
"right-now": x(`
76+
- [ ] task 1 [1]
77+
- [ ] task 2 [1]
78+
`)
79+
})
80+
})
81+
5682
/// lib
5783
function test(name: string, fnc: () => void) {
5884
console.log(name)
5985
fnc()
6086
}
6187
function assertEquals(a: any, b: any) {
6288
if (!objectEquals(a, b)) {
63-
throw new Error(`${a} !== ${b}`)
89+
throw new Error(`${JSON.stringify(a)} !== ${JSON.stringify(b)}`)
6490
}
6591
}
6692
function x(input: string): string {

src/index.ts

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,27 +8,34 @@ const issue_number = parseInt((getInput('yesterday') || process.env.GTD_YESTERDA
88
const today = parseInt((getInput('today') || process.env.GTD_TODAY)!)
99
const token = getInput('token')!
1010
const octokit = github.getOctokit(token)
11+
const comment_title = getInput('name')
1112

1213

1314
if (issue_number) {
1415
const comments = (await octokit.rest.issues.listComments({
1516
owner, repo, issue_number
1617
})).data
1718

18-
const parsed = parse(comments)
19+
const parsed = parse(comments, comment_title)
1920

2021
let body = ''
22+
let h = '##'
23+
24+
if (comment_title) {
25+
body += `# ${comment_title}`
26+
h = '##'
27+
}
2128

2229
if (parsed['right-now']) body += `
23-
# Right Now
30+
${h} Right Now
2431
${parsed['right-now']}
2532
`
2633
if (parsed['now-now']) body += `
27-
# Now Now
34+
${h} Now Now
2835
${parsed['now-now']}
2936
`
3037
if (parsed['just-now']) body += `
31-
# Just Now
38+
${h} Just Now
3239
<details>
3340
<summary>${parsed['just-now'].split("\n").length} Items</summary>
3441
@@ -37,7 +44,7 @@ ${parsed['just-now']}
3744
</details>
3845
`
3946
if (parsed['now']) body += `
40-
# Now
47+
${h} Now
4148
<details>
4249
<summary>${parsed['now'].split("\n").length} Items</summary>
4350

0 commit comments

Comments
 (0)