-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 6f192bf
Showing
3 changed files
with
77 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
ISC License | ||
|
||
Copyright (c) 2017 Brandon Keepers | ||
|
||
Permission to use, copy, modify, and/or distribute this software for any | ||
purpose with or without fee is hereby granted, provided that the above | ||
copyright notice and this permission notice appear in all copies. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES | ||
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF | ||
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR | ||
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES | ||
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN | ||
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF | ||
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
# Probot: metadata | ||
|
||
A [Probot](https://github.com/probot/probot) extension to store metadata on an Issue and Pull Request. | ||
|
||
## Usage | ||
|
||
```js | ||
const metadata = require('probot-metadata'); | ||
|
||
// where `context` is either a Probot `Context`, or an object with `owner`, `repo`, and `number values` | ||
metadata.set(context, key, value); | ||
const value = await metadata.get(context, key) | ||
``` | ||
|
||
## Example | ||
|
||
```js | ||
const metadata = require('probot-metadata'); | ||
|
||
module.exports = robot => { | ||
robot.on('issue_comment.created', context => { | ||
match = context.payload.comment.body.match('/snooze (.*)') | ||
if(match) { | ||
metadata.set(context, 'snooze', match[1]); | ||
} | ||
}) | ||
} | ||
``` | ||
|
||
## How it works | ||
|
||
This extension is what you might call "a hack". GitHub doesn't have an API for storing metadata on Issues and Pull Requests, but it does have rather large comment fields. GitHub renders the comments as Markdown and will strip any unsupported HTML (including HTML comments like `<!-- I can put whatever I want here -->`), but still serves up the raw comment body through the API. This extension takes advantage of this "feature" to store JSON values on Issues and Pull Requests as HTML comments. | ||
|
||
It will update the body of the original post and append an HTML comment with JSON values for each key. For example: | ||
|
||
```markdown | ||
This is the body of the original post | ||
|
||
<!-- probot = {"json": "here"} --> | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
{ | ||
"name": "probot-kv", | ||
"version": "1.0.0", | ||
"description": "Hack to key/value support to GitHub Issues & Pull Requests", | ||
"main": "index.js", | ||
"scripts": { | ||
"test": "mocha" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/probot/kv.git" | ||
}, | ||
"keywords": [ | ||
"probot" | ||
], | ||
"author": "Brandon Keepers", | ||
"license": "ISC", | ||
"bugs": { | ||
"url": "https://github.com/probot/kv/issues" | ||
}, | ||
"homepage": "https://github.com/probot/kv#readme" | ||
} |