-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add labels in a more principled way. #90
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,16 +5,19 @@ import {execCmd} from './execCmd'; | |
import {ownerAndRepo, extraPermGithub, type Context} from './setup'; | ||
import {PUSH, GERALD_COMMIT_COMMENT_HEADER} from './constants'; | ||
|
||
const makeCommitComment = async ( | ||
peopleToFiles: {[string]: Array<string>, ...}, | ||
commitSHA: string, | ||
) => { | ||
const names: string[] = Object.keys(peopleToFiles); | ||
if (peopleToFiles && names.length) { | ||
type NameToLabelToFiles = {[name: string]: {[label: string]: string[], ...}, ...}; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we put this somewhere shared so as to not dupe? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If you want. I like having it in each place so it's easier to find when reading the file; flow won't let them get out of sync. But I know some people feel very militant about DRY! |
||
|
||
const makeCommitComment = async (peopleToLabelToFiles: NameToLabelToFiles, commitSHA: string) => { | ||
const names: string[] = Object.keys(peopleToLabelToFiles); | ||
if (peopleToLabelToFiles && names.length) { | ||
let body: string = GERALD_COMMIT_COMMENT_HEADER; | ||
names.forEach((person: string) => { | ||
const files = peopleToFiles[person]; | ||
body += `${person} for changes to \`${files.join('`, `')}\`\n`; | ||
const labels: string[] = Object.keys(peopleToLabelToFiles[person]); | ||
labels.forEach((label: string) => { | ||
const files = peopleToLabelToFiles[person][label]; | ||
const labelText = label ? ` (${label})` : ''; | ||
body += `${person} for changes to \`${files.join('`, `')}\`${labelText}\n`; | ||
}); | ||
}); | ||
|
||
await extraPermGithub.repos.createCommitComment({ | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Before, if there were multiple matching rules, I think it would do:
Then in the comment it would do:
But now if there are multiple matching rules, I think I would want:
I'm not clear if this structure gets us to that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, it does! You can see in some of the test output.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe it does, but the syntax is starting to twist my head...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If js allowed non-string map keys, I could do a map from
(person, label)
to[files]
, but it doesn't, so this is the best I could do...