mirror of
https://gitlab.com/soapbox-pub/shakespeare.git
synced 2026-12-05 16:23:36 +00:00
Refactor ProjectsManager.cloneProject to accept an options object
This commit is contained in:
4 files changed
+26
-6
No files matched your search
@@ -41,7 +41,10 @@ export function RepositoryCard({ repo }: RepositoryCardProps) {
|
||||
await projectsManager.init();
|
||||
|
||||
// Clone the repository using the Nostr URI
|
||||
const project = await projectsManager.cloneProject(repo.name, nostrURI.toString());
|
||||
const project = await projectsManager.cloneProject({
|
||||
name: repo.name,
|
||||
repoUrl: nostrURI.toString(),
|
||||
});
|
||||
|
||||
toast({
|
||||
title: t('nostrRepositoryImportedSuccessfully'),
|
||||
|
||||
@@ -457,7 +457,10 @@ describe('ProjectsManager', () => {
|
||||
Object.assign(projectsManager, { git: mockGit });
|
||||
|
||||
// Attempt to clone a project
|
||||
await expect(projectsManager.cloneProject('test-project', 'https://github.com/test/repo.git'))
|
||||
await expect(projectsManager.cloneProject({
|
||||
name: 'test-project',
|
||||
repoUrl: 'https://github.com/test/repo.git',
|
||||
}))
|
||||
.rejects.toThrow('Clone failed');
|
||||
|
||||
// Verify that the project directory was cleaned up
|
||||
@@ -488,7 +491,10 @@ describe('ProjectsManager', () => {
|
||||
|
||||
try {
|
||||
// Attempt to clone a project
|
||||
await expect(projectsManager.cloneProject('test-project', 'https://github.com/test/repo.git'))
|
||||
await expect(projectsManager.cloneProject({
|
||||
name: 'test-project',
|
||||
repoUrl: 'https://github.com/test/repo.git',
|
||||
}))
|
||||
.rejects.toThrow('Clone failed');
|
||||
|
||||
// Should have logged a cleanup warning
|
||||
|
||||
@@ -494,7 +494,14 @@ export class ProjectsManager {
|
||||
}
|
||||
}
|
||||
|
||||
async cloneProject(name: string, repoUrl: string, customId?: string, options?: { depth?: number }): Promise<Project> {
|
||||
async cloneProject(options: {
|
||||
name: string;
|
||||
repoUrl: string;
|
||||
customId?: string;
|
||||
depth?: number;
|
||||
remote?: string;
|
||||
}): Promise<Project> {
|
||||
const { name, repoUrl, customId, depth, remote } = options;
|
||||
const id = customId || await this.generateUniqueProjectId(name);
|
||||
|
||||
// Check if project with this ID already exists when using custom ID
|
||||
@@ -512,7 +519,8 @@ export class ProjectsManager {
|
||||
dir: projectPath,
|
||||
url: repoUrl,
|
||||
singleBranch: true,
|
||||
depth: options?.depth, // Use depth if provided, otherwise clone full history
|
||||
depth, // Use depth if provided, otherwise clone full history
|
||||
remote, // Use remote if provided, otherwise defaults to 'origin'
|
||||
});
|
||||
|
||||
// Get filesystem stats for timestamps
|
||||
|
||||
+4
-1
@@ -156,7 +156,10 @@ export default function Clone() {
|
||||
const repoName = await extractRepoName(targetUrl);
|
||||
|
||||
// Clone the repository (Git class handles both regular Git URLs and Nostr URIs)
|
||||
const project = await projectsManager.cloneProject(repoName, targetUrl.trim());
|
||||
const project = await projectsManager.cloneProject({
|
||||
name: repoName,
|
||||
repoUrl: targetUrl.trim(),
|
||||
});
|
||||
|
||||
// Determine success message based on URL type
|
||||
const isNostrUri = targetUrl.startsWith('nostr://');
|
||||
|
||||
Reference in new issue
Block a user