style: code formatting
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import {Rule, Extractor, Regex, Transformer, Sort, PullConfiguration} from './pr-collector/types'
|
||||
import {Extractor, PullConfiguration, Regex, Rule, Sort, Transformer} from './pr-collector/types'
|
||||
|
||||
export interface Configuration extends PullConfiguration {
|
||||
max_tags_to_fetch: number
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
import * as core from '@actions/core'
|
||||
import {Octokit, RestEndpointMethodTypes} from '@octokit/rest'
|
||||
import moment from 'moment'
|
||||
import {failOrError} from './utils'
|
||||
import {PullRequestInfo} from './pullRequests'
|
||||
import {Options} from './prCollector'
|
||||
import {BaseRepository} from "../repositories/BaseRepository";
|
||||
import {BaseRepository} from '../repositories/BaseRepository'
|
||||
|
||||
export interface DiffInfo {
|
||||
changedFiles: number
|
||||
@@ -35,8 +34,7 @@ export interface CommitInfo {
|
||||
}
|
||||
|
||||
export class Commits {
|
||||
constructor(private repositoryUtils: BaseRepository) {
|
||||
}
|
||||
constructor(private repositoryUtils: BaseRepository) {}
|
||||
|
||||
async getDiff(owner: string, repo: string, base: string, head: string): Promise<DiffInfo> {
|
||||
const diff: DiffInfo = await this.getDiffRemote(owner, repo, base, head)
|
||||
|
||||
@@ -1,12 +1,10 @@
|
||||
import * as core from '@actions/core'
|
||||
import {PullConfiguration} from './types'
|
||||
import {Octokit} from '@octokit/rest'
|
||||
import {TagInfo, Tags} from './tags'
|
||||
import {failOrError} from './utils'
|
||||
import {HttpsProxyAgent} from 'https-proxy-agent'
|
||||
import {PullRequestInfo, PullRequests} from './pullRequests'
|
||||
import {Commits, DiffInfo} from './commits'
|
||||
import {BaseRepository} from "../repositories/BaseRepository";
|
||||
import {BaseRepository} from '../repositories/BaseRepository'
|
||||
|
||||
export interface Options {
|
||||
owner: string // the owner of the repository
|
||||
@@ -47,7 +45,7 @@ export class PullRequestCollector {
|
||||
private fetchReleaseInformation = false,
|
||||
private fetchReviews = false,
|
||||
private commitMode = false,
|
||||
private configuration: PullConfiguration,
|
||||
private configuration: PullConfiguration
|
||||
) {}
|
||||
|
||||
async build(): Promise<Data | null> {
|
||||
|
||||
@@ -1,11 +1,10 @@
|
||||
import * as core from '@actions/core'
|
||||
import {Octokit, RestEndpointMethodTypes} from '@octokit/rest'
|
||||
import {Unpacked} from './utils'
|
||||
import {RestEndpointMethodTypes} from '@octokit/rest'
|
||||
import moment from 'moment'
|
||||
import {Property, Sort} from './types'
|
||||
import {Commits, DiffInfo, filterCommits} from './commits'
|
||||
import {Options} from './prCollector'
|
||||
import {BaseRepository} from "../repositories/BaseRepository";
|
||||
import {BaseRepository} from '../repositories/BaseRepository'
|
||||
|
||||
export interface PullRequestInfo {
|
||||
number: number
|
||||
@@ -77,12 +76,17 @@ export class PullRequests {
|
||||
private commits: Commits
|
||||
) {}
|
||||
|
||||
|
||||
async getForCommitHash(owner: string, repo: string, commit_sha: string, maxPullRequests: number): Promise<PullRequestInfo[]> {
|
||||
return sortPrs(await this.repositoryUtils.getForCommitHash(owner, repo, commit_sha, maxPullRequests))
|
||||
}
|
||||
|
||||
async getBetweenDates(owner: string, repo: string, fromDate: moment.Moment, toDate: moment.Moment, maxPullRequests: number): Promise<PullRequestInfo[]> {
|
||||
async getBetweenDates(
|
||||
owner: string,
|
||||
repo: string,
|
||||
fromDate: moment.Moment,
|
||||
toDate: moment.Moment,
|
||||
maxPullRequests: number
|
||||
): Promise<PullRequestInfo[]> {
|
||||
return sortPrs(await this.repositoryUtils.getBetweenDates(owner, repo, fromDate, toDate, maxPullRequests))
|
||||
}
|
||||
|
||||
@@ -215,8 +219,6 @@ export class PullRequests {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
function sortPrs(pullRequests: PullRequestInfo[]): PullRequestInfo[] {
|
||||
return sortPullRequests(pullRequests, {
|
||||
order: 'ASC',
|
||||
@@ -281,4 +283,3 @@ export function retrieveProperty(pr: PullRequestInfo, property: Property, useCas
|
||||
}
|
||||
return value
|
||||
}
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ import {RegexTransformer, TagResolver, Transformer} from './types'
|
||||
import {createCommandManager} from './gitHelper'
|
||||
import moment from 'moment'
|
||||
import {validateTransformer} from './regexUtils'
|
||||
import {BaseRepository} from "../repositories/BaseRepository";
|
||||
import {BaseRepository} from '../repositories/BaseRepository'
|
||||
|
||||
export interface TagResult {
|
||||
from: TagInfo | null
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
import * as core from '@actions/core'
|
||||
import {Rule, RegexTransformer} from './pr-collector/types'
|
||||
import {RegexTransformer, Rule} from './pr-collector/types'
|
||||
import {PullRequestInfo, retrieveProperty} from './pr-collector/pullRequests'
|
||||
import {validateTransformer} from './pr-collector/regexUtils'
|
||||
|
||||
|
||||
@@ -1,13 +1,12 @@
|
||||
import * as core from '@actions/core'
|
||||
import {Configuration} from './configuration'
|
||||
import {checkExportedData, writeCacheData} from './utils'
|
||||
import {PullRequestData, buildChangelog} from './transform'
|
||||
import {buildChangelog, PullRequestData} from './transform'
|
||||
import {PullRequestCollector} from './pr-collector/prCollector'
|
||||
import {failOrError} from './pr-collector/utils'
|
||||
import {TagInfo} from './pr-collector/tags'
|
||||
import {DiffInfo} from './pr-collector/commits'
|
||||
import {PullRequestInfo} from './pr-collector/pullRequests'
|
||||
import * as fs from 'fs'
|
||||
import {BaseRepository} from './repositories/BaseRepository'
|
||||
|
||||
export interface ReleaseNotesOptions {
|
||||
|
||||
@@ -1,20 +1,23 @@
|
||||
import {TagInfo} from "../pr-collector/tags";
|
||||
import {DiffInfo} from "../pr-collector/commits";
|
||||
import {Options} from "../pr-collector/prCollector";
|
||||
import moment from "moment/moment";
|
||||
import {PullRequestInfo} from "../pr-collector/pullRequests";
|
||||
import * as core from "@actions/core";
|
||||
import {createCommandManager} from "../pr-collector/gitHelper";
|
||||
import {TagInfo} from '../pr-collector/tags'
|
||||
import {DiffInfo} from '../pr-collector/commits'
|
||||
import moment from 'moment/moment'
|
||||
import {PullRequestInfo} from '../pr-collector/pullRequests'
|
||||
import * as core from '@actions/core'
|
||||
import {createCommandManager} from '../pr-collector/gitHelper'
|
||||
|
||||
export abstract class BaseRepository {
|
||||
proxy?: string;
|
||||
proxy?: string
|
||||
noProxyArray: string[]
|
||||
|
||||
// Define an abstract getter for the default URL
|
||||
abstract get defaultUrl(): string;
|
||||
abstract get defaultUrl(): string
|
||||
|
||||
abstract get homeUrl():string;
|
||||
protected constructor(protected token: string, protected url: string | undefined,protected repositoryPath:string) {
|
||||
abstract get homeUrl(): string
|
||||
protected constructor(
|
||||
protected token: string,
|
||||
protected url: string | undefined,
|
||||
protected repositoryPath: string
|
||||
) {
|
||||
this.proxy = process.env.https_proxy || process.env.HTTPS_PROXY
|
||||
const noProxy = process.env.no_proxy || process.env.NO_PROXY
|
||||
this.noProxyArray = []
|
||||
@@ -29,16 +32,20 @@ export abstract class BaseRepository {
|
||||
|
||||
abstract getDiffRemote(owner: string, repo: string, base: string, head: string): Promise<DiffInfo>
|
||||
|
||||
|
||||
abstract getForCommitHash(owner: string, repo: string, commit_sha: string, maxPullRequests: number): Promise<PullRequestInfo[]>
|
||||
|
||||
abstract getBetweenDates(owner: string, repo: string, fromDate: moment.Moment, toDate: moment.Moment, maxPullRequests: number): Promise<PullRequestInfo[]>
|
||||
abstract getBetweenDates(
|
||||
owner: string,
|
||||
repo: string,
|
||||
fromDate: moment.Moment,
|
||||
toDate: moment.Moment,
|
||||
maxPullRequests: number
|
||||
): Promise<PullRequestInfo[]>
|
||||
|
||||
abstract getOpen(owner: string, repo: string, maxPullRequests: number): Promise<PullRequestInfo[]>
|
||||
|
||||
abstract getReviews(owner: string, repo: string, pr: PullRequestInfo): Promise<void>
|
||||
|
||||
|
||||
protected async getTagByCreateTime(repositoryPath: string, tagInfo: TagInfo) {
|
||||
core.info(`⚠️ No release information found for ${tagInfo.name}, trying to retrieve tag creation time as fallback.`)
|
||||
const gitHelper = await createCommandManager(repositoryPath)
|
||||
@@ -56,5 +63,4 @@ export abstract class BaseRepository {
|
||||
}
|
||||
return tagInfo
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,19 +1,14 @@
|
||||
import {BaseRepository} from "./BaseRepository";
|
||||
import {Octokit, RestEndpointMethodTypes} from "@octokit/rest";
|
||||
import {HttpsProxyAgent} from "https-proxy-agent";
|
||||
import * as core from "@actions/core";
|
||||
import {TagInfo} from "../pr-collector/tags";
|
||||
import moment from "moment/moment";
|
||||
import {DiffInfo} from "../pr-collector/commits";
|
||||
import {
|
||||
CommentInfo, PullData,
|
||||
PullRequestInfo,
|
||||
PullReviewsData, PullsListData
|
||||
} from "../pr-collector/pullRequests";
|
||||
import {Unpacked} from "../pr-collector/utils";
|
||||
import {BaseRepository} from './BaseRepository'
|
||||
import {Octokit, RestEndpointMethodTypes} from '@octokit/rest'
|
||||
import {HttpsProxyAgent} from 'https-proxy-agent'
|
||||
import * as core from '@actions/core'
|
||||
import {TagInfo} from '../pr-collector/tags'
|
||||
import moment from 'moment/moment'
|
||||
import {DiffInfo} from '../pr-collector/commits'
|
||||
import {CommentInfo, PullData, PullRequestInfo, PullReviewsData, PullsListData} from '../pr-collector/pullRequests'
|
||||
import {Unpacked} from '../pr-collector/utils'
|
||||
|
||||
export class GithubRepository extends BaseRepository {
|
||||
|
||||
async getDiffRemote(owner: string, repo: string, base: string, head: string): Promise<DiffInfo> {
|
||||
let changedFilesCount = 0
|
||||
let additionCount = 0
|
||||
@@ -93,7 +88,13 @@ export class GithubRepository extends BaseRepository {
|
||||
return mergedPRs
|
||||
}
|
||||
|
||||
async getBetweenDates(owner: string, repo: string, fromDate: moment.Moment, toDate: moment.Moment, maxPullRequests: number): Promise<PullRequestInfo[]> {
|
||||
async getBetweenDates(
|
||||
owner: string,
|
||||
repo: string,
|
||||
fromDate: moment.Moment,
|
||||
toDate: moment.Moment,
|
||||
maxPullRequests: number
|
||||
): Promise<PullRequestInfo[]> {
|
||||
const mergedPRs: PullRequestInfo[] = []
|
||||
const options = this.octokit.pulls.list.endpoint.merge({
|
||||
owner,
|
||||
@@ -173,13 +174,13 @@ export class GithubRepository extends BaseRepository {
|
||||
}
|
||||
|
||||
get defaultUrl(): string {
|
||||
return "https://api.github.com";
|
||||
return 'https://api.github.com'
|
||||
}
|
||||
|
||||
private octokit: Octokit
|
||||
|
||||
constructor(token: string, url: string | undefined, repositoryPath: string) {
|
||||
super(token, url,repositoryPath);
|
||||
super(token, url, repositoryPath)
|
||||
this.url = url || this.defaultUrl
|
||||
|
||||
// load octokit instance
|
||||
@@ -297,6 +298,6 @@ export class GithubRepository extends BaseRepository {
|
||||
return false
|
||||
}
|
||||
get homeUrl(): string {
|
||||
return "https://github.com";
|
||||
return 'https://github.com'
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -11,7 +11,7 @@ import {
|
||||
} from './pr-collector/pullRequests'
|
||||
import {DiffInfo} from './pr-collector/commits'
|
||||
import {validateTransformer} from './pr-collector/regexUtils'
|
||||
import {Transformer, RegexTransformer} from './pr-collector/types'
|
||||
import {RegexTransformer, Transformer} from './pr-collector/types'
|
||||
import {ReleaseNotesOptions} from './releaseNotesBuilder'
|
||||
import {matchesRules} from './regexUtils'
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@ import {DiffInfo} from './pr-collector/commits'
|
||||
import {PullRequestInfo} from './pr-collector/pullRequests'
|
||||
import {Data, ReleaseNotesOptions} from './releaseNotesBuilder'
|
||||
import {env} from 'process'
|
||||
|
||||
/**
|
||||
* Resolves the repository path, relatively to the GITHUB_WORKSPACE
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user