Skip to content
Snippets Groups Projects
Commit 5306e6bd authored by Michael Kriese's avatar Michael Kriese Committed by Rhys Arkins
Browse files

fix(bitbucket-server): fix race condition (#3592)

parent 30fd1777
No related branches found
Tags 32.42.0
No related merge requests found
const url = require('url'); const url = require('url');
const delay = require('delay');
const api = require('./bb-got-wrapper'); const api = require('./bb-got-wrapper');
const utils = require('./utils'); const utils = require('./utils');
...@@ -240,6 +241,8 @@ async function commitFilesToBranch( ...@@ -240,6 +241,8 @@ async function commitFilesToBranch(
parentBranch parentBranch
); );
// wait for pr change propagation
await delay(1000);
// refresh cache // refresh cache
await getBranchPr(branchName, true); await getBranchPr(branchName, true);
} }
...@@ -696,6 +699,7 @@ async function getPr(prNo, refreshCache) { ...@@ -696,6 +699,7 @@ async function getPr(prNo, refreshCache) {
if (!prNo) { if (!prNo) {
return null; return null;
} }
const res = await api.get( const res = await api.get(
`./rest/api/1.0/projects/${config.projectKey}/repos/${ `./rest/api/1.0/projects/${config.projectKey}/repos/${
config.repositorySlug config.repositorySlug
......
...@@ -13,6 +13,7 @@ describe('platform/bitbucket-server', () => { ...@@ -13,6 +13,7 @@ describe('platform/bitbucket-server', () => {
beforeEach(() => { beforeEach(() => {
// reset module // reset module
jest.resetModules(); jest.resetModules();
jest.mock('delay');
jest.mock('got', () => (url, options) => { jest.mock('got', () => (url, options) => {
const { method } = options; const { method } = options;
const body = mockResponses[url] && mockResponses[url][method]; const body = mockResponses[url] && mockResponses[url][method];
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment