mirror of
https://code.forgejo.org/actions/git-backporting.git
synced 2025-05-13 09:09:13 -04:00
feat: config file as option (#42)
Fix https://github.com/lampajr/backporting/issues/37 This enhancement required a huge refactoring where all arguments defaults have been centralized in one single place ArgsParser#parse
This commit is contained in:
parent
a88adeec35
commit
5ead31f606
27 changed files with 1465 additions and 219 deletions
|
@ -7,17 +7,17 @@ import { GitPullRequest } from "@bp/service/git/git.types";
|
|||
|
||||
export default class PullRequestConfigsParser extends ConfigsParser {
|
||||
|
||||
private gitService: GitClient;
|
||||
private gitClient: GitClient;
|
||||
|
||||
constructor() {
|
||||
super();
|
||||
this.gitService = GitClientFactory.getClient();
|
||||
this.gitClient = GitClientFactory.getClient();
|
||||
}
|
||||
|
||||
public async parse(args: Args): Promise<Configs> {
|
||||
let pr: GitPullRequest;
|
||||
try {
|
||||
pr = await this.gitService.getPullRequestFromUrl(args.pullRequest);
|
||||
pr = await this.gitClient.getPullRequestFromUrl(args.pullRequest);
|
||||
} catch(error) {
|
||||
this.logger.error("Something went wrong retrieving pull request");
|
||||
throw error;
|
||||
|
@ -26,15 +26,15 @@ export default class PullRequestConfigsParser extends ConfigsParser {
|
|||
const folder: string = args.folder ?? this.getDefaultFolder();
|
||||
|
||||
return {
|
||||
dryRun: args.dryRun,
|
||||
dryRun: args.dryRun!,
|
||||
auth: args.auth,
|
||||
folder: `${folder.startsWith("/") ? "" : process.cwd() + "/"}${args.folder ?? this.getDefaultFolder()}`,
|
||||
targetBranch: args.targetBranch,
|
||||
originalPullRequest: pr,
|
||||
backportPullRequest: this.getDefaultBackportPullRequest(pr, args),
|
||||
git: {
|
||||
user: args.gitUser,
|
||||
email: args.gitEmail,
|
||||
user: args.gitUser ?? this.gitClient.getDefaultGitUser(),
|
||||
email: args.gitEmail ?? this.gitClient.getDefaultGitEmail(),
|
||||
}
|
||||
};
|
||||
}
|
||||
|
@ -64,7 +64,7 @@ export default class PullRequestConfigsParser extends ConfigsParser {
|
|||
const body = args.body ?? `${originalPullRequest.body}`;
|
||||
|
||||
return {
|
||||
author: args.gitUser,
|
||||
author: args.gitUser ?? this.gitClient.getDefaultGitUser(),
|
||||
title: args.title ?? `[${args.targetBranch}] ${originalPullRequest.title}`,
|
||||
body: `${bodyPrefix}${body}`,
|
||||
reviewers: [...new Set(reviewers)],
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue