mirror of
https://github.com/actions/labeler.git
synced 2025-12-13 13:07:24 +00:00
Create new interfaces for MatchConfig
This commit is contained in:
@@ -1,9 +1,14 @@
|
|||||||
import * as core from '@actions/core';
|
import * as core from '@actions/core';
|
||||||
import * as github from '@actions/github';
|
import * as github from '@actions/github';
|
||||||
|
|
||||||
|
export interface BranchMatchConfig {
|
||||||
|
headBranch?: string[];
|
||||||
|
baseBranch?: string[];
|
||||||
|
}
|
||||||
|
|
||||||
type BranchBase = 'base' | 'head';
|
type BranchBase = 'base' | 'head';
|
||||||
|
|
||||||
export function toMatchConfigWithBranches(config: any) {
|
export function toBranchMatchConfig(config: any): BranchMatchConfig {
|
||||||
if (!config['head-branch'] || config['base-branch']) {
|
if (!config['head-branch'] || config['base-branch']) {
|
||||||
return config;
|
return config;
|
||||||
}
|
}
|
||||||
@@ -27,12 +32,7 @@ export function toMatchConfigWithBranches(config: any) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return branchConfig;
|
||||||
...config,
|
|
||||||
['head-branch']: undefined,
|
|
||||||
['base-branch']: undefined,
|
|
||||||
...branchConfig
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getBranchName(branchBase?: BranchBase): string | undefined {
|
export function getBranchName(branchBase?: BranchBase): string | undefined {
|
||||||
|
|||||||
@@ -3,15 +3,19 @@ import * as github from '@actions/github';
|
|||||||
import * as yaml from 'js-yaml';
|
import * as yaml from 'js-yaml';
|
||||||
import {Minimatch} from 'minimatch';
|
import {Minimatch} from 'minimatch';
|
||||||
|
|
||||||
import {checkBranch, toMatchConfigWithBranches} from './branch';
|
import {checkBranch, toBranchMatchConfig, BranchMatchConfig} from './branch';
|
||||||
|
|
||||||
interface MatchConfig {
|
interface FilesChangedMatchConfig {
|
||||||
all?: string[];
|
all?: string[];
|
||||||
any?: string[];
|
any?: string[];
|
||||||
headBranch?: string[];
|
filesChanged?: {
|
||||||
baseBranch?: string[];
|
all?: string[];
|
||||||
|
any?: string[];
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type MatchConfig = FilesChangedMatchConfig & BranchMatchConfig;
|
||||||
|
|
||||||
type StringOrMatchConfig = string | MatchConfig;
|
type StringOrMatchConfig = string | MatchConfig;
|
||||||
type ClientType = ReturnType<typeof github.getOctokit>;
|
type ClientType = ReturnType<typeof github.getOctokit>;
|
||||||
|
|
||||||
@@ -152,7 +156,12 @@ function toMatchConfig(config: StringOrMatchConfig): MatchConfig {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
return toMatchConfigWithBranches(config);
|
const branchConfig = toBranchMatchConfig(config);
|
||||||
|
|
||||||
|
return {
|
||||||
|
...config,
|
||||||
|
...branchConfig
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
function printPattern(matcher: Minimatch): string {
|
function printPattern(matcher: Minimatch): string {
|
||||||
|
|||||||
Reference in New Issue
Block a user