- move around some parts of the code
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import {Extractor, Regex, Rule, Sort, Transformer} from 'github-pr-collector/lib/configuration'
|
||||
import {PullConfiguration} from 'github-pr-collector/lib/types'
|
||||
|
||||
export interface Configuration {
|
||||
export interface Configuration extends PullConfiguration {
|
||||
max_tags_to_fetch: number
|
||||
max_pull_requests: number
|
||||
max_back_track_time_days: number
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
import * as core from '@actions/core'
|
||||
import {Rule} from 'github-pr-collector/lib/configuration'
|
||||
import {PullRequestInfo, retrieveProperty} from 'github-pr-collector/lib/pullRequests'
|
||||
import {validateTransformer} from 'github-pr-collector/lib/regexUtils'
|
||||
import {RegexTransformer} from 'github-pr-collector/lib/types'
|
||||
|
||||
/**
|
||||
* Checks if any of the rules match the given PR
|
||||
*/
|
||||
export function matchesRules(rules: Rule[], pr: PullRequestInfo, exhaustive: Boolean): boolean {
|
||||
const transformers: RegexTransformer[] = rules.map(rule => validateTransformer(rule)).filter(t => t !== null) as RegexTransformer[]
|
||||
if (exhaustive) {
|
||||
return transformers.every(transformer => {
|
||||
return matches(pr, transformer, 'rule')
|
||||
})
|
||||
} else {
|
||||
return transformers.some(transformer => {
|
||||
return matches(pr, transformer, 'rule')
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the configured property results in a positive `test` with the regex.
|
||||
*/
|
||||
function matches(pr: PullRequestInfo, extractor: RegexTransformer, extractor_usecase: string): boolean {
|
||||
if (extractor.pattern == null) {
|
||||
return false
|
||||
}
|
||||
|
||||
if (extractor.onProperty !== undefined && extractor.onProperty.length === 1) {
|
||||
const prop = extractor.onProperty[0]
|
||||
const value = retrieveProperty(pr, prop, extractor_usecase)
|
||||
const matched = extractor.pattern.test(value)
|
||||
if (core.isDebug()) {
|
||||
core.debug(` Pattern ${extractor.pattern} resulted in ${matched} for ${value} on PR ${pr.number} (usecase: ${extractor_usecase})`)
|
||||
}
|
||||
return matched
|
||||
}
|
||||
return false
|
||||
}
|
||||
@@ -90,12 +90,11 @@ export class ReleaseNotesBuilder {
|
||||
return null
|
||||
}
|
||||
|
||||
const resolvedOptions = prData.options
|
||||
const options: ReleaseNotesOptions = {
|
||||
owner: this.owner,
|
||||
repo: this.repo,
|
||||
fromTag: resolvedOptions.fromTag,
|
||||
toTag: resolvedOptions.toTag,
|
||||
fromTag: prData.fromTag,
|
||||
toTag: prData.toTag,
|
||||
includeOpen: this.includeOpen,
|
||||
failOnError: this.failOnError,
|
||||
fetchReviewers: this.fetchReviewers,
|
||||
|
||||
+3
-1
@@ -3,9 +3,11 @@ import {Category, Configuration, Placeholder, Property} from './configuration'
|
||||
import {createOrSet, haveCommonElementsArr, haveEveryElementsArr} from './utils'
|
||||
import {CommentInfo, EMPTY_COMMENT_INFO, PullRequestInfo, retrieveProperty, sortPullRequests} from 'github-pr-collector/lib/pullRequests'
|
||||
import {DiffInfo} from 'github-pr-collector/lib/commits'
|
||||
import {RegexTransformer, matchesRules, validateTransformer} from 'github-pr-collector/lib/regexUtils'
|
||||
import {validateTransformer} from 'github-pr-collector/lib/regexUtils'
|
||||
import {Transformer} from 'github-pr-collector/lib/configuration'
|
||||
import {ReleaseNotesOptions} from './releaseNotesBuilder'
|
||||
import {matchesRules} from './regexUtils'
|
||||
import {RegexTransformer} from 'github-pr-collector/lib/types'
|
||||
|
||||
const EMPTY_MAP = new Map<string, string>()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user