feat: git sync improvements (#6182)
* init checkpoint * ui second pass... * round 1 backend + saving settings + detecting changes... * checkpoint * fix openapi * saving + correct wmill.yaml diff * cli refactor * cli and tests refactor done * cli multi workspace support * cli support skip core types to align with ui * new test framework * sqlx * openapi spec * frontend * sync + settings changes * some fixes * some fixes * security: Remove hardcoded EE license key, use environment variable only - Remove hardcoded license key from containerized test backend - Environment variable EE_LICENSE_KEY now required for EE features - License key no longer stored in database during tests * sqlx * tests * fixing tests * fix tests * checkpoint * checkpoint * cli build * frontend - cli exchange * settings match * ee repo ref * npm check * openapi * tests * checkpoint * cli + tests * reset to preview on changes * merge issue ee * cleanup * hubscript * simplifications * ee repo ref * cli fixes * fix sync and add tests * extra test * git sync settings / key change aware * ee-repo ref * ee-repo ref * ee repo ref * ee ref * review 1 * ee ref * Update frontend/src/lib/components/PullGitRepoPopover.svelte Co-authored-by: ellipsis-dev[bot] <65095814+ellipsis-dev[bot]@users.noreply.github.com> * Update frontend/src/routes/(root)/(logged)/workspace_settings/+page.svelte Co-authored-by: ellipsis-dev[bot] <65095814+ellipsis-dev[bot]@users.noreply.github.com> * ee ref * remove extra includes from ui --------- Co-authored-by: ellipsis-dev[bot] <65095814+ellipsis-dev[bot]@users.noreply.github.com>
This commit is contained in:
47
cli/utils.ts
47
cli/utils.ts
@@ -149,4 +149,51 @@ export function printSync(input: string | Uint8Array, to = Deno.stdout) {
|
||||
while (bytesWritten < bytes.length) {
|
||||
bytesWritten += to.writeSync(bytes.subarray(bytesWritten))
|
||||
}
|
||||
}
|
||||
|
||||
// Repository interface for shared selection logic
|
||||
export interface Repository {
|
||||
git_repo_resource_path: string;
|
||||
}
|
||||
|
||||
// Shared repository selection logic
|
||||
export async function selectRepository<T extends Repository>(
|
||||
repositories: T[],
|
||||
operation?: string
|
||||
): Promise<T> {
|
||||
if (repositories.length === 0) {
|
||||
throw new Error("No git-sync repositories configured in workspace");
|
||||
}
|
||||
|
||||
if (repositories.length === 1) {
|
||||
const repoPath = repositories[0].git_repo_resource_path.replace(/^\$res:/, "");
|
||||
log.info(`Using repository: ${repoPath}`);
|
||||
return repositories[0];
|
||||
}
|
||||
|
||||
// Check if we're in a non-interactive environment
|
||||
const isInteractive = Deno.stdin.isTerminal() && Deno.stdout.isTerminal();
|
||||
|
||||
if (!isInteractive) {
|
||||
const repoPaths = repositories.map(r => r.git_repo_resource_path.replace(/^\$res:/, ""));
|
||||
throw new Error(`Multiple repositories found: ${repoPaths.join(', ')}. Use --repository to specify which one to ${operation || 'use'}.`);
|
||||
}
|
||||
|
||||
// Import Select dynamically to avoid dependency issues
|
||||
const { Select } = await import("./deps.ts");
|
||||
|
||||
console.log(`\nMultiple repositories found. Please select which repository to ${operation || 'use'}:\n`);
|
||||
|
||||
const selectedRepo = await Select.prompt({
|
||||
message: `Select repository for ${operation || 'operation'}:`,
|
||||
options: repositories.map((repo, index) => {
|
||||
const displayPath = repo.git_repo_resource_path.replace(/^\$res:/, "");
|
||||
return {
|
||||
name: `${index + 1}. ${displayPath}`,
|
||||
value: repo.git_repo_resource_path
|
||||
};
|
||||
})
|
||||
});
|
||||
|
||||
return repositories.find((r) => r.git_repo_resource_path === selectedRepo)!;
|
||||
}
|
||||
Reference in New Issue
Block a user