Skip to content

add support for checking new issue against issue templates - #39

Merged
hiimbex merged 15 commits into
behaviorbot:masterfrom
shiftkey:check-issue-templates
Oct 18, 2018
Merged

add support for checking new issue against issue templates#39
hiimbex merged 15 commits into
behaviorbot:masterfrom
shiftkey:check-issue-templates

Conversation

@shiftkey

@shiftkeyshiftkey commented Sep 25, 2018

Copy link
Copy Markdown
Contributor

Fixes#8

  • first pass at the API work to check templates
  • write some tests to verify the behaviour

@welcome

welcomeBot commented Sep 25, 2018

Copy link
Copy Markdown

Thanks so much for opening your first PR here!

@shiftkeyshiftkey changed the title add support for checking new issue against issue templates[WIP] add support for checking new issue against issue templatesSep 25, 2018
@shiftkeyshiftkey changed the title [WIP] add support for checking new issue against issue templatesadd support for checking new issue against issue templatesSep 25, 2018
@shiftkey

Copy link
Copy Markdown
ContributorAuthor

I think this is ready for a review. I mostly just reused the existing test infrastructure, which was very helpful to ensure I hadn't broken anything!

@hiimbexhiimbex left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for taking this on @shiftkey! Super excited to see some progress here. 🎉

I left some thoughts/feedback in the comments, but the tldr is that this appears to suffer from the same issues that have prevented me from implementing this feature, which is how to actually pattern match against an issue template.

Comment threadindex.js
badBody = true
}
} else if (eventSrc === 'issue') {
if (!(await IssueBodyChecker.isBodyValid(body, config, context))) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you think about check config.checkIssueTemplate here?

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was me following the pattern that PullRequestBodyChecker used. I can move it out, just wanting to confirm I should ignore that.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hah! Typical that my code would contradict me. I didn't actually write PullRequestBodyChecker, but yea no need to match that pattern exactly. I think I'd rather not even call this function if that config option isn't listed

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is very minor, so I'll defer to you on whether matching the existing code or being slightly more efficient is better. Let me know which you decide @shiftkey and happy to merge this whenever.

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about we leave this as-is, and I'll follow up with a PR to lift both this config.checkIssueTemplate and config.checkPullRequestTemplate out of their relevant components and into here, so they remain consistent?

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@hiimbex friendly bump 👋

Comment threadlib/IssueBodyChecker.js Outdated
return false
}

if (config.checkIssueTemplate && (await isBodyEqualToTemplate(body, context))) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd recommend moving this check config.checkIssueTemplate in accordance with my previous comment!

Comment threadlib/IssueBodyChecker.js Outdated
try {
const singleTemplate = await context.github.repos.getContent({
owner: context.payload.repository.owner.login,
repo: context.payload.repository.name,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we clean this up using some probot internal APIs:

constsingleTemplate=awaitcontext.github.repos.getContent(context.repo({path}))

Comment threadlib/IssueBodyChecker.js Outdated
try {
const templatesDirectory = await context.github.repos.getContent({
owner: context.payload.repository.owner.login,
repo: context.payload.repository.name,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above

Comment threadlib/IssueBodyChecker.js
@hiimbex
hiimbex merged commit fc9c211 into behaviorbot:masterOct 18, 2018
@welcome

welcomeBot commented Oct 18, 2018

Copy link
Copy Markdown

Congrats on merging your first pull request here! 🎉 How awesome!

@hiimbex

Copy link
Copy Markdown
Member

Sorry for the delay! Thanks again for this @shiftkey 🎉

@shiftkey
shiftkey deleted the check-issue-templates branch October 18, 2018 15:03
This was referenced Oct 18, 2018
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

@shiftkey@hiimbex@j-f1