mirror of
https://github.com/rohitg00/skillkit.git
synced 2026-11-18 18:04:26 +00:00
fix: sparse checkout includes subpath so skill discovery works
cloneRepo now accepts a subpath option. When set, sparse-checkout includes both the subpath itself and SKILL_DISCOVERY_PATHS under it. All four providers pass their parsed subpath through to cloneRepo. Without this, sparse checkout would skip the subpath directory and discoverSkills would find nothing.
This commit is contained in:
@@ -19,6 +19,7 @@ export interface CloneOptions {
|
||||
depth?: number;
|
||||
branch?: string;
|
||||
ssh?: boolean;
|
||||
subpath?: string;
|
||||
onProgress?: (message: string) => void;
|
||||
}
|
||||
|
||||
@@ -100,11 +101,16 @@ export async function cloneRepo(
|
||||
stdio: ['pipe', 'pipe', 'pipe'],
|
||||
});
|
||||
|
||||
const sparsePaths = SKILL_DISCOVERY_PATHS.filter((p) => !p.includes('/'));
|
||||
const deepPaths = SKILL_DISCOVERY_PATHS.filter((p) => p.includes('/'));
|
||||
const sparsePaths = [...SKILL_DISCOVERY_PATHS];
|
||||
if (options.subpath) {
|
||||
sparsePaths.push(options.subpath);
|
||||
for (const dp of SKILL_DISCOVERY_PATHS) {
|
||||
sparsePaths.push(`${options.subpath}/${dp}`);
|
||||
}
|
||||
}
|
||||
execFileSync(
|
||||
'git',
|
||||
['-C', tempDir, 'sparse-checkout', 'set', ...sparsePaths, ...deepPaths],
|
||||
['-C', tempDir, 'sparse-checkout', 'set', ...sparsePaths],
|
||||
{ stdio: ['pipe', 'pipe', 'pipe'] },
|
||||
);
|
||||
|
||||
|
||||
@@ -75,7 +75,7 @@ export class BitbucketProvider implements GitProviderAdapter {
|
||||
const tempDir = join(tmpdir(), `skillkit-${randomUUID()}`);
|
||||
|
||||
try {
|
||||
await cloneRepo(cloneUrl, tempDir, options);
|
||||
await cloneRepo(cloneUrl, tempDir, { ...options, subpath });
|
||||
|
||||
const searchDir = subpath ? join(tempDir, subpath) : tempDir;
|
||||
const skills = discoverSkills(searchDir);
|
||||
|
||||
@@ -68,7 +68,7 @@ export class GitHubProvider implements GitProviderAdapter {
|
||||
const tempDir = join(tmpdir(), `skillkit-${randomUUID()}`);
|
||||
|
||||
try {
|
||||
await cloneRepo(cloneUrl, tempDir, options);
|
||||
await cloneRepo(cloneUrl, tempDir, { ...options, subpath });
|
||||
|
||||
const searchDir = subpath ? join(tempDir, subpath) : tempDir;
|
||||
const skills = discoverSkills(searchDir);
|
||||
|
||||
@@ -73,7 +73,7 @@ export class GitLabProvider implements GitProviderAdapter {
|
||||
const tempDir = join(tmpdir(), `skillkit-${randomUUID()}`);
|
||||
|
||||
try {
|
||||
await cloneRepo(cloneUrl, tempDir, options);
|
||||
await cloneRepo(cloneUrl, tempDir, { ...options, subpath });
|
||||
|
||||
const searchDir = subpath ? join(tempDir, subpath) : tempDir;
|
||||
const skills = discoverSkills(searchDir);
|
||||
|
||||
@@ -65,7 +65,7 @@ export class SkillsShProvider implements GitProviderAdapter {
|
||||
const tempDir = join(tmpdir(), `skillkit-skillssh-${randomUUID()}`);
|
||||
|
||||
try {
|
||||
await cloneRepo(cloneUrl, tempDir, options);
|
||||
await cloneRepo(cloneUrl, tempDir, { ...options, subpath });
|
||||
|
||||
const searchDir = subpath ? join(tempDir, subpath) : tempDir;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user