fix: createPr arguments order (#4878)

This commit is contained in:
Nico Domino 2024-09-11 13:43:26 +02:00 committed by GitHub
parent 25c2f516fd
commit a1ff2079db
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 36 additions and 17 deletions

View File

@ -126,7 +126,13 @@
return;
}
await $prService.createPr(title, body, opts.draft, upstreamBranchName, baseBranchName);
await $prService.createPr({
title,
body,
draft: opts.draft,
baseBranchName,
upstreamName: upstreamBranchName
});
} catch (err: any) {
console.error(err);
const toast = mapErrorToToast(err);

View File

@ -8,7 +8,12 @@ import { get, writable } from 'svelte/store';
import type { Persisted } from '$lib/persisted/persisted';
import type { RepoInfo } from '$lib/url/gitUrl';
import type { GitHostPrService } from '../interface/gitHostPrService';
import type { DetailedPullRequest, MergeMethod, PullRequest } from '../interface/types';
import type {
CreatePullRequestArgs,
DetailedPullRequest,
MergeMethod,
PullRequest
} from '../interface/types';
import type { Octokit } from '@octokit/rest';
const DEFAULT_PULL_REQUEST_TEMPLATE_PATH = '.github/PULL_REQUEST_TEMPLATE.md';
@ -23,13 +28,13 @@ export class GitHubPrService implements GitHostPrService {
private pullRequestTemplatePath?: Persisted<string>
) {}
async createPr(
title: string,
body: string,
draft: boolean,
baseBranchName: string,
upstreamName: string
): Promise<PullRequest> {
async createPr({
title,
body,
draft,
baseBranchName,
upstreamName
}: CreatePullRequestArgs): Promise<PullRequest> {
this.loading.set(true);
const request = async (pullRequestTemplate: string | undefined = '') => {
const resp = await this.octokit.rest.pulls.create({

View File

@ -1,6 +1,6 @@
import { buildContextStore } from '$lib/utils/context';
import type { GitHostPrMonitor } from './gitHostPrMonitor';
import type { DetailedPullRequest, MergeMethod, PullRequest } from './types';
import type { CreatePullRequestArgs, DetailedPullRequest, MergeMethod, PullRequest } from './types';
import type { Writable } from 'svelte/store';
export const [getGitHostPrService, createGitHostPrServiceStore] = buildContextStore<
@ -10,13 +10,13 @@ export const [getGitHostPrService, createGitHostPrServiceStore] = buildContextSt
export interface GitHostPrService {
loading: Writable<boolean>;
get(prNumber: number): Promise<DetailedPullRequest>;
createPr(
title: string,
body: string,
draft: boolean,
baseBranchName: string,
upstreamName: string
): Promise<PullRequest>;
createPr({
title,
body,
draft,
baseBranchName,
upstreamName
}: CreatePullRequestArgs): Promise<PullRequest>;
fetchPrTemplate(path?: string): Promise<string | undefined>;
merge(method: MergeMethod, prNumber: number): Promise<void>;
prMonitor(prNumber: number): GitHostPrMonitor;

View File

@ -76,3 +76,11 @@ export type GitHostArguments = {
baseBranch: string;
forkStr?: string;
};
export type CreatePullRequestArgs = {
title: string;
body: string;
draft: boolean;
baseBranchName: string;
upstreamName: string;
};