backport 8.2.0 → 8.3.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/backportRun.js +5 -1
- package/dist/entrypoint.module.private.test.js +21 -0
- package/dist/lib/github/v4/validateTargetBranches.d.ts +2 -7
- package/dist/lib/github/v4/validateTargetBranches.js +1 -1
- package/dist/lib/github/v4/validateTargetBranches.private.test.js +8 -8
- package/dist/options/options.js +0 -4
- package/dist/utils/packageVersion.d.ts +1 -1
- package/dist/utils/packageVersion.js +1 -1
- package/package.json +1 -1
package/dist/backportRun.js
CHANGED
|
@@ -11,6 +11,7 @@ const getCommits_1 = require("./lib/getCommits");
|
|
|
11
11
|
const getTargetBranches_1 = require("./lib/getTargetBranches");
|
|
12
12
|
const createStatusComment_1 = require("./lib/github/v3/createStatusComment");
|
|
13
13
|
const apiRequestV4_1 = require("./lib/github/v4/apiRequestV4");
|
|
14
|
+
const validateTargetBranches_1 = require("./lib/github/v4/validateTargetBranches");
|
|
14
15
|
const logger_1 = require("./lib/logger");
|
|
15
16
|
const ora_1 = require("./lib/ora");
|
|
16
17
|
const setupRepo_1 = require("./lib/setupRepo");
|
|
@@ -51,7 +52,10 @@ async function backportRun({ processArgs, optionsFromModule = {}, exitCodeOnFail
|
|
|
51
52
|
}
|
|
52
53
|
const targetBranches = await (0, getTargetBranches_1.getTargetBranches)(options, commits);
|
|
53
54
|
logger.info('Target branches', targetBranches);
|
|
54
|
-
await
|
|
55
|
+
await Promise.all([
|
|
56
|
+
(0, setupRepo_1.setupRepo)(options),
|
|
57
|
+
(0, validateTargetBranches_1.validateTargetBranches)(options, targetBranches),
|
|
58
|
+
]);
|
|
55
59
|
const results = await (0, runSequentially_1.runSequentially)({
|
|
56
60
|
options,
|
|
57
61
|
commits,
|
|
@@ -40,6 +40,27 @@ describe('entrypoint.module', () => {
|
|
|
40
40
|
expect(response.results[0].error.errorContext.conflictingFiles).toEqual(['la-liga.md']);
|
|
41
41
|
});
|
|
42
42
|
});
|
|
43
|
+
describe('when target branch in branchLabelMapping is invalid', () => {
|
|
44
|
+
let response;
|
|
45
|
+
beforeAll(async () => {
|
|
46
|
+
response = (await (0, entrypoint_module_1.backportRun)({
|
|
47
|
+
options: {
|
|
48
|
+
accessToken,
|
|
49
|
+
branchLabelMapping: {
|
|
50
|
+
[`^backport-to-(.+)$`]: '$1',
|
|
51
|
+
},
|
|
52
|
+
interactive: false,
|
|
53
|
+
pullNumber: 1,
|
|
54
|
+
repoName: 'repo-with-invalid-target-branch-label',
|
|
55
|
+
repoOwner: 'backport-org',
|
|
56
|
+
},
|
|
57
|
+
}));
|
|
58
|
+
});
|
|
59
|
+
it('should correct error code', async () => {
|
|
60
|
+
expect(response.status).toBe('failure');
|
|
61
|
+
expect(response.error.message).toBe('The branch "--foo" does not exist');
|
|
62
|
+
});
|
|
63
|
+
});
|
|
43
64
|
describe('when missing branches to backport to', () => {
|
|
44
65
|
let response;
|
|
45
66
|
beforeAll(async () => {
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { ValidConfigOptions } from '../../../options/options';
|
|
1
2
|
export interface TargetBranchResponse {
|
|
2
3
|
repository: {
|
|
3
4
|
ref: {
|
|
@@ -5,10 +6,4 @@ export interface TargetBranchResponse {
|
|
|
5
6
|
} | null;
|
|
6
7
|
};
|
|
7
8
|
}
|
|
8
|
-
export declare function validateTargetBranches({ accessToken, repoName, repoOwner,
|
|
9
|
-
accessToken: string;
|
|
10
|
-
repoOwner: string;
|
|
11
|
-
repoName: string;
|
|
12
|
-
targetBranches?: string[];
|
|
13
|
-
githubApiBaseUrlV4?: string;
|
|
14
|
-
}): Promise<void>;
|
|
9
|
+
export declare function validateTargetBranches({ accessToken, repoName, repoOwner, githubApiBaseUrlV4 }: ValidConfigOptions, targetBranches: string[]): Promise<void>;
|
|
@@ -32,7 +32,7 @@ async function fetchTargetBranch({ accessToken, repoName, repoOwner, branchName,
|
|
|
32
32
|
}
|
|
33
33
|
return res.repository.ref;
|
|
34
34
|
}
|
|
35
|
-
async function validateTargetBranches({ accessToken, repoName, repoOwner,
|
|
35
|
+
async function validateTargetBranches({ accessToken, repoName, repoOwner, githubApiBaseUrlV4 }, targetBranches) {
|
|
36
36
|
await Promise.all(targetBranches.map((targetBranch) => {
|
|
37
37
|
return fetchTargetBranch({
|
|
38
38
|
accessToken,
|
|
@@ -10,9 +10,9 @@ describe('validateTargetBranches', () => {
|
|
|
10
10
|
repoOwner: 'backport-org',
|
|
11
11
|
repoName: 'repo-with-target-branches',
|
|
12
12
|
accessToken,
|
|
13
|
-
targetBranches: [],
|
|
14
13
|
};
|
|
15
|
-
|
|
14
|
+
const targetBranches = [];
|
|
15
|
+
expect(await (0, validateTargetBranches_1.validateTargetBranches)(options, targetBranches)).toEqual(undefined);
|
|
16
16
|
});
|
|
17
17
|
});
|
|
18
18
|
describe('one invalid and one valid branch', () => {
|
|
@@ -21,9 +21,9 @@ describe('validateTargetBranches', () => {
|
|
|
21
21
|
repoOwner: 'backport-org',
|
|
22
22
|
repoName: 'repo-with-target-branches',
|
|
23
23
|
accessToken,
|
|
24
|
-
targetBranches: ['production', 'foo'],
|
|
25
24
|
};
|
|
26
|
-
|
|
25
|
+
const targetBranches = ['production', 'foo'];
|
|
26
|
+
await expect(() => (0, validateTargetBranches_1.validateTargetBranches)(options, targetBranches)).rejects.toThrowError('The branch "foo" does not exist');
|
|
27
27
|
});
|
|
28
28
|
});
|
|
29
29
|
describe('two valid branches', () => {
|
|
@@ -32,9 +32,9 @@ describe('validateTargetBranches', () => {
|
|
|
32
32
|
repoOwner: 'backport-org',
|
|
33
33
|
repoName: 'repo-with-target-branches',
|
|
34
34
|
accessToken,
|
|
35
|
-
targetBranches: ['production', 'staging'],
|
|
36
35
|
};
|
|
37
|
-
|
|
36
|
+
const targetBranches = ['production', 'staging'];
|
|
37
|
+
expect(await (0, validateTargetBranches_1.validateTargetBranches)(options, targetBranches)).toEqual(undefined);
|
|
38
38
|
});
|
|
39
39
|
});
|
|
40
40
|
describe('two invalid branches', () => {
|
|
@@ -43,9 +43,9 @@ describe('validateTargetBranches', () => {
|
|
|
43
43
|
repoOwner: 'backport-org',
|
|
44
44
|
repoName: 'repo-with-target-branches',
|
|
45
45
|
accessToken,
|
|
46
|
-
targetBranches: ['foo', 'bar'],
|
|
47
46
|
};
|
|
48
|
-
|
|
47
|
+
const targetBranches = ['foo', 'bar'];
|
|
48
|
+
await expect(() => (0, validateTargetBranches_1.validateTargetBranches)(options, targetBranches)).rejects.toThrow(/The branch "(foo|bar)" does not exist/);
|
|
49
49
|
});
|
|
50
50
|
});
|
|
51
51
|
});
|
package/dist/options/options.js
CHANGED
|
@@ -6,7 +6,6 @@ const BackportError_1 = require("../lib/BackportError");
|
|
|
6
6
|
const env_1 = require("../lib/env");
|
|
7
7
|
const getOptionsFromGithub_1 = require("../lib/github/v4/getOptionsFromGithub/getOptionsFromGithub");
|
|
8
8
|
const getRepoOwnerAndNameFromGitRemotes_1 = require("../lib/github/v4/getRepoOwnerAndNameFromGitRemotes");
|
|
9
|
-
const validateTargetBranches_1 = require("../lib/github/v4/validateTargetBranches");
|
|
10
9
|
const logger_1 = require("../lib/logger");
|
|
11
10
|
const config_1 = require("./config/config");
|
|
12
11
|
const PROJECT_CONFIG_DOCS_LINK = 'https://github.com/sqren/backport/blob/main/docs/configuration.md#project-config-backportrcjson';
|
|
@@ -79,9 +78,6 @@ async function getOptions({ optionsFromCliArgs, optionsFromModule, }) {
|
|
|
79
78
|
repoOwner,
|
|
80
79
|
};
|
|
81
80
|
throwForRequiredOptions(options);
|
|
82
|
-
if (options.targetBranches.length > 0) {
|
|
83
|
-
await (0, validateTargetBranches_1.validateTargetBranches)(options);
|
|
84
|
-
}
|
|
85
81
|
return options;
|
|
86
82
|
}
|
|
87
83
|
exports.getOptions = getOptions;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const PACKAGE_VERSION = "8.
|
|
1
|
+
export declare const PACKAGE_VERSION = "8.3.0-beta.1";
|