-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Includes performance improvements to the backend request queue and fixes to configuration consumption.
- Loading branch information
1 parent
219d354
commit 5d1411a
Showing
17 changed files
with
514 additions
and
207 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 |
---|---|---|
@@ -1,20 +1,34 @@ | ||
### 0.0.1 | ||
|
||
First release as migration of [Checkee](https://github.com/kurtwagner/checkee) | ||
tool for commenting on pull requests from linter results. | ||
|
||
### 0.0.2 | ||
### 0.0.5 | ||
|
||
**Fixes** | ||
**Improvement** | ||
- Support parallel requests in backend package, this should result in faster turnarounds when the requests are known up front. Requests that page through are yet to be optimised to look ahead. | ||
|
||
- Fixes #4 - Can't read attribute "username" on `null` when comparing existing `deleted` comment. | ||
**Fix** | ||
- Non-relative configuration and credentials paths were not being resolved correctly. | ||
- `.bitbucket-toolbox.js` configuration was not being picked up. | ||
|
||
**Feature** | ||
- New `scripts` action where you can perform and respond to certain events. For now this only supports the "openPullRequests" type. This will load all open pull requests (including changed chunks). | ||
|
||
### 0.0.4 | ||
|
||
**Fix** | ||
- Fix - `chalk` should be a production dependency. | ||
|
||
### 0.0.3 | ||
|
||
**Enhancement** | ||
- Resolves #1 - Introduces `--fail-on-severity` option to the `comments` action. | ||
|
||
### 0.0.4 | ||
### 0.0.2 | ||
|
||
**Fix** | ||
- Fix - `chalk` should be a production dependency. | ||
**Fixes** | ||
|
||
- Fixes #4 - Can't read attribute "username" on `null` when comparing existing `deleted` comment. | ||
|
||
### 0.0.1 | ||
|
||
First release as migration of [Checkee](https://github.com/kurtwagner/checkee) | ||
tool for commenting on pull requests from linter results. |
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
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 |
---|---|---|
|
@@ -2,4 +2,5 @@ | |
|
||
module.exports = { | ||
ACTION_COMMENTS: 'comments', | ||
}; | ||
ACTION_SCRIPT: 'run', | ||
}; |
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
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,84 @@ | ||
'use strict'; | ||
|
||
const Q = require('q'); | ||
|
||
const { highlightText } = require('../colors'); | ||
const logger = require('../logger'); | ||
const { BitbucketClient } = require('../bitbucket'); | ||
const { ACTION_SCRIPT } = require('./constants'); | ||
|
||
const SCRIPT_TYPES = { | ||
openPullRequests: openPullRequests, | ||
}; | ||
|
||
module.exports = { | ||
executeScriptAction, | ||
}; | ||
|
||
function executeScriptAction(actionDetails) { | ||
const { argv, config } = actionDetails; | ||
const { scriptRunner, scriptConfig } = getAndVerifyScript({ argv, config }); | ||
|
||
return scriptRunner(actionDetails).then(result => { | ||
return Q(scriptConfig.resolve(result)); | ||
}); | ||
} | ||
|
||
function getAndVerifyScript({ config, argv }) { | ||
if (!config.scripts) { | ||
throw new Error(`Missing "scripts" in configuration file.`); | ||
} | ||
|
||
const scriptName = argv[argv.findIndex(arg => arg === ACTION_SCRIPT) + 1]; | ||
if (!scriptName) { | ||
throw new Error(`Missing script name. e.g, "bitbucket-toolbox ${ACTION_SCRIPT} <scriptName>"`); | ||
} | ||
|
||
const scriptConfig = config.scripts[scriptName]; | ||
if (!scriptConfig) { | ||
throw new Error(`No script configuration for ${highlightText(scriptName)}`); | ||
} | ||
if (!scriptConfig.type) { | ||
throw new Error(`Script ${highlightText(scriptName)} is missing a "type". ${getAvailableScriptTypesText()}`); | ||
} | ||
if (!scriptConfig.resolve) { | ||
throw new Error(`Script ${highlightText(scriptName)} is missing a "resolve" function.`); | ||
} | ||
|
||
const scriptRunner = SCRIPT_TYPES[scriptConfig.type]; | ||
if (!scriptRunner) { | ||
throw new Error( | ||
`Script ${highlightText(scriptName)} has an unknown type ${highlightText( | ||
scriptConfig.type | ||
)}. ${getAvailableScriptTypesText()}` | ||
); | ||
} | ||
|
||
return { scriptConfig, scriptRunner }; | ||
} | ||
|
||
function openPullRequests({ args, config, credentials }) { | ||
const { repoUser = config.bitbucket.repoUser, repoSlug = config.bitbucket.repoSlug } = args; | ||
|
||
if (!repoSlug || !repoUser) { | ||
throw new Error('Missing required repo slug and repo user'); | ||
} | ||
|
||
const client = new BitbucketClient({ | ||
username: credentials.bitbucket.username, | ||
password: credentials.bitbucket.password, | ||
}); | ||
|
||
logger.step(1, 2, `Loading open pull requests`); | ||
return client | ||
.repository(repoUser, repoSlug) | ||
.pullRequests() | ||
.then(pullRequests => { | ||
logger.step(2, 2, `Resolving script`); | ||
return { pullRequests }; | ||
}); | ||
} | ||
|
||
function getAvailableScriptTypesText() { | ||
return `Valid types: ${Object.keys(SCRIPT_TYPES).join(', ')}`; | ||
} |
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
Oops, something went wrong.