Skip to content

Commit

Permalink
fix(1689): Change the getFile url to use Bitbucket API 2.0 (#62)
Browse files Browse the repository at this point in the history
  • Loading branch information
xangxiong authored and jithine committed Jun 27, 2019
1 parent a553e7a commit 1204b66
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 4 deletions.
3 changes: 1 addition & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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`;
Expand Down Expand Up @@ -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',
Expand Down
3 changes: 1 addition & 2 deletions test/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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: '' });
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit 1204b66

Please sign in to comment.