Skip to content

Commit

Permalink
Apply prettier cleanups
Browse files Browse the repository at this point in the history
  • Loading branch information
toolmantim committed Dec 20, 2018
1 parent 8c709a4 commit 81a4604
Show file tree
Hide file tree
Showing 8 changed files with 369 additions and 184 deletions.
20 changes: 10 additions & 10 deletions CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,19 @@ In the interest of fostering an open and welcoming environment, we as contributo

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
- 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
- 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

Expand Down
48 changes: 24 additions & 24 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,35 +36,35 @@ As pull requests are merged, a draft release is kept up-to-date listing the chan
You can configure Release Drafter using the following key in your `.github/release-drafter.yml` file:

|Key|Required|Description|
|-|-|-|
|`template`|Required|The template for the body of the draft release. Use [template variables](#template-variables) to insert values.|
|`change-template`|Optional|The template to use for each merged pull request. Use [change template variables](#change-template-variables) to insert values. Default: `* $TITLE (#$NUMBER) @$AUTHOR`|
|`no-changes-template`|Optional|The template to use for when there’s no changes. Default: `* No changes`|
|`branches`|Optional|The branches to listen for configuration updates to `.github/release-drafter.yml` and for merge commits. Useful if you want to test the app on a pull request branch. Default is the repository’s default branch.|
|`categories`|Optional|Categorize pull requests using labels. Refer to [Categorize Pull Requests](#categorize-pull-requests) to learn more about this option.|
| Key | Required | Description |
| --------------------- | -------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `template` | Required | The template for the body of the draft release. Use [template variables](#template-variables) to insert values. |
| `change-template` | Optional | The template to use for each merged pull request. Use [change template variables](#change-template-variables) to insert values. Default: `* $TITLE (#$NUMBER) @$AUTHOR` |
| `no-changes-template` | Optional | The template to use for when there’s no changes. Default: `* No changes` |
| `branches` | Optional | The branches to listen for configuration updates to `.github/release-drafter.yml` and for merge commits. Useful if you want to test the app on a pull request branch. Default is the repository’s default branch. |
| `categories` | Optional | Categorize pull requests using labels. Refer to [Categorize Pull Requests](#categorize-pull-requests) to learn more about this option. |

Release Drafter also supports [Probot Config](https://github.com/probot/probot-config), if you want to store your configuration files in a central repository. This allows you to share configurations between projects, and create a organization-wide configuration file by creating a repository named `.github` and file named `release-drafter.yml`.

## Template variables

You can use any of the following variables in your `template`:

|Variable|Description|
|-|-|
|`$CHANGES`|The markdown list of pull requests that have been merged.|
|`$CONTRIBUTORS`|A comma separated list of contributors to this release (pull request authors, commit authors, and commit committers).|
|`$PREVIOUS_TAG`|The previous releases’s tag.|
| Variable | Description |
| --------------- | --------------------------------------------------------------------------------------------------------------------- |
| `$CHANGES` | The markdown list of pull requests that have been merged. |
| `$CONTRIBUTORS` | A comma separated list of contributors to this release (pull request authors, commit authors, and commit committers). |
| `$PREVIOUS_TAG` | The previous releases’s tag. |

## Change Template variables

You can use any of the following variables in `change-template`:

|Variable|Description|
|-|-|
|`$NUMBER`|The number of the pull request, e.g. `42`|
|`$TITLE`|The title of the pull request, e.g. `Add alien technology`|
|`$AUTHOR`|The pull request author’s username, e.g. `gracehopper`|
| Variable | Description |
| --------- | ---------------------------------------------------------- |
| `$NUMBER` | The number of the pull request, e.g. `42` |
| `$TITLE` | The title of the pull request, e.g. `Add alien technology` |
| `$AUTHOR` | The pull request author’s username, e.g. `gracehopper` |

## Categorize Pull Requests

Expand Down Expand Up @@ -130,10 +130,10 @@ git checkout master && git pull && npm version [major | minor | patch]

The command does the following:

* Ensures you’re on master and don’t have local, un-commited changes
* Bumps the version number in [package.json](package.json) based on major, minor or patch
* Runs the `postversion` npm script in [package.json](package.json), which:
* Pushes the tag to GitHub
* Publishes the npm release
* Deploys to [Now](https://now.sh)
* Opens the GitHub releases page so you can publish the release notes
- Ensures you’re on master and don’t have local, un-commited changes
- Bumps the version number in [package.json](package.json) based on major, minor or patch
- Runs the `postversion` npm script in [package.json](package.json), which:
- Pushes the tag to GitHub
- Publishes the npm release
- Deploys to [Now](https://now.sh)
- Opens the GitHub releases page so you can publish the release notes
2 changes: 1 addition & 1 deletion lib/base64.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module.exports.encodeContent = (content) => {
module.exports.encodeContent = content => {
return Buffer.from(content).toString('base64')
}
68 changes: 45 additions & 23 deletions lib/commits.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,38 +2,53 @@ const log = require('./log')

module.exports.findCommits = async ({ app, context, branch, lastRelease }) => {
if (lastRelease) {
log({ app, context, message: `Comparing commits ${lastRelease.tag_name}..${branch}` })
log({
app,
context,
message: `Comparing commits ${lastRelease.tag_name}..${branch}`
})
// Only supports up to 250 commits
return context.github.repos.compareCommits(context.repo({
base: lastRelease.tag_name,
head: branch
})).then(res => res.data.commits)
return context.github.repos
.compareCommits(
context.repo({
base: lastRelease.tag_name,
head: branch
})
)
.then(res => res.data.commits)
} else {
log({ app, context, message: `Fetching all commits for branch ${branch}` })
return context.github.paginate(
context.github.repos.getCommits(context.repo({
sha: branch,
per_page: 100
})),
context.github.repos.getCommits(
context.repo({
sha: branch,
per_page: 100
})
),
res => res.data
)
}
}

module.exports.extractPullRequestNumber = (commit) => {
module.exports.extractPullRequestNumber = commit => {
// There are two types of GitHub pull request merges, normal and squashed.
// Normal ones look like 'Merge pull request #123'
// Squashed ones have multiple lines, first one looks like 'Some changes (#123)'
const match = commit.commit.message.split('\n')[0].match(/\(#(\d+)\)$|^Merge pull request #(\d+)/)
const match = commit.commit.message
.split('\n')[0]
.match(/\(#(\d+)\)$|^Merge pull request #(\d+)/)
return match && (match[1] || match[2])
}

const findPullRequest = ({ context, number }) => {
return context.github.pullRequests.get(context.repo({ number: number }))
.then(res => res.data)
// We ignore any problems, in case the PR number pulled out of the commits
// are bonkers
.catch(() => false)
return (
context.github.pullRequests
.get(context.repo({ number: number }))
.then(res => res.data)
// We ignore any problems, in case the PR number pulled out of the commits
// are bonkers
.catch(() => false)
)
}

module.exports.findPullRequests = ({ app, context, commits }) => {
Expand All @@ -45,13 +60,20 @@ module.exports.findPullRequests = ({ app, context, commits }) => {
.map(module.exports.extractPullRequestNumber)
.filter(number => number)

log({ app, context, message: `Found pull request numbers: ${pullRequestNumbers.join(', ')}` })
log({
app,
context,
message: `Found pull request numbers: ${pullRequestNumbers.join(', ')}`
})

const pullRequestPromises = pullRequestNumbers
.map(number => findPullRequest({ context, number }))
const pullRequestPromises = pullRequestNumbers.map(number =>
findPullRequest({ context, number })
)

return Promise.all(pullRequestPromises)
// Filter out PR lookups that failed
.then(prs => prs.filter(pr => pr))
.catch(() => [])
return (
Promise.all(pullRequestPromises)
// Filter out PR lookups that failed
.then(prs => prs.filter(pr => pr))
.catch(() => [])
)
}
Loading

0 comments on commit 81a4604

Please sign in to comment.