Skip to content
Open

done #56

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
97 commits
Select commit Hold shift + click to select a range
a72193b
Merge pull request #1 from behaviorbot/updates
Jul 19, 2017
fd8c1ca
Update README.md
Jul 19, 2017
67d6428
Update index.js
Jul 21, 2017
f7b85f1
Create CODE_OF_CONDUCT.md
Jul 28, 2017
58fef99
Create .travis.yml
Jul 28, 2017
b12218a
linting
Jul 28, 2017
1b2eaa2
Merge pull request #3 from behaviorbot/lint
Jul 28, 2017
7694c33
Merge pull request #2 from behaviorbot/add-code-of-conduct-1
Jul 28, 2017
327a9af
Create LICENSE
Jul 28, 2017
8916fbc
Merge pull request #4 from behaviorbot/add-license-1
Jul 28, 2017
103bc61
Create CONTRIBUTING.md
Jul 28, 2017
e9b75d7
update probot and add engines
Aug 1, 2017
f13cb84
Merge pull request #5 from behaviorbot/update-probot
Aug 1, 2017
87d4bee
Update README.md
Aug 4, 2017
b25f9bf
make default titles optional
Aug 7, 2017
f93287e
Merge pull request #6 from behaviorbot/optional-titles
Aug 7, 2017
68e08a8
Create config.yml
Aug 15, 2017
7e006f2
add default comment
hiimbex Sep 15, 2017
4c42dd8
updates documentation to show default message
hiimbex Sep 15, 2017
d653f82
Merge pull request #9 from behaviorbot/add-default
hiimbex Sep 15, 2017
96eb303
actually add defaults
hiimbex Sep 15, 2017
feee4ec
update probot and swap to standard lint
hiimbex Sep 15, 2017
d629c8a
Merge pull request #10 from behaviorbot/standard
hiimbex Sep 15, 2017
affdf1e
Adding capability to disable info request for some events
nMustaki Oct 15, 2017
e3dbf47
RequestOnType : fix missing semicolons and extract CONFIG from function
nMustaki Oct 15, 2017
4cec508
RequestOnType : make eslint happy
nMustaki Oct 15, 2017
58b8b59
Update tests
nMustaki Oct 15, 2017
f9ab0b2
Merge pull request #13 from nMustaki/feature/only_request_on_type
hiimbex Oct 16, 2017
58390db
update probot and style
hiimbex Oct 16, 2017
866c9e0
Merge pull request #15 from behaviorbot/style
hiimbex Oct 16, 2017
67a9c81
FIX #14 Multiple random messages
nMustaki Oct 17, 2017
79991b2
Update docs
nMustaki Oct 17, 2017
ddd93d0
Merge pull request #16 from nMustaki/feature/multipleComments
hiimbex Oct 17, 2017
7e51d7b
add test for when reply comment is array
hiimbex Oct 17, 2017
ae36f1d
Merge pull request #17 from behaviorbot/rand-test
hiimbex Oct 17, 2017
73d09d4
add users to excluse param
hiimbex Oct 17, 2017
2e67240
Merge pull request #18 from behaviorbot/add-users-to-exclude
hiimbex Oct 17, 2017
348d5b2
clarify that reply comment is now optional
hiimbex Oct 17, 2017
96c9f19
update probot
hiimbex Oct 19, 2017
f692ade
Merge pull request #19 from behaviorbot/probot
hiimbex Oct 19, 2017
33caee0
remove param reassignment antipattern
codebytere Oct 19, 2017
6d67757
simplify ternary
codebytere Oct 19, 2017
ac532ce
Fix docs for filtering based on issue type
j-f1 Oct 19, 2017
cc51ea4
Merge pull request #22 from j-f1/patch-1
hiimbex Oct 21, 2017
eb14e62
Merge pull request #21 from codebytere/remove_param_reassign
hiimbex Oct 21, 2017
37e8bc5
fix default config
hiimbex Dec 7, 2017
7ac8bf6
Merge pull request #27 from behaviorbot/hiimbex-patch-1
hiimbex Dec 7, 2017
dc3a632
add option to check for PR template body
BrechtBonte Feb 26, 2018
be73268
add tests for PR template functionality
BrechtBonte Feb 27, 2018
3760d20
Update package.json
Apr 13, 2018
fb6af18
Merge pull request #33 from aps120797/patch-1
hiimbex Apr 13, 2018
6ecbf36
Merge pull request #32 from marlon-be/feature/default-pr-body
hiimbex Apr 16, 2018
0b917d2
Fix: Typo fix and improves clearity.
aryannarora Apr 16, 2018
578ad95
Merge pull request #34 from aryannarora/patch-4
hiimbex Apr 16, 2018
b0045fa
Updated package.json and .gitignore
knrt10 Apr 17, 2018
5b67510
Updated travil.yml file
knrt10 Apr 17, 2018
2f4ceb5
Merge pull request #35 from knrt10/packageFile
hiimbex Apr 20, 2018
cb2c852
implement probot-config
hiimbex Jul 13, 2018
c245141
Merge pull request #37 from behaviorbot/probot-config
hiimbex Jul 13, 2018
826192c
stub IssueBodyChecker to check templates
shiftkey Sep 25, 2018
2c576ba
add something to the README
shiftkey Sep 25, 2018
62a6133
inject the new rules for checking the issue body
shiftkey Sep 25, 2018
2116e61
refactor and introduce resilience for the API checks
shiftkey Sep 25, 2018
731ebc0
address standard fixes
shiftkey Sep 25, 2018
9bf5580
sketch out new tests
shiftkey Sep 25, 2018
6e32d6f
first couple of tests added
shiftkey Sep 25, 2018
a10761c
add more tests
shiftkey Sep 25, 2018
5038742
tidy up things
shiftkey Sep 25, 2018
428ec46
last set of tests
shiftkey Sep 25, 2018
49e94a4
tidy up
shiftkey Sep 25, 2018
a0aad36
no need to set these
shiftkey Sep 25, 2018
a99712f
use probot internal APIs
shiftkey Sep 26, 2018
9e88b9d
Update package.json to require probot v7.20 or higher
shermanhui Oct 6, 2018
5cd7cc1
Update test file to load Application
shermanhui Oct 6, 2018
d999b48
Remove the use of the deprecated `event` key
shermanhui Oct 6, 2018
41f458f
Add tests
JasonEtco Oct 10, 2018
ec91d4d
Add handler
JasonEtco Oct 10, 2018
462e785
Comment instead of create an issue
JasonEtco Oct 10, 2018
af149d9
Fix tests
JasonEtco Oct 10, 2018
e6e120a
Whoops typo
JasonEtco Oct 10, 2018
8387cdd
follow functions pattern
hiimbex Oct 10, 2018
aece18f
lol this is what i get for editting in the browser
hiimbex Oct 10, 2018
06f57ae
make test more clear
hiimbex Oct 10, 2018
fab44ce
Merge pull request #42 from JasonEtco/intro-to-github-apps
hiimbex Oct 10, 2018
e35d126
Remove instances of `robot` in favor of `app`
shermanhui Oct 11, 2018
a81c006
Merge branch 'master' into update-probot-version
shermanhui Oct 11, 2018
e1ceb14
Remove typo in index file
shermanhui Oct 11, 2018
413fc86
Merge branch 'master' into check-issue-templates
shiftkey Oct 11, 2018
dc9b3ee
Remove references to `robot`
shermanhui Oct 11, 2018
40021be
Merge pull request #40 from shui91/update-probot-version
hiimbex Oct 17, 2018
8927ee8
Merge branch 'master' into check-issue-templates
shiftkey Oct 18, 2018
fc9c211
Merge pull request #39 from shiftkey/check-issue-templates
hiimbex Oct 18, 2018
f977b79
lify up config checks into main path
shiftkey Oct 18, 2018
6958f74
remove unnecessary parameter
shiftkey Oct 18, 2018
d3a5fb7
Merge pull request #43 from shiftkey/tidy-up-config-checks
hiimbex Oct 19, 2018
3e109f1
bump node
tcbyrd Oct 13, 2021
bc1dc1e
Merge pull request #60 from behaviorbot/bump-node
hiimbex Oct 13, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions .github/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
updateDocsWhiteList:
- BUG
- Chore
- minor

updateDocsComment: >
Thanks for opening this pull request! The maintainers of this repository would appreciate it if you would update some of our documentation based on your changes.

requestInfoReplyComment: >
We would appreciate it if you could provide us with more info about this issue/pr!

requestInfoLabelToAdd: request-more-info

newPRWelcomeComment: >
Thanks so much for opening your first PR here!

firstPRMergeComment: >
Congrats on merging your first pull request here! :tada: How awesome!

newIssueWelcomeComment: >
Thanks for opening this issue, a maintainer will get back to you shortly!

sentimentBotToxicityThreshold: .7

sentimentBotReplyComment: >
Please be sure to review the code of conduct and be respectful of other users. cc/ @hiimbex

lockThreads:
toxicityThreshold: .7
numComments: 2
setTimeInHours: 72
replyComment: >
This thread is being locked due to exceeding the toxicity minimums. cc/ @hiimbex
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
node_modules
*.pem
.DS_Store
package-lock.json
6 changes: 6 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
sudo: false
language: node_js
node_js:
- "8"
notifications:
disabled: true
46 changes: 46 additions & 0 deletions CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# Contributor Covenant Code of Conduct

## Our Pledge

In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, gender identity and expression, level of experience, nationality, personal appearance, race, religion, or sexual identity and orientation.

## Our Standards

Examples of behavior that contributes to creating a positive environment include:

* Using welcoming and inclusive language
* Being respectful of differing viewpoints and experiences
* Gracefully accepting constructive criticism
* Focusing on what is best for the community
* Showing empathy towards other community members

Examples of unacceptable behavior by participants include:

* The use of sexualized language or imagery and unwelcome sexual attention or advances
* Trolling, insulting/derogatory comments, and personal or political attacks
* Public or private harassment
* Publishing others' private information, such as a physical or electronic address, without explicit permission
* Other conduct which could reasonably be considered inappropriate in a professional setting

## Our Responsibilities

Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior.

Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful.

## Scope

This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers.

## Enforcement

Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at [email protected]. The project team will review and investigate all complaints, and will respond in a way that it deems appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately.

Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership.

## Attribution

This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, available at [http://contributor-covenant.org/version/1/4][version]

[homepage]: http://contributor-covenant.org
[version]: http://contributor-covenant.org/version/1/4/
35 changes: 35 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
## Contributing

[fork]: https://github.com/behaviorbot/request-info/fork
[pr]: https://github.com/behaviorbot/request-info/compare
[style]: https://github.com/probot/eslint-config-probot
[code-of-conduct]: CODE_OF_CONDUCT.md

Hi there! We're thrilled that you'd like to contribute to this project. Your help is essential for keeping it great.

Please note that this project is released with a [Contributor Code of Conduct][code-of-conduct]. By participating in this project you agree to abide by its terms.

## Submitting a pull request

0. [Fork][fork] and clone the repository
0. Configure and install the dependencies: `npm install`
0. Make sure the tests pass on your machine: `npm test`
0. Create a new branch: `git checkout -b my-branch-name`
0. Make your change, add tests, and make sure the tests still pass
0. Push to your fork and [submit a pull request][pr]
0. Pat your self on the back and wait for your pull request to be reviewed and merged.

Here are a few things you can do that will increase the likelihood of your pull request being accepted:

- Follow the [style guide][style] which is a custom eslint linter.
- Write and update tests.
- Keep your change as focused as possible. If there are multiple changes you would like to make that are not dependent upon each other, consider submitting them as separate pull requests.
- Write a [good commit message](http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html).

Work in Progress pull request are also welcome to get feedback early on, or if there is something blocked you.

## Resources

- [How to Contribute to Open Source](https://opensource.guide/how-to-contribute/)
- [Using Pull Requests](https://help.github.com/articles/about-pull-requests/)
- [GitHub Help](https://help.github.com)
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2017 Bex Warner

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
46 changes: 39 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# request-info

> a GitHub App built with [probot](https://github.com/probot/probot) that requests more info from newly opened Pull Requests and Issues that contain either default titles or whose description is left blank. It does so by taking data from a file located in a `.github/request-info.md` and replying with the contents of that file.
> a GitHub App built with [probot](https://github.com/probot/probot) that requests more info from newly opened Pull Requests and Issues that contain either default titles or whose description is left blank. It does so by taking data from a `.github/config.yml`.

<img width="1041" alt="screen shot 2017-07-07 at 3 32 01 pm" src="https://user-images.githubusercontent.com/13410355/28132821-d37bf2a8-66f2-11e7-9e7b-5930ba65d67a.png">

Expand All @@ -16,18 +16,50 @@
```yml
# Configuration for request-info - https://github.com/behaviorbot/request-info

# *Required* default titles to check against for lack of descriptiveness
# *OPTIONAL* Comment to reply with
# Can be either a string :
requestInfoReplyComment: >
We would appreciate it if you could provide us with more info about this issue/pr!

# Or an array:
# requestInfoReplyComment:
# - Ah no! young blade! That was a trifle short!
# - Tell me more !
# - I am sure you can be more effusive


# *OPTIONAL* default titles to check against for lack of descriptiveness
# MUST BE ALL LOWERCASE
requestInfoDefaultTitles:
- update readme.md
- updates

# *Required* Comment to reply with
requestInfoReplyComment: >
We would appreciate it if you could provide us with more info about this issue/pr!

# *OPTIONAL* Label to be added to Issues and Pull Requests with insufficient information given
requestInfolabelToAdd: needs-more-info
requestInfoLabelToAdd: needs-more-info

# *OPTIONAL* Require Issues to contain more information than what is provided in the issue templates
# Will fail if the issue's body is equal to a provided template
checkIssueTemplate: true

# *OPTIONAL* Require Pull Requests to contain more information than what is provided in the PR template
# Will fail if the pull request's body is equal to the provided template
checkPullRequestTemplate: true

# *OPTIONAL* Only warn about insufficient information on these events type
# Keys must be lowercase. Valid values are 'issue' and 'pullRequest'
requestInfoOn:
pullRequest: true
issue: true

# *OPTIONAL* Add a list of people whose Issues/PRs will not be commented on
# keys must be GitHub usernames
requestInfoUserstoExclude:
- hiimbex
- bexo
```
3. If you prefer not to add a `.github/config.yml` file, you can simply install the bot and it would comment on issues and pull requests that have empty bodies, with the comment:
```
The maintainers of this repository would appreciate it if you could provide more information.
```

## Setup
Expand Down
102 changes: 76 additions & 26 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,33 +1,83 @@
const yaml = require('js-yaml');

module.exports = robot => {
robot.on('pull_request.opened', receive);
robot.on('issues.opened', receive);
async function receive(context) {
let title, body, config, badTitle;
if (context.payload.pull_request) {
({ title, body } = context.payload.pull_request);
} else {
({ title, body } = context.payload.issue);
const getComment = require('./lib/getComment')
const defaultConfig = require('./lib/defaultConfig')
const PullRequestBodyChecker = require('./lib/PullRequestBodyChecker')
const IssueBodyChecker = require('./lib/IssueBodyChecker')
const getConfig = require('probot-config')

module.exports = app => {
app.on('installation_repositories.added', learningLabWelcome)
app.on(['pull_request.opened', 'issues.opened'], receive)
async function receive (context) {
let title
let body
let badTitle
let badBody
let user

let eventSrc = 'issue'
if (context.payload.pull_request) {
({title, body, user} = context.payload.pull_request)
eventSrc = 'pullRequest'
} else {
({title, body, user} = context.payload.issue)
}

try {
const config = await getConfig(context, 'config.yml', defaultConfig)

if (!config.requestInfoOn[eventSrc]) {
return
}

if (config.requestInfoDefaultTitles) {
if (config.requestInfoDefaultTitles.includes(title.toLowerCase())) {
badTitle = true
}
}

try {
const options = context.repo({path: '.github/config.yml'});
const response = await context.github.repos.getContent(options);
config = yaml.load(Buffer.from(response.data.content, 'base64').toString()) || {};
} catch (err) {
if (err.code !== 404) throw err;
if (eventSrc === 'pullRequest') {
if (config.checkPullRequestTemplate && !(await PullRequestBodyChecker.isBodyValid(body, context))) {
badBody = true
}
} else if (eventSrc === 'issue') {
if (config.checkIssueTemplate && !(await IssueBodyChecker.isBodyValid(body, context))) {
badBody = true
}
}

if (config) {
if (config.requestInfoDefaultTitles.includes(title.toLowerCase())) badTitle = true;
let notExcludedUser = true
if (config.requestInfoUserstoExclude) {
if (config.requestInfoUserstoExclude.includes(user.login)) {
notExcludedUser = false
}
if (!body || badTitle) {
context.github.issues.createComment(context.issue({body: config.requestInfoReplyComment}));
if (config.requestInfoLabelToAdd) {
// Add label if there is one listed in the yaml file
context.github.issues.addLabels(context.issue({labels: [config.requestInfoLabelToAdd]}));
}
}
if ((!body || badTitle || badBody) && notExcludedUser) {
const comment = getComment(config.requestInfoReplyComment, defaultConfig.requestInfoReplyComment)
context.github.issues.createComment(context.issue({body: comment}))

if (config.requestInfoLabelToAdd) {
// Add label if there is one listed in the yaml file
context.github.issues.addLabels(context.issue({labels: [config.requestInfoLabelToAdd]}))
}
}
} catch (err) {
if (err.code !== 404) {
throw err
}
}
};
}

// Say hi!
const NAME = 'introduction-to-github-apps'
async function learningLabWelcome (context) {
const includes = context.payload.repositories_added.some(r => r.name === NAME)
if (!includes) return

return context.github.issues.createComment({
owner: context.payload.installation.account.login,
repo: NAME,
number: 2,
body: 'Well done! You successfully installed the request info app.\n\n_disclaimer_ If you use this app in future repos, you won\'t get a message like this. This is just for Learning Lab!'
})
}
}
Loading