mirror of
https://gitlab.com/soapbox-pub/shakespeare.git
synced 2026-12-05 16:23:36 +00:00
Fix linter errors
This commit is contained in:
10 files changed
+79
-72
No files matched your search
@@ -71,15 +71,6 @@ export function AnnounceRepositoryDialog({
|
||||
}
|
||||
}, [open]);
|
||||
|
||||
useEffect(() => {
|
||||
if (isOpen && remoteUrl) {
|
||||
// Parse remote URL to pre-fill data
|
||||
parseRemoteUrl(remoteUrl);
|
||||
// Get earliest commit
|
||||
getEarliestCommit();
|
||||
}
|
||||
}, [isOpen, remoteUrl, parseRemoteUrl, getEarliestCommit]);
|
||||
|
||||
const parseRemoteUrl = useCallback((url: string) => {
|
||||
// Extract repo ID from Nostr URL
|
||||
if (url.startsWith('nostr://')) {
|
||||
@@ -114,6 +105,15 @@ export function AnnounceRepositoryDialog({
|
||||
}
|
||||
}, [git, projectPath]);
|
||||
|
||||
useEffect(() => {
|
||||
if (isOpen && remoteUrl) {
|
||||
// Parse remote URL to pre-fill data
|
||||
parseRemoteUrl(remoteUrl);
|
||||
// Get earliest commit
|
||||
getEarliestCommit();
|
||||
}
|
||||
}, [isOpen, remoteUrl, parseRemoteUrl, getEarliestCommit]);
|
||||
|
||||
const addWebUrl = () => {
|
||||
if (newWebUrl.trim() && !webUrls.includes(newWebUrl.trim())) {
|
||||
setWebUrls([...webUrls, newWebUrl.trim()]);
|
||||
|
||||
@@ -141,6 +141,33 @@ export function PullRequestDialog({
|
||||
return;
|
||||
}
|
||||
|
||||
const ensureFork = async (info: RemoteInfo, token: string): Promise<{ owner: string; repo: string; url: string }> => {
|
||||
console.log('=== ENSURE FORK ===');
|
||||
console.log('Repository:', `${info.owner}/${info.repo}`);
|
||||
|
||||
// First check if fork already exists
|
||||
const user = await getCurrentUser(info, token);
|
||||
console.log('Current user:', user.username);
|
||||
|
||||
const existingFork = await checkForkExists(info, token, user.username);
|
||||
|
||||
if (existingFork) {
|
||||
console.log('Found existing fork:', existingFork);
|
||||
return existingFork;
|
||||
}
|
||||
|
||||
// Create fork
|
||||
console.log('No existing fork found, creating new fork...');
|
||||
const fork = await createFork(info, token);
|
||||
console.log('Fork created:', fork);
|
||||
|
||||
// Wait a bit for fork to be ready
|
||||
console.log('Waiting 2 seconds for fork to be ready...');
|
||||
await new Promise(resolve => setTimeout(resolve, 2000));
|
||||
|
||||
return fork;
|
||||
};
|
||||
|
||||
setIsCheckingPermissions(true);
|
||||
try {
|
||||
const credentials = findCredentialsForRepo(remoteUrl, settings.credentials);
|
||||
@@ -178,7 +205,7 @@ export function PullRequestDialog({
|
||||
} finally {
|
||||
setIsCheckingPermissions(false);
|
||||
}
|
||||
}, [remoteInfo, remoteUrl, settings.credentials, ensureFork]);
|
||||
}, [remoteInfo, remoteUrl, settings.credentials]);
|
||||
|
||||
useEffect(() => {
|
||||
if (isOpen && remoteUrl) {
|
||||
@@ -569,33 +596,6 @@ export function PullRequestDialog({
|
||||
}
|
||||
};
|
||||
|
||||
const ensureFork = async (info: RemoteInfo, token: string): Promise<{ owner: string; repo: string; url: string }> => {
|
||||
console.log('=== ENSURE FORK ===');
|
||||
console.log('Repository:', `${info.owner}/${info.repo}`);
|
||||
|
||||
// First check if fork already exists
|
||||
const user = await getCurrentUser(info, token);
|
||||
console.log('Current user:', user.username);
|
||||
|
||||
const existingFork = await checkForkExists(info, token, user.username);
|
||||
|
||||
if (existingFork) {
|
||||
console.log('Found existing fork:', existingFork);
|
||||
return existingFork;
|
||||
}
|
||||
|
||||
// Create fork
|
||||
console.log('No existing fork found, creating new fork...');
|
||||
const fork = await createFork(info, token);
|
||||
console.log('Fork created:', fork);
|
||||
|
||||
// Wait a bit for fork to be ready
|
||||
console.log('Waiting 2 seconds for fork to be ready...');
|
||||
await new Promise(resolve => setTimeout(resolve, 2000));
|
||||
|
||||
return fork;
|
||||
};
|
||||
|
||||
const getCurrentUser = async (info: RemoteInfo, token: string): Promise<{ username: string }> => {
|
||||
const url = info.platform === 'github' ? `${info.apiUrl}/user` : `${info.apiUrl}/user`;
|
||||
const headers: Record<string, string> = info.platform === 'github'
|
||||
|
||||
@@ -106,13 +106,12 @@ export function PullRequestForm({ projectId, currentBranch, remoteUrl }: PullReq
|
||||
} else {
|
||||
setError('Unsupported remote URL format');
|
||||
}
|
||||
} catch (err) {
|
||||
} catch {
|
||||
setError('Failed to parse remote URL');
|
||||
}
|
||||
}, []);
|
||||
|
||||
const loadRemoteBranches = useCallback(async () => {
|
||||
setIsLoadingBranches(true);
|
||||
try {
|
||||
const branches = await git.listBranches({
|
||||
dir: projectPath,
|
||||
@@ -129,8 +128,6 @@ export function PullRequestForm({ projectId, currentBranch, remoteUrl }: PullReq
|
||||
}
|
||||
} catch {
|
||||
setRemoteBranches(['main', 'master', 'develop']);
|
||||
} finally {
|
||||
setIsLoadingBranches(false);
|
||||
}
|
||||
}, [git, projectPath]);
|
||||
|
||||
|
||||
@@ -260,7 +260,14 @@ async function fetchNostrPatches(
|
||||
|
||||
try {
|
||||
// Build query filter based on whether user is repo owner or contributor
|
||||
const filter: any = {
|
||||
interface PatchFilter {
|
||||
kinds: number[];
|
||||
'#a': string[];
|
||||
limit: number;
|
||||
authors?: string[];
|
||||
}
|
||||
|
||||
const filter: PatchFilter = {
|
||||
kinds: [1617],
|
||||
'#a': [`30617:${info.owner}:${info.repo}`],
|
||||
limit: 50,
|
||||
@@ -286,12 +293,13 @@ async function fetchNostrPatches(
|
||||
let statusEvents: NostrEvent[] = [];
|
||||
|
||||
if (patchIds.length > 0) {
|
||||
statusEvents = await nostr.query([
|
||||
const events = await nostr.query([
|
||||
{
|
||||
kinds: [1630, 1631, 1632, 1633], // Open, Applied/Merged, Closed, Draft
|
||||
'#e': patchIds,
|
||||
}
|
||||
], { signal });
|
||||
statusEvents = events as NostrEvent[];
|
||||
console.log(`Found ${statusEvents.length} status events`);
|
||||
}
|
||||
|
||||
|
||||
@@ -165,6 +165,7 @@ describe('configUtils', () => {
|
||||
|
||||
expect(result).toEqual({
|
||||
credentials: {},
|
||||
hostTokens: {},
|
||||
coAuthorEnabled: true,
|
||||
});
|
||||
});
|
||||
|
||||
@@ -5,6 +5,7 @@ import type {
|
||||
GitRepository,
|
||||
GitFork,
|
||||
PullRequest,
|
||||
PullRequestCheck,
|
||||
CreatePullRequestOptions,
|
||||
GitHostUser,
|
||||
} from './types';
|
||||
@@ -274,7 +275,7 @@ export class GitHubProvider implements GitHostProvider {
|
||||
mergeable?: boolean;
|
||||
merged?: boolean;
|
||||
}): PullRequest {
|
||||
const state = data.merged ? 'merged' : data.state;
|
||||
const state: 'open' | 'closed' | 'merged' = data.merged ? 'merged' : data.state as 'open' | 'closed';
|
||||
|
||||
return {
|
||||
number: data.number,
|
||||
@@ -294,7 +295,7 @@ export class GitHubProvider implements GitHostProvider {
|
||||
};
|
||||
}
|
||||
|
||||
private transformChecks(data: any): PullRequestCheck[] | undefined {
|
||||
private transformChecks(_data: unknown): PullRequestCheck[] | undefined {
|
||||
// GitHub's check runs are in a separate API call, so we don't have them here
|
||||
// This would need a separate API call to /repos/{owner}/{repo}/commits/{ref}/check-runs
|
||||
return undefined;
|
||||
|
||||
@@ -5,6 +5,7 @@ import type {
|
||||
GitRepository,
|
||||
GitFork,
|
||||
PullRequest,
|
||||
PullRequestCheck,
|
||||
CreatePullRequestOptions,
|
||||
GitHostUser,
|
||||
} from './types';
|
||||
@@ -25,6 +26,10 @@ interface GitLabMRResponse {
|
||||
target_project_id: number;
|
||||
merge_status?: string;
|
||||
merged_at?: string;
|
||||
pipeline?: {
|
||||
status: string;
|
||||
web_url: string;
|
||||
};
|
||||
}
|
||||
|
||||
export class GitLabProvider implements GitHostProvider {
|
||||
@@ -245,7 +250,7 @@ export class GitLabProvider implements GitHostProvider {
|
||||
|
||||
async closePullRequest(owner: string, repo: string, number: number): Promise<PullRequest> {
|
||||
const projectPath = this.encodeProjectPath(owner, repo);
|
||||
const data = await this.fetch<any>(`/projects/${projectPath}/merge_requests/${number}`, {
|
||||
const data = await this.fetch<GitLabMRResponse>(`/projects/${projectPath}/merge_requests/${number}`, {
|
||||
method: 'PUT',
|
||||
body: JSON.stringify({
|
||||
state_event: 'close',
|
||||
@@ -278,23 +283,7 @@ export class GitLabProvider implements GitHostProvider {
|
||||
return `https://gitlab.com/${baseRepo}/-/merge_requests/new?merge_request[source_branch]=${headBranch}&merge_request[source_project]=${headOwner}/${headRepoName}&merge_request[target_branch]=${baseBranch}`;
|
||||
}
|
||||
|
||||
private transformMergeRequest(data: {
|
||||
id: number;
|
||||
iid: number;
|
||||
state: string;
|
||||
title: string;
|
||||
description: string;
|
||||
web_url: string;
|
||||
created_at: string;
|
||||
updated_at: string;
|
||||
author: { username: string };
|
||||
source_branch: string;
|
||||
target_branch: string;
|
||||
source_project_id: number;
|
||||
target_project_id: number;
|
||||
merge_status?: string;
|
||||
merged_at?: string;
|
||||
}): PullRequest {
|
||||
private transformMergeRequest(data: GitLabMRResponse): PullRequest {
|
||||
const state = data.state === 'merged' ? 'merged' : data.state === 'opened' ? 'open' : 'closed';
|
||||
|
||||
return {
|
||||
@@ -315,14 +304,24 @@ export class GitLabProvider implements GitHostProvider {
|
||||
};
|
||||
}
|
||||
|
||||
private transformPipeline(data: any): PullRequestCheck[] | undefined {
|
||||
private transformPipeline(data: GitLabMRResponse): PullRequestCheck[] | undefined {
|
||||
if (!data.pipeline) return undefined;
|
||||
|
||||
const mapConclusion = (status: string): PullRequestCheck['conclusion'] => {
|
||||
switch (status) {
|
||||
case 'success': return 'success';
|
||||
case 'failed': return 'failure';
|
||||
case 'canceled': return 'cancelled';
|
||||
case 'skipped': return 'skipped';
|
||||
default: return undefined;
|
||||
}
|
||||
};
|
||||
|
||||
return [{
|
||||
name: 'Pipeline',
|
||||
status: data.pipeline.status === 'running' ? 'pending' :
|
||||
data.pipeline.status === 'success' ? 'success' : 'failure',
|
||||
conclusion: data.pipeline.status,
|
||||
data.pipeline.status === 'success' ? 'success' : 'failure',
|
||||
conclusion: mapConclusion(data.pipeline.status),
|
||||
detailsUrl: data.pipeline.web_url,
|
||||
}];
|
||||
}
|
||||
|
||||
@@ -272,7 +272,7 @@ export class GiteaProvider implements GitHostProvider {
|
||||
mergeable?: boolean;
|
||||
merged?: boolean;
|
||||
}): PullRequest {
|
||||
const state = data.merged ? 'merged' : data.state;
|
||||
const state: 'open' | 'closed' | 'merged' = data.merged ? 'merged' : data.state as 'open' | 'closed';
|
||||
|
||||
return {
|
||||
number: data.number,
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { NRelay1 } from '@nostrify/nostrify';
|
||||
import { NRelay1, type NostrEvent } from '@nostrify/nostrify';
|
||||
import type {
|
||||
GitHostProvider,
|
||||
GitHostConfig,
|
||||
@@ -10,7 +10,7 @@ import type {
|
||||
} from './types';
|
||||
|
||||
interface NostrSigner {
|
||||
signEvent: (event: { kind: number; content: string; tags: string[][]; created_at: number }) => Promise<unknown>;
|
||||
signEvent: (event: { kind: number; content: string; tags: string[][]; created_at: number }) => Promise<NostrEvent>;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -36,7 +36,7 @@ export class NostrGitProvider implements GitHostProvider {
|
||||
this.relay = new NRelay1('wss://relay.nostr.band'); // Default, will be changed
|
||||
}
|
||||
|
||||
private async queryRepo(owner: string, repo: string): Promise<{ tags: string[][]; content: string }> {
|
||||
private async queryRepo(owner: string, repo: string): Promise<NostrEvent> {
|
||||
// Query for repository announcement (kind 30617)
|
||||
// d tag is the repo-id (usually kebab-case short name)
|
||||
const events = await this.relay.query([
|
||||
@@ -46,7 +46,7 @@ export class NostrGitProvider implements GitHostProvider {
|
||||
'#d': [repo], // repo is the d tag identifier
|
||||
limit: 1,
|
||||
}
|
||||
]);
|
||||
]) as NostrEvent[];
|
||||
|
||||
if (events.length === 0) {
|
||||
throw new Error(`Repository not found: ${owner}/${repo}`);
|
||||
|
||||
@@ -10,12 +10,13 @@ import { GiteaProvider } from './GiteaProvider';
|
||||
import { NostrGitProvider } from './NostrGitProvider';
|
||||
import { detectGitHost } from './types';
|
||||
import type { GitHostProvider, GitHostConfig } from './types';
|
||||
import type { NostrEvent } from '@nostrify/nostrify';
|
||||
|
||||
/**
|
||||
* Create a Git host provider instance based on the repository URL
|
||||
*/
|
||||
interface NostrSigner {
|
||||
signEvent: (event: { kind: number; content: string; tags: string[][]; created_at: number }) => Promise<unknown>;
|
||||
signEvent: (event: { kind: number; content: string; tags: string[][]; created_at: number }) => Promise<NostrEvent>;
|
||||
}
|
||||
|
||||
export function createGitHostProvider(
|
||||
|
||||
Reference in new issue
Block a user