mirror of
https://github.com/renovatebot/renovate.git
synced 2025-01-12 15:06:27 +00:00
refactor: Refactor azure (#17858)
Co-authored-by: whitesource-for-github-com[bot] <50673670+whitesource-for-github-com[bot]@users.noreply.github.com> Co-authored-by: whitesource-for-github-com[bot] <whitesource-for-github-com[bot]@users.noreply.github.com>
This commit is contained in:
parent
6ee1a8d931
commit
5fd8c2bd8b
7 changed files with 23 additions and 28 deletions
|
@ -623,10 +623,7 @@ Elements in the `repositories` array can be an object if you wish to define addi
|
||||||
|
|
||||||
```js
|
```js
|
||||||
{
|
{
|
||||||
repositories: [
|
repositories: [{ repository: 'g/r1', bumpVersion: true }, 'g/r2'];
|
||||||
{ repository: 'g/r1', bumpVersion: true },
|
|
||||||
'g/r2'
|
|
||||||
],
|
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
|
@ -5,11 +5,11 @@ import {
|
||||||
} from 'azure-devops-node-api/interfaces/GitInterfaces.js';
|
} from 'azure-devops-node-api/interfaces/GitInterfaces.js';
|
||||||
import { logger } from '../../../logger';
|
import { logger } from '../../../logger';
|
||||||
import { streamToString } from '../../../util/streams';
|
import { streamToString } from '../../../util/streams';
|
||||||
|
import { getNewBranchName } from '../util';
|
||||||
import * as azureApi from './azure-got-wrapper';
|
import * as azureApi from './azure-got-wrapper';
|
||||||
import {
|
import {
|
||||||
getBranchNameWithoutRefsPrefix,
|
getBranchNameWithoutRefsPrefix,
|
||||||
getBranchNameWithoutRefsheadsPrefix,
|
getBranchNameWithoutRefsheadsPrefix,
|
||||||
getNewBranchName,
|
|
||||||
} from './util';
|
} from './util';
|
||||||
|
|
||||||
const mergePolicyGuid = 'fa4e907d-c16b-4a4c-9dfa-4916e5d171ab'; // Magic GUID for merge strategy policy configurations
|
const mergePolicyGuid = 'fa4e907d-c16b-4a4c-9dfa-4916e5d171ab'; // Magic GUID for merge strategy policy configurations
|
||||||
|
|
|
@ -40,7 +40,7 @@ import type {
|
||||||
RepoResult,
|
RepoResult,
|
||||||
UpdatePrConfig,
|
UpdatePrConfig,
|
||||||
} from '../types';
|
} from '../types';
|
||||||
import { repoFingerprint } from '../util';
|
import { getNewBranchName, repoFingerprint } from '../util';
|
||||||
import { smartTruncate } from '../utils/pr-body';
|
import { smartTruncate } from '../utils/pr-body';
|
||||||
import * as azureApi from './azure-got-wrapper';
|
import * as azureApi from './azure-got-wrapper';
|
||||||
import * as azureHelper from './azure-helper';
|
import * as azureHelper from './azure-helper';
|
||||||
|
@ -49,7 +49,6 @@ import {
|
||||||
getBranchNameWithoutRefsheadsPrefix,
|
getBranchNameWithoutRefsheadsPrefix,
|
||||||
getGitStatusContextCombinedName,
|
getGitStatusContextCombinedName,
|
||||||
getGitStatusContextFromCombinedName,
|
getGitStatusContextFromCombinedName,
|
||||||
getNewBranchName,
|
|
||||||
getProjectAndRepo,
|
getProjectAndRepo,
|
||||||
getRenovatePRFormat,
|
getRenovatePRFormat,
|
||||||
getRepoByName,
|
getRepoByName,
|
||||||
|
|
|
@ -4,7 +4,6 @@ import {
|
||||||
getBranchNameWithoutRefsheadsPrefix,
|
getBranchNameWithoutRefsheadsPrefix,
|
||||||
getGitStatusContextCombinedName,
|
getGitStatusContextCombinedName,
|
||||||
getGitStatusContextFromCombinedName,
|
getGitStatusContextFromCombinedName,
|
||||||
getNewBranchName,
|
|
||||||
getProjectAndRepo,
|
getProjectAndRepo,
|
||||||
getRenovatePRFormat,
|
getRenovatePRFormat,
|
||||||
getRepoByName,
|
getRepoByName,
|
||||||
|
@ -13,18 +12,6 @@ import {
|
||||||
} from './util';
|
} from './util';
|
||||||
|
|
||||||
describe('modules/platform/azure/util', () => {
|
describe('modules/platform/azure/util', () => {
|
||||||
describe('getNewBranchName', () => {
|
|
||||||
it('should add refs/heads', () => {
|
|
||||||
const res = getNewBranchName('testBB');
|
|
||||||
expect(res).toBe(`refs/heads/testBB`);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should be the same', () => {
|
|
||||||
const res = getNewBranchName('refs/heads/testBB');
|
|
||||||
expect(res).toBe(`refs/heads/testBB`);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('getGitStatusContextCombinedName', () => {
|
describe('getGitStatusContextCombinedName', () => {
|
||||||
it('should return undefined if null context passed', () => {
|
it('should return undefined if null context passed', () => {
|
||||||
const contextName = getGitStatusContextCombinedName(null);
|
const contextName = getGitStatusContextCombinedName(null);
|
||||||
|
|
|
@ -12,13 +12,6 @@ import { toBase64 } from '../../../util/string';
|
||||||
import { getPrBodyStruct } from '../pr-body';
|
import { getPrBodyStruct } from '../pr-body';
|
||||||
import type { AzurePr } from './types';
|
import type { AzurePr } from './types';
|
||||||
|
|
||||||
export function getNewBranchName(branchName?: string): string | undefined {
|
|
||||||
if (branchName && !branchName.startsWith('refs/heads/')) {
|
|
||||||
return `refs/heads/${branchName}`;
|
|
||||||
}
|
|
||||||
return branchName;
|
|
||||||
}
|
|
||||||
|
|
||||||
export function getGitStatusContextCombinedName(
|
export function getGitStatusContextCombinedName(
|
||||||
context: GitStatusContext | null | undefined
|
context: GitStatusContext | null | undefined
|
||||||
): string | undefined {
|
): string | undefined {
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import * as hostRules from '../../util/host-rules';
|
import * as hostRules from '../../util/host-rules';
|
||||||
import { repoFingerprint } from './util';
|
import { getNewBranchName, repoFingerprint } from './util';
|
||||||
|
|
||||||
describe('modules/platform/util', () => {
|
describe('modules/platform/util', () => {
|
||||||
beforeEach(() => hostRules.clear());
|
beforeEach(() => hostRules.clear());
|
||||||
|
@ -16,4 +16,16 @@ describe('modules/platform/util', () => {
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('getNewBranchName', () => {
|
||||||
|
it('should add refs/heads', () => {
|
||||||
|
const res = getNewBranchName('testBB');
|
||||||
|
expect(res).toBe(`refs/heads/testBB`);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should be the same', () => {
|
||||||
|
const res = getNewBranchName('refs/heads/testBB');
|
||||||
|
expect(res).toBe(`refs/heads/testBB`);
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -8,3 +8,10 @@ export function repoFingerprint(
|
||||||
const fingerprint = hasha(input);
|
const fingerprint = hasha(input);
|
||||||
return fingerprint;
|
return fingerprint;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function getNewBranchName(branchName?: string): string | undefined {
|
||||||
|
if (branchName && !branchName.startsWith('refs/heads/')) {
|
||||||
|
return `refs/heads/${branchName}`;
|
||||||
|
}
|
||||||
|
return branchName;
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue