Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't output table if no violations are specified #116

Merged
merged 5 commits into from
Jan 29, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
8 changes: 5 additions & 3 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@

// Add your own contribution below

* Builds which only use markdown now only show the markdown, and no violations table is shown - mxstbr

### 0.10.0

* Adds support for running Danger against a PR locally - orta

The workflow is that you find a PR that exhibits the behavior you'd like Danger to run against,
The workflow is that you find a PR that exhibits the behavior you'd like Danger to run against,
then edit the local `Dangerfile.js` and run `yarn run danger pr https://github.com/facebook/jest/pull/2629`.

This will post the results to your console, instead of on the PR itself.
Expand All @@ -19,8 +21,8 @@ This will post the results to your console, instead of on the PR itself.

* Adds support for `git.commits` and `git.luolix.topmits` - orta

Why two? Well git.luolix.topmits contains a bunch of github specific metadata ( e.g. GitHub user creds,
commit comment counts. ) Chances are, you're always going to use `git.commits` however if you
Why two? Well git.luolix.topmits contains a bunch of github specific metadata ( e.g. GitHub user creds,
commit comment counts. ) Chances are, you're always going to use `git.commits` however if you
want more rich data, the GitHub one is available too. Here's an example:

```js
Expand Down
9 changes: 8 additions & 1 deletion source/runner/_tests/fixtures/ExampleDangerResults.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,13 @@ export const emptyResults: DangerResults = {
markdowns: []
}

export const failsResultsWithoutMessages: DangerResults = {
fails: [{}, {}],
warnings: [],
messages: [],
markdowns: []
}

export const warnResults: DangerResults = {
fails: [],
warnings: [{ message: "Warning message" }],
Expand All @@ -26,4 +33,4 @@ export const summaryResults: DangerResults = {
warnings: [{ message: "Warning message Warning message" }],
messages: [{ message: "message" }],
markdowns: ["markdown"],
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { emptyResults, warnResults, failsResults, summaryResults } from "../../_tests/fixtures/ExampleDangerResults"
import { emptyResults, failsResultsWithoutMessages, warnResults, failsResults, summaryResults } from "../../_tests/fixtures/ExampleDangerResults"
import { template as githubResultsTemplate } from "../../templates/github-issue-template"

describe("generating messages", () => {
Expand All @@ -9,6 +9,13 @@ describe("generating messages", () => {
expect(issues).not.toContain("Messages")
})

it("shows no tables for results without messages", () => {
const issues = githubResultsTemplate(failsResultsWithoutMessages)
expect(issues).not.toContain("Fails")
expect(issues).not.toContain("Warnings")
expect(issues).not.toContain("Messages")
})

it("Shows the failing messages in a table", () => {
const issues = githubResultsTemplate(failsResults)
expect(issues).toContain("Fails")
Expand Down
2 changes: 1 addition & 1 deletion source/runner/templates/github-issue-template.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import * as v from "voca"
* @returns {string} HTML
*/
function table(name: string, emoji: string, violations: Array<Violation>): string {
if (violations.length === 0) { return "" }
if (violations.length === 0 || violations.every(violation => !violation.message)) { return "" }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cool, the every function is new to me

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I've only known it for a few weeks! (there's also some FYI)

return `
<table>
<thead>
Expand Down