From 1204b6649c1a4385497d36f075baa4d17f9bf010 Mon Sep 17 00:00:00 2001 From: Xang Xiong Date: Thu, 27 Jun 2019 09:22:48 -0700 Subject: [PATCH] fix(1689): Change the getFile url to use Bitbucket API 2.0 (#62) --- index.js | 3 +-- test/index.test.js | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/index.js b/index.js index d717264..b42a6ed 100644 --- a/index.js +++ b/index.js @@ -9,7 +9,6 @@ const joi = require('joi'); const url = require('url'); const request = require('request'); const schema = require('screwdriver-data-schema'); -const API_URL_V1 = 'https://api.bitbucket.org/1.0'; const API_URL_V2 = 'https://api.bitbucket.org/2.0'; const REPO_URL = `${API_URL_V2}/repositories`; const USER_URL = `${API_URL_V2}/users`; @@ -523,7 +522,7 @@ class BitbucketScm extends Scm { _getFile(config) { const scm = getScmUriParts(config.scmUri); const branch = config.ref || scm.branch; - const fileUrl = `${API_URL_V1}/repositories/${scm.repoId}/src/${branch}/${config.path}`; + const fileUrl = `${API_URL_V2}/repositories/${scm.repoId}/src/${branch}/${config.path}`; const options = { url: fileUrl, method: 'GET', diff --git a/test/index.test.js b/test/index.test.js index 791f978..337d4a1 100644 --- a/test/index.test.js +++ b/test/index.test.js @@ -13,7 +13,6 @@ const testPayloadSync = require('./data/pr.sync.json'); const testPayloadClose = require('./data/pr.closed.json'); const testPayloadPush = require('./data/repo.push.json'); const token = 'myAccessToken'; -const API_URL_V1 = 'https://api.bitbucket.org/1.0'; const API_URL_V2 = 'https://api.bitbucket.org/2.0'; sinon.assert.expose(assert, { prefix: '' }); @@ -816,7 +815,7 @@ describe('index', function () { }); describe('getFile', () => { - const apiUrl = `${API_URL_V1}/repositories/repoId/src/branchName/path/to/file.txt`; + const apiUrl = `${API_URL_V2}/repositories/repoId/src/branchName/path/to/file.txt`; const scmUri = 'hostName:repoId:branchName'; const params = { scmUri,