Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/danger/danger-js
Browse files Browse the repository at this point in the history
  • Loading branch information
orta committed May 7, 2020
2 parents 69cac62 + 0897c6c commit 4ba6cce
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 15 deletions.
29 changes: 20 additions & 9 deletions .github/workflows/uploadDockerImage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,28 @@ name: Upload tag to GitHub
on:
push:
tags:
- "*"
- '*'

jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@master
- name: Publish to Registry
uses: elgohr/Publish-Docker-Github-Action@master
with:
name: docker.pkg.github.com/danger/danger-js/release
username: ${{ secrets.DOCKER_GITHUB_USERNAME }}
password: ${{ secrets.DOCKER_GITHUB_PASSWORD }}
registry: docker.pkg.github.com
- uses: actions/checkout@v2

- name: Export tag version
run: echo ::set-env name=VERSION::${GITHUB_REF/refs\/tags\//}

- name: Docker Login
run: echo $PACKAGES_WRITE_TOKEN | docker login docker.pkg.github.com -u $USERNAME --password-stdin
env:
PACKAGES_WRITE_TOKEN: ${{ secrets.DOCKER_GITHUB_PASSWORD }}
USERNAME: ${{ secrets.DOCKER_GITHUB_USERNAME }}
- name: Docker Build
run: docker build -t docker.pkg.github.com/danger/danger-js/danger-danger-js:$VERSION .
env:
USERNAME: ${{ secrets.DOCKER_GITHUB_USERNAME }}
- name: Deploy
run: docker push docker.pkg.github.com/danger/danger-js/danger-danger-js:$VERSION
env:
USERNAME: ${{ secrets.DOCKER_GITHUB_USERNAME }}
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ x

<!-- Your comment below this -->

- Fix danger failure on getting diff for files with spaces in file path [@HonzaMac]

<!-- Your comment above this -->

# 10.2.0
Expand Down
6 changes: 4 additions & 2 deletions source/platforms/bitbucket_server/BitBucketServerAPI.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,9 @@ export class BitBucketServerAPI implements BitBucketServerAPIDSL {

getStructuredDiffForFile = async (base: string, head: string, filename: string): Promise<BitBucketServerDiff[]> => {
const { repoSlug } = this.repoMetadata
const path = `rest/api/1.0/${repoSlug}/compare/diff/${filename}?withComments=false&from=${head}&to=${base}`
const path = `rest/api/1.0/${repoSlug}/compare/diff/${encodeURI(
filename
)}?withComments=false&from=${head}&to=${base}`
const res = await this.get(path)
throwIfNotOk(res)
return (await res.json()).diffs
Expand Down Expand Up @@ -241,7 +243,7 @@ export class BitBucketServerAPI implements BitBucketServerAPIDSL {

// The last two are "optional" in the protocol, but not really optional WRT the BBSAPI
getFileContents = async (filePath: string, repoSlug?: string, refspec?: string) => {
const path = `rest/api/1.0/${repoSlug}/` + `raw/${filePath}` + `?at=${refspec}`
const path = `rest/api/1.0/${repoSlug}/` + `raw/${encodeURI(filePath)}` + `?at=${refspec}`
const res = await this.get(path, undefined, true)
if (res.status === 404) {
return ""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,11 @@ describe("API testing - BitBucket Server", () => {

it("getStructuredDiffForFile", async () => {
jsonResult = () => ({ diffs: ["diff"] })
const result = await api.getStructuredDiffForFile("BASE", "HEAD", "filename.txt")
const result = await api.getStructuredDiffForFile("BASE", "HEAD", "path with space/filename.txt")

expect(api.fetch).toHaveBeenCalledWith(
`${host}/rest/api/1.0/projects/FOO/repos/BAR/compare/diff/` +
`filename.txt` +
`path%20with%20space/filename.txt` +
`?withComments=false&from=HEAD&to=BASE`,
{ method: "GET", body: null, headers: expectedJSONHeaders },
undefined
Expand Down Expand Up @@ -272,10 +272,10 @@ describe("API testing - BitBucket Server", () => {

it("getFileContents", async () => {
textResult = "contents..."
const result = await api.getFileContents("path/to/foo.txt", "projects/FOO/repos/BAR", "master")
const result = await api.getFileContents("path/folder with space/foo.txt", "projects/FOO/repos/BAR", "master")

expect(api.fetch).toHaveBeenCalledWith(
`${host}/rest/api/1.0/projects/FOO/repos/BAR/raw/path/to/foo.txt?at=master`,
`${host}/rest/api/1.0/projects/FOO/repos/BAR/raw/path/folder%20with%20space/foo.txt?at=master`,
{ method: "GET", body: null, headers: expectedJSONHeaders },
true
)
Expand Down

0 comments on commit 4ba6cce

Please sign in to comment.