Skip to content

Commit

Permalink
Add possibility to assign TODO authors to the created issue
Browse files Browse the repository at this point in the history
  • Loading branch information
goce-cz committed Oct 27, 2021
1 parent 74cdb70 commit 0cee78e
Show file tree
Hide file tree
Showing 28 changed files with 651 additions and 77 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# v1.1.0
## Features
- Assign issues to TODO authors on GitHub

# v1.0.0
## Initial release
See [README.md](https://github.com/salsita/todo2issue/blob/v1.0.0/README.md) for usage instructions.
9 changes: 8 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ At the first run, it:
- finds TODOs and FIXMEs in your code
- groups them using their text
- creates a GitHub issue for each group with a specific label
- optionally assigns a user to the issue based on the author of the label (see `authorsByEmail` configuration option)
- references the issue in the code-base like `TODO(#123) Do something`

When ran again, it:
Expand Down Expand Up @@ -56,7 +57,10 @@ Then you should configure behavior of the tool using `todo2issue` property:
"**/*.js?(x)"
],
"issueLabel": "TODO",
"branch": "develop"
"branch": "develop",
"authorsByEmail": {
"[email protected]": "goce-cz"
}
},
// ...
}
Expand All @@ -71,6 +75,9 @@ Then you should configure behavior of the tool using `todo2issue` property:
- this label **MUST NOT** be assigned / unassigned manually
- `branch` - name of the branch to be used when referencing code from the generated issues
- defaults to active Git branch, but it is highly recommended fixing this in the config
- `authorsByEmail` - mapping between email of a commit author and a GitHub username
- if present, authors of TODOs are assigned to the created issues
- if present, and a mapping for particular email is missing, the sync fails (can be overridden by `--ignore-unresolved-users`)

### GitHub token
The tool needs GitHub personal access token to interact with GitHub API on your behalf.
Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

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

14 changes: 12 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "todo2issue",
"version": "1.0.0",
"version": "1.1.0",
"description": "CLI tool for in-code TODO synchronization to GitHub issues",
"main": "lib/index.js",
"scripts": {
Expand Down Expand Up @@ -30,12 +30,12 @@
"homepage": "https://github.com/salsita/todo2issue#readme",
"dependencies": {
"@expo/spawn-async": "^1.5.0",
"@octokit/rest": "^18.12.0",
"dotenv": "^10.0.0",
"escape-string-regexp": "^4.0.0",
"git-url-parse": "^11.6.0",
"globby": "^11.0.4",
"leasot": "^12.0.0",
"@octokit/rest": "^18.12.0",
"read-package-json": "^4.1.1",
"tslib": "^2.3.1",
"yargs": "^17.2.1"
Expand All @@ -47,5 +47,15 @@
"jest": "^27.2.5",
"ts-jest": "^27.0.6",
"typescript": "^4.4.4"
},
"todo2issue": {
"filePatterns": [
"sample/**/*.ts?(x)",
"sample/**/*.js?(x)"
],
"branch": "master",
"authorsByEmail": {
"[email protected]": "goce-cz"
}
}
}
13 changes: 0 additions & 13 deletions sample/package.json

This file was deleted.

7 changes: 5 additions & 2 deletions src/__snapshots__/config.spec.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,13 @@

exports[`readRepositoryConfig reads 1`] = `
Object {
"authorsByEmail": Object {
"[email protected]": "goce-cz",
},
"branch": "master",
"filePatterns": Array [
"**/*.ts?(x)",
"**/*.js?(x)",
"sample/**/*.ts?(x)",
"sample/**/*.js?(x)",
],
"issueLabel": "TODO",
"repo": Object {
Expand Down
34 changes: 34 additions & 0 deletions src/__snapshots__/find-authors.spec.ts.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`findAuthors finds authors 1`] = `
Array [
Object {
"author": "goce-cz",
"filename": "sample/src/index.ts",
"line": 1,
"tag": "TODO",
"text": "A",
},
Object {
"author": "goce-cz",
"filename": "sample/src/index.ts",
"line": 4,
"tag": "TODO",
"text": "B",
},
Object {
"author": "goce-cz",
"filename": "sample/src/helpers/helper.ts",
"line": 1,
"tag": "TODO",
"text": "C",
},
Object {
"author": "goce-cz",
"filename": "sample/src/index.ts",
"line": 16,
"tag": "TODO",
"text": "line comments",
},
]
`;
15 changes: 15 additions & 0 deletions src/__snapshots__/generate-issue-body.spec.ts.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`generateIssueBody generates description of issue 1`] = `
"---
_This issue origins from a TODO within the code-base and was synchronized automatically._
## Occurrences
### \`sample/src/index.ts\`
- [line 1](https://github.com/salsita/todo2issue/blob/master/sample/src/index.ts#L1) - Single line todo comment
- [line 2](https://github.com/salsita/todo2issue/blob/master/sample/src/index.ts#L2) - Single line todo comment with reference
---"
`;
50 changes: 50 additions & 0 deletions src/__snapshots__/git.spec.ts.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`parseBlameInfo parses blame info 1`] = `
Array [
Object {
"author": Object {
"email": "[email protected]",
"name": "Jiří Staniševský",
"time": 1634279203,
"timeZone": "+0200",
},
"commitHash": "aa73a7deb88f1487c0006abcd3b684bf91c2266e",
"committer": Object {
"email": "<[email protected]>",
"name": "Jiří Staniševský",
"time": 1634279340,
"timeZone": "+0200",
},
"filename": "sample/src/index.ts",
"lineEnd": 1,
"lineStart": 1,
"summary": "Add sample \\"code-base\\"",
"text": Array [
" // TODO Single line todo comment",
],
},
Object {
"author": Object {
"email": "[email protected]",
"name": "Jiří Staniševský",
"time": 1634279489,
"timeZone": "+0200",
},
"commitHash": "be1ec0218067e7152167afaf1de0f84e6c55fd43",
"committer": Object {
"email": "<[email protected]>",
"name": "Jiří Staniševský",
"time": 1634281973,
"timeZone": "+0200",
},
"filename": "sample/src/index.ts",
"lineEnd": 4,
"lineStart": 4,
"summary": "Scanning WiP",
"text": Array [
" // TODO(#123) Same reference different comment",
],
},
]
`;
153 changes: 153 additions & 0 deletions src/__snapshots__/group-todos-to-issues.spec.ts.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,153 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`groupTodosToIssues groups 1`] = `
Array [
Object {
"issueNumber": 123,
"todos": Array [
Object {
"filename": "src/index.ts",
"issueNumber": 123,
"line": 2,
"tag": "TODO",
"text": "Single line todo comment with reference",
},
Object {
"filename": "src/index.ts",
"issueNumber": 123,
"line": 4,
"tag": "TODO",
"text": "Same reference different comment",
},
Object {
"filename": "src/index.ts",
"issueNumber": undefined,
"line": 5,
"tag": "TODO",
"text": "Same reference different comment",
},
],
},
Object {
"issueNumber": 124,
"todos": Array [
Object {
"filename": "src/index.ts",
"issueNumber": 124,
"line": 12,
"tag": "TODO",
"text": "Multiline todo",
},
Object {
"filename": "src/index.ts",
"issueNumber": undefined,
"line": 7,
"tag": "TODO",
"text": "Multiline todo",
},
Object {
"filename": "src/helpers/helper.ts",
"issueNumber": undefined,
"line": 4,
"tag": "TODO",
"text": "Multiline todo",
},
],
},
Object {
"issueNumber": 125,
"todos": Array [
Object {
"filename": "src/index.ts",
"issueNumber": 125,
"line": 19,
"tag": "TODO",
"text": "Multiple single",
},
Object {
"filename": "src/helpers/helper.ts",
"issueNumber": 125,
"line": 7,
"tag": "TODO",
"text": "Related issue",
},
Object {
"filename": "src/index.ts",
"issueNumber": undefined,
"line": 15,
"tag": "TODO",
"text": "Multiple single",
},
],
},
Object {
"todos": Array [
Object {
"filename": "src/index.ts",
"issueNumber": undefined,
"line": 1,
"tag": "TODO",
"text": "Single line todo comment",
},
],
},
Object {
"todos": Array [
Object {
"filename": "src/index.ts",
"issueNumber": undefined,
"line": 16,
"tag": "TODO",
"text": "line comments",
},
],
},
Object {
"todos": Array [
Object {
"filename": "src/index.ts",
"issueNumber": undefined,
"line": 20,
"tag": "TODO",
"text": "line comments with reference",
},
],
},
Object {
"todos": Array [
Object {
"filename": "src/index.ts",
"issueNumber": undefined,
"line": 22,
"tag": "TODO",
"text": "With colon",
},
Object {
"filename": "src/index.ts",
"issueNumber": undefined,
"line": 24,
"tag": "TODO",
"text": "With colon",
},
Object {
"filename": "src/index.ts",
"issueNumber": undefined,
"line": 26,
"tag": "TODO",
"text": "With colon",
},
],
},
Object {
"todos": Array [
Object {
"filename": "src/helpers/helper.ts",
"issueNumber": undefined,
"line": 1,
"tag": "TODO",
"text": "This one is from a sub-folder",
},
],
},
]
`;
Loading

0 comments on commit 0cee78e

Please sign in to comment.