Skip to content

Commit cf18f08

Browse files
committed
refactor(ng-dev/pr): move pr configuration out of the merge directory (#227)
As part of #203, refactoring the pr directory into more reusable pieces. PR Close #227
1 parent 3fea02f commit cf18f08

File tree

10 files changed

+26
-17
lines changed

10 files changed

+26
-17
lines changed

ng-dev/pr/BUILD.bazel

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,12 @@ ts_library(
1313
"@npm//@types/yargs",
1414
],
1515
)
16+
17+
ts_library(
18+
name = "config",
19+
srcs = ["config.ts"],
20+
visibility = ["//ng-dev:__subpackages__"],
21+
deps = [
22+
"//ng-dev/utils",
23+
],
24+
)

ng-dev/pr/check-target-branches/BUILD.bazel

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ ts_library(
55
srcs = glob(["*.ts"]),
66
visibility = ["//ng-dev:__subpackages__"],
77
deps = [
8+
"//ng-dev/pr:config",
89
"//ng-dev/pr/merge",
910
"//ng-dev/utils",
1011
"@npm//@types/yargs",

ng-dev/pr/check-target-branches/check-target-branches.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
import {assertValidGithubConfig, getConfig, GithubConfig} from '../../utils/config';
1010
import {info} from '../../utils/console';
1111
import {GitClient} from '../../utils/git/git-client';
12-
import {assertValidMergeConfig, MergeConfig} from '../merge/config';
12+
import {assertValidMergeConfig, MergeConfig} from '../config';
1313
import {getTargetBranchesForPullRequest} from '../merge/target-label';
1414

1515
async function getTargetBranchesForPr(

ng-dev/pr/merge/config.ts renamed to ng-dev/pr/config.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,22 @@
66
* found in the LICENSE file at https://angular.io/license
77
*/
88

9-
import {ConfigValidationError, GithubConfig} from '../../utils/config';
10-
11-
import {GithubApiMergeStrategyConfig} from './strategies/api-merge';
9+
import {ConfigValidationError, GithubConfig} from '../utils/config';
1210

1311
/**
1412
* Possible merge methods supported by the Github API.
1513
* https://developer.github.com/v3/pulls/#merge-a-pull-request-merge-button.
1614
*/
1715
export type GithubApiMergeMethod = 'merge' | 'squash' | 'rebase';
1816

17+
/** Configuration for the Github API merge strategy. */
18+
export interface GithubApiMergeStrategyConfig {
19+
/** Default method used for merging pull requests */
20+
default: GithubApiMergeMethod;
21+
/** Labels which specify a different merge method than the default. */
22+
labels?: {pattern: string; method: GithubApiMergeMethod}[];
23+
}
24+
1925
/**
2026
* Configuration for the merge script with all remote options specified. The
2127
* default `MergeConfig` has does not require any of these options as defaults

ng-dev/pr/merge/BUILD.bazel

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ ts_library(
1616
],
1717
deps = [
1818
"//ng-dev/commit-message",
19+
"//ng-dev/pr:config",
1920
"//ng-dev/pr/common",
2021
"//ng-dev/release/config",
2122
"//ng-dev/release/versioning",

ng-dev/pr/merge/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import {AuthenticatedGitClient} from '../../utils/git/authenticated-git-client';
1212
import {GithubApiRequestError} from '../../utils/git/github';
1313
import {GITHUB_TOKEN_GENERATE_URL} from '../../utils/git/github-urls';
1414

15-
import {assertValidMergeConfig} from './config';
15+
import {assertValidMergeConfig} from '../config';
1616
import {MergeResult, MergeStatus, PullRequestMergeTask, PullRequestMergeTaskFlags} from './task';
1717

1818
/**

ng-dev/pr/merge/strategies/api-merge.ts

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import {prompt} from 'inquirer';
1111

1212
import {parseCommitMessage} from '../../../commit-message/parse';
1313
import {AuthenticatedGitClient} from '../../../utils/git/authenticated-git-client';
14-
import {GithubApiMergeMethod} from '../config';
14+
import {GithubApiMergeMethod, GithubApiMergeStrategyConfig} from '../../config';
1515
import {PullRequestFailure} from '../failures';
1616
import {PullRequest} from '../pull-request';
1717
import {matchesPattern} from '../string-pattern';
@@ -22,14 +22,6 @@ import {GithubApiRequestError} from '../../../utils/git/github';
2222
/** Type describing the parameters for the Octokit `merge` API endpoint. */
2323
type OctokitMergeParams = RestEndpointMethodTypes['pulls']['merge']['parameters'];
2424

25-
/** Configuration for the Github API merge strategy. */
26-
export interface GithubApiMergeStrategyConfig {
27-
/** Default method used for merging pull requests */
28-
default: GithubApiMergeMethod;
29-
/** Labels which specify a different merge method than the default. */
30-
labels?: {pattern: string; method: GithubApiMergeMethod}[];
31-
}
32-
3325
/** Separator between commit message header and body. */
3426
const COMMIT_HEADER_SEPARATOR = '\n\n';
3527

ng-dev/pr/merge/target-label.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* found in the LICENSE file at https://angular.io/license
77
*/
88

9-
import {MergeConfig} from './config';
9+
import {MergeConfig} from '../config';
1010
import {getTargetLabelsForActiveReleaseTrains} from './defaults';
1111
import {GithubConfig} from '../../utils/config';
1212
import {Commit} from '../../commit-message/parse';

ng-dev/pr/merge/task.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import {promptConfirm} from '../../utils/console';
1010
import {AuthenticatedGitClient} from '../../utils/git/authenticated-git-client';
1111
import {GitCommandError} from '../../utils/git/git-client';
1212

13-
import {MergeConfigWithRemote} from './config';
13+
import {MergeConfigWithRemote} from '../config';
1414
import {PullRequestFailure} from './failures';
1515
import {
1616
getCaretakerNotePromptMessage,

ng-dev/pr/merge/validations.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
import {Commit} from '../../commit-message/parse';
1010
import {TargetLabel, TargetLabelName} from './target-label';
11-
import {MergeConfig} from './config';
11+
import {MergeConfig} from '../config';
1212
import {PullRequestFailure} from './failures';
1313
import {red, warn} from '../../utils/console';
1414
import {breakingChangeLabel} from './constants';

0 commit comments

Comments
 (0)