fix: more conflict clean up

This commit is contained in:
ndom91 2024-09-13 11:17:04 +02:00
parent e842b282ae
commit 907bbe838d
8 changed files with 43 additions and 26 deletions

View File

@ -48,12 +48,12 @@ export class AzureDevOps implements GitHost {
return undefined;
}
async getAvailablePrTemplates(_path?: string) {
async availablePullRequestTemplates(_path?: string) {
// See: https://learn.microsoft.com/en-us/azure/devops/repos/git/pull-request-templates?view=azure-devops#default-pull-request-templates
return undefined;
}
async getPrTemplateContent(_path?: string) {
async pullRequestTemplateContent(_path?: string) {
return undefined;
}
}

View File

@ -52,12 +52,12 @@ export class BitBucket implements GitHost {
return undefined;
}
async getAvailablePrTemplates(_path?: string) {
async availablePullRequestTemplates(_path?: string) {
// See: https://confluence.atlassian.com/bitbucketserver/create-a-pull-request-808488431.html#Createapullrequest-templatePullrequestdescriptiontemplates
return undefined;
}
async getPrTemplateContent(_path?: string) {
async pullRequestTemplateContent(_path?: string) {
return undefined;
}
}

View File

@ -2,6 +2,7 @@ import { GitHubBranch } from './githubBranch';
import { GitHubChecksMonitor } from './githubChecksMonitor';
import { GitHubListingService } from './githubListingService';
import { GitHubPrService } from './githubPrService';
import { GitHubIssueService } from '$lib/gitHost/github/issueService';
import { Octokit } from '@octokit/rest';
import type { ProjectMetrics } from '$lib/metrics/projectMetrics';
import type { RepoInfo } from '$lib/url/gitUrl';
@ -50,6 +51,13 @@ export class GitHub implements GitHost {
return new GitHubPrService(this.octokit, this.repo);
}
issueService() {
if (!this.octokit) {
return;
}
return new GitHubIssueService(this.octokit, this.repo);
}
checksMonitor(sourceBranch: string) {
if (!this.octokit) {
return;

View File

@ -7,8 +7,13 @@ import { sleep } from '$lib/utils/sleep';
import posthog from 'posthog-js';
import { writable } from 'svelte/store';
import type { GitHostPrService } from '$lib/gitHost/interface/gitHostPrService';
import type { DetailedPullRequest, MergeMethod, PullRequest } from '$lib/gitHost/interface/types';
import type { RepoInfo } from '$lib/url/gitUrl';
import type {
CreatePullRequestArgs,
DetailedPullRequest,
MergeMethod,
PullRequest
} from '../interface/types';
import type { Octokit } from '@octokit/rest';
export class GitHubPrService implements GitHostPrService {
@ -19,13 +24,13 @@ export class GitHubPrService implements GitHostPrService {
private repo: RepoInfo
) {}
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 () => {
const resp = await this.octokit.rest.pulls.create({
@ -37,6 +42,7 @@ export class GitHubPrService implements GitHostPrService {
body,
draft
});
return ghResponseToInstance(resp.data);
};

View File

@ -53,12 +53,12 @@ export class GitLab implements GitHost {
return undefined;
}
async getAvailablePrTemplates(_path?: string) {
async availablePullRequestTemplates(_path?: string) {
// See: https://docs.gitlab.com/ee/user/project/description_templates.html
return undefined;
}
async getPrTemplateContent(_path?: string) {
async pullRequestTemplateContent(_path?: string) {
return undefined;
}
}

View File

@ -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>;
getAvailablePrTemplates(path?: string): Promise<string[] | undefined>;
getPrTemplateContent(path?: string): Promise<string | undefined>;
merge(method: MergeMethod, prNumber: number): Promise<void>;

View File

@ -77,8 +77,10 @@ export type GitHostArguments = {
forkStr?: string;
};
export type CreatePullRequestArguments = {
export type CreatePullRequestArgs = {
title: string;
body: string;
draft: boolean;
baseBranchName: string;
upstreamName: string;
};

View File

@ -115,21 +115,22 @@
// Refresh base branch if git fetch event is detected.
const mode = $derived(modeService.mode);
const head = $derived(modeService.head);
// We end up with a `state_unsafe_mutation` when switching projects if we
// don't use $effect.pre here.
// TODO: can we eliminate the need to debounce?
const fetch = $derived(fetchSignal.event);
const debouncedBaseBranchResfresh = debounce(() => baseBranchService.refresh(), 500);
$effect(() => {
$effect.pre(() => {
if ($fetch || $head) debouncedBaseBranchResfresh();
});
// TODO: can we eliminate the need to debounce?
const debouncedRemoteBranchRefresh = debounce(() => remoteBranchService.refresh(), 500);
$effect(() => {
$effect.pre(() => {
if ($baseBranch || $head || $fetch) debouncedRemoteBranchRefresh();
});
$effect(() => {
$effect.pre(() => {
const gitHost =
repoInfo && baseBranchName
? gitHostFactory.build(repoInfo, baseBranchName, forkInfo)