Skip to content

Commit

Permalink
feat: extend settings from a different repository
Browse files Browse the repository at this point in the history
  • Loading branch information
dessant committed Jun 16, 2018
1 parent 67fad24 commit 6affa95
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 8 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ close: true

# Lock issues marked as support requests
lock: false

# Repository to extend settings from
# _extends: repo
```

## Deployment
Expand Down
3 changes: 3 additions & 0 deletions assets/app-description.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ close: true

# Lock issues marked as support requests
lock: false

# Repository to extend settings from
# _extends: repo
```

## Supporting the Project
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@
],
"dependencies": {
"joi": "^13.3.0",
"probot": "^6.2.0"
"probot": "^6.2.0",
"probot-config": "^0.1.0"
},
"devDependencies": {
"nodemon": "^1.17.5",
Expand Down
16 changes: 9 additions & 7 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -1,40 +1,42 @@
const Support = require('./support');
const getMergedConfig = require('probot-config');

const App = require('./support');
const schema = require('./schema');

module.exports = robot => {
robot.on('issues.labeled', async context => {
const app = await getSupport(context);
const app = await getApp(context);
if (app) {
await app.labeled();
}
});

robot.on('issues.unlabeled', async context => {
const app = await getSupport(context);
const app = await getApp(context);
if (app) {
await app.unlabeled();
}
});

robot.on('issues.reopened', async context => {
const app = await getSupport(context);
const app = await getApp(context);
if (app) {
await app.reopened();
}
});

async function getSupport(context) {
async function getApp(context) {
const config = await getConfig(context);
if (config) {
return new Support(context, config, robot.log);
return new App(context, config, robot.log);
}
}

async function getConfig(context) {
const {owner, repo} = context.issue();
let config;
try {
let repoConfig = await context.config('support.yml');
let repoConfig = await getMergedConfig(context, 'support.yml');
if (!repoConfig) {
repoConfig = {perform: false};
}
Expand Down
13 changes: 13 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2022,6 +2022,13 @@ joi@^13.3.0:
isemail "3.x.x"
topo "3.x.x"

js-yaml@^3.10.0:
version "3.12.0"
resolved "https://registry.yarnpkg.com/js-yaml/-/js-yaml-3.12.0.tgz#eaed656ec8344f10f527c6bfa1b6e2244de167d1"
dependencies:
argparse "^1.0.7"
esprima "^4.0.0"

js-yaml@^3.6.1:
version "3.11.0"
resolved "https://registry.yarnpkg.com/js-yaml/-/js-yaml-3.11.0.tgz#597c1a8bd57152f26d622ce4117851a51f5ebaef"
Expand Down Expand Up @@ -3073,6 +3080,12 @@ prepend-http@^1.0.1:
version "1.0.4"
resolved "https://registry.yarnpkg.com/prepend-http/-/prepend-http-1.0.4.tgz#d4f4562b0ce3696e41ac52d0e002e57a635dc6dc"

probot-config@^0.1.0:
version "0.1.0"
resolved "https://registry.yarnpkg.com/probot-config/-/probot-config-0.1.0.tgz#b6ef11ccc468e7f28e06deb68b34e093b7c7e88e"
dependencies:
js-yaml "^3.10.0"

probot@^6.2.0:
version "6.2.0"
resolved "https://registry.yarnpkg.com/probot/-/probot-6.2.0.tgz#9c6d743dd172553db2bb687907cee11e9dc99b58"
Expand Down

0 comments on commit 6affa95

Please sign in to comment.