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

Adapt emoji for Bitbucket server to fix "Database error has occurred" #645

Merged
merged 5 commits into from Aug 1, 2018
Merged
Diff settings

Always

Just for now

Copy path View file
@@ -13,6 +13,11 @@

## Master

# 3.8.3

This comment has been minimized.

Copy link
@orta

orta Aug 1, 2018

Member

Adding this means likely merge conflicts, best to leave them next time - I normally add this version when I create the new release. I should make a danger rule for that 👍

This comment has been minimized.

Copy link
@acecilia

acecilia Aug 1, 2018

Author Member

I can avoid adding changelog for the next PR. Do you prefer that? Or just add the changelog without specifying the version?


- Adapt emoji for Bitbucket server to fix "Database error has occurred"
[645](https://github.com/danger/danger-js/pull/645) - [@acecilia](https://github.com/acecilia)

# 3.8.2

- Use the Peril Bot ID for the comment lookup checks - [@orta][]
@@ -789,12 +794,12 @@ If these files are supposed to not exist, please update your PR body to include

```js
// In danger 0.16.0:
const fullDiff = danger.git.diffForFile('foo.js')
const addedLines = danger.git.diffForFile('foo.js', ['add'])
const removedLines = danger.git.diffForFile('foo.js', ['del'])
const fullDiff = danger.git.diffForFile("foo.js")

This comment has been minimized.

Copy link
@acecilia

acecilia Aug 1, 2018

Author Member

I did not add this changes, I think the hooks that the project has are causing this.

This comment has been minimized.

Copy link
@orta

orta Aug 1, 2018

Member

cool 👍

const addedLines = danger.git.diffForFile("foo.js", ["add"])
const removedLines = danger.git.diffForFile("foo.js", ["del"])
// In the latest version:
const diff = await danger.git.diffForFile('foo.js')
const diff = await danger.git.diffForFile("foo.js")
const fullDiff = diff.diff
const addedLines = diff.added
const removedLines = diff.removed
@@ -876,10 +881,10 @@ If these files are supposed to not exist, please update your PR body to include
if (packageDiff.dependencies) {
const deps = packageDiff.dependencies
deps.added // ["chalk"],
deps.added // ["chalk"],
deps.removed // []
deps.after // { "babel-polyfill": "^6.20.0", "chalk": "^1.1.1", "commander": "^2.9.0", "debug": "^2.6.0" }
deps.before // { "babel-polyfill": "^6.20.0", "commander": "^2.9.0", "debug": "^2.6.0" }
deps.after // { "babel-polyfill": "^6.20.0", "chalk": "^1.1.1", "commander": "^2.9.0", "debug": "^2.6.0" }
deps.before // { "babel-polyfill": "^6.20.0", "commander": "^2.9.0", "debug": "^2.6.0" }
}
```

Copy path View file
@@ -19,10 +19,12 @@ import {
template as githubResultsTemplate,
inlineTemplate as githubResultsInlineTemplate,
fileLineToString,
messageForResultWithIssues as githubMessageForResultWithIssues,
} from "./templates/githubIssueTemplate"
import {
template as bitbucketServerTemplate,
inlineTemplate as bitbucketServerInlineTemplate,
messageForResultWithIssues as bitbucketMessageForResultWithIssues,
} from "./templates/bitbucketServerTemplate"
import exceptionRaisedTemplate from "./templates/exceptionRaisedTemplate"

@@ -387,6 +389,8 @@ const messageForResults = (results: DangerResults) => {
if (!results.fails.length && !results.warnings.length) {
return `All green. ${compliment()}`
} else {
return "⚠️ Danger found some issues. Don't worry, everything is fixable."
return process.env["DANGER_BITBUCKETSERVER_HOST"]
? bitbucketMessageForResultWithIssues
: githubMessageForResultWithIssues
}
}
@@ -281,7 +281,7 @@ describe("setup", () => {
await exec.handleResults(warnResults, dsl.git)
expect(platform.updateStatus).toBeCalledWith(
true,
"⚠️ Danger found some issues. Don't worry, everything is fixable.",
":warning: Danger found some issues. Don't worry, everything is fixable.",
undefined
)
})
@@ -296,7 +296,7 @@ describe("setup", () => {
await exec.handleResults(failsResults, dsl.git)
expect(platform.updateStatus).toBeCalledWith(
false,
"⚠️ Danger found some issues. Don't worry, everything is fixable.",
":warning: Danger found some issues. Don't worry, everything is fixable.",
undefined
)
})
@@ -3,7 +3,7 @@
exports[`generating messages for BitBucket server summary result matches snapshot 1`] = `
"

| 🚫 | Fails
| | Fails
| --- | --- |

> Failing message Failing message
@@ -15,7 +15,7 @@ exports[`generating messages for BitBucket server summary result matches snapsho
> Warning message Warning message


| 📖 | Messages
| | Messages
| --- | --- |

> message
@@ -26,7 +26,7 @@ markdown

| |
|---:|
| _Generated by 🚫 [dangerJS](http://github.com/danger/danger-js/)_ |
| _Generated by [dangerJS](http://github.com/danger/danger-js/)_ |


[](http://danger-id-blankID;)
@@ -9,6 +9,10 @@ import {
} from "../../_tests/fixtures/ExampleDangerResults"
import { template, inlineTemplate } from "../bitbucketServerTemplate"

const noEntryEmoji = "\u274C"
const warningEmoji = "⚠️"
const messageEmoji = "\u2728"

describe("generating messages for BitBucket server", () => {
it("shows no sections for empty results", () => {
const issues = template("blankID", emptyResults)
@@ -44,23 +48,23 @@ describe("generating messages for BitBucket server", () => {
describe("generating inline messages", () => {
it("Shows the failing message", () => {
const issues = inlineTemplate("blankID", failsResults, "File.swift", 5)
expect(issues).toContain("- 🚫 Failing message")
expect(issues).not.toContain("- ⚠️")
expect(issues).not.toContain("- 📖")
expect(issues).toContain(`- ${noEntryEmoji} Failing message`)
expect(issues).not.toContain(`- ${warningEmoji}`)
expect(issues).not.toContain(`- ${messageEmoji}`)
})

it("Shows the warning message", () => {
const issues = inlineTemplate("blankID", warnResults, "File.swift", 5)
expect(issues).toContain("- ⚠️ Warning message")
expect(issues).not.toContain("- 🚫")
expect(issues).not.toContain("- 📖")
expect(issues).toContain(`- ${warningEmoji} Warning message`)
expect(issues).not.toContain(`- ${noEntryEmoji}`)
expect(issues).not.toContain(`- ${messageEmoji}`)
})

it("Shows the message", () => {
const issues = inlineTemplate("blankID", messagesResults, "File.swift", 5)
expect(issues).toContain("- 📖 Message")
expect(issues).not.toContain("- 🚫")
expect(issues).not.toContain("- ⚠️")
expect(issues).toContain(`- ${messageEmoji} Message`)
expect(issues).not.toContain(`- ${noEntryEmoji}`)
expect(issues).not.toContain(`- ${warningEmoji}`)
})

it("Shows markdowns one after another", () => {
@@ -1,6 +1,11 @@
import { DangerResults } from "../../dsl/DangerResults"
import { Violation } from "../../dsl/Violation"

// This unicode emojis also work for old versions of bitbucket server, were emojis are not supported
const noEntryEmoji = "\u274C"
const warningEmoji = "⚠️"
const messageEmoji = "\u2728"

/**
* Converts a set of violations into a Markdown section
*
@@ -42,8 +47,12 @@ export const fileLineToString = (file: string, line: number) => ` File: ${file}
export const dangerSignaturePostfix = `
| |
|---:|
| _Generated by 🚫 [dangerJS](http://github.com/danger/danger-js/)_ |
| _Generated by ${noEntryEmoji} [dangerJS](http://github.com/danger/danger-js/)_ |
`
/**
* Comment to add when updating the PR status when issues are found
*/
export const messageForResultWithIssues = `${warningEmoji} Danger found some issues. Don't worry, everything is fixable.`

/**
* A template function for creating a GitHub issue comment from Danger Results
@@ -53,9 +62,9 @@ export const dangerSignaturePostfix = `
*/
export function template(dangerID: string, results: DangerResults): string {
return `
${resultsSection("Fails", "🚫", results.fails)}
${resultsSection("Warnings", "⚠️", results.warnings)}
${resultsSection("Messages", "📖", results.messages)}
${resultsSection("Fails", noEntryEmoji, results.fails)}
${resultsSection("Warnings", warningEmoji, results.warnings)}
${resultsSection("Messages", messageEmoji, results.messages)}
${results.markdowns.map(v => v.message).join("\n\n")}
@@ -73,9 +82,9 @@ export function inlineTemplate(dangerID: string, results: DangerResults, file: s
return `
[//]: # (${dangerIDToString(dangerID)})
[//]: # (${fileLineToString(file, line)})
${results.fails.map(printViolation("🚫")).join("\n")}
${results.warnings.map(printViolation("⚠️")).join("\n")}
${results.messages.map(printViolation("📖")).join("\n")}
${results.fails.map(printViolation(noEntryEmoji)).join("\n")}
${results.warnings.map(printViolation(warningEmoji)).join("\n")}
${results.messages.map(printViolation(messageEmoji)).join("\n")}

This comment has been minimized.

Copy link
@orta

orta Aug 1, 2018

Member

Yep - this all makes sense 👍

${results.markdowns.map(v => v.message).join("\n\n")}
`
}
@@ -68,6 +68,11 @@ export const fileLineToString = (file: string, line: number) => ` File: ${file}
*/
export const dangerSignaturePostfix = `Generated by :no_entry_sign: <a href="http://github.com/danger/danger-js/">dangerJS</a>`

/**
* Comment to add when updating the PR status when issues are found
*/
export const messageForResultWithIssues = `:warning: Danger found some issues. Don't worry, everything is fixable.`

/**
* A template function for creating a GitHub issue comment from Danger Results
* @param {string} dangerID A string that represents a unique build
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.