gitset
Version:
Enhanced git init with user configuration management
105 lines • 2.84 kB
TypeScript
/**
* Result of a Git command execution
*/
export interface GitCommandResult {
success: boolean;
stdout: string;
stderr: string;
exitCode: number;
}
/**
* Optimized Git command executor with caching and retry logic
*/
export declare class GitCommandExecutor {
private static cache;
private static readonly DEFAULT_TTL;
private static readonly MAX_RETRIES;
private static readonly RETRY_DELAY;
/**
* Execute a Git command with caching support
*/
static execute(args: string[], options?: {
cwd?: string;
timeout?: number;
cacheable?: boolean;
ttl?: number;
retries?: number;
}): Promise<GitCommandResult>;
/**
* Execute command with retry logic
*/
private static executeWithRetry;
/**
* Execute a single Git command
*/
private static executeSingle;
/**
* Generate cache key for command and options
*/
private static generateCacheKey;
/**
* Get result from cache if valid
*/
private static getFromCache;
/**
* Store result in cache
*/
private static setCache;
/**
* Clean up expired cache entries
*/
private static cleanupCache;
/**
* Check if error should not be retried
*/
private static isNonRetryableError;
/**
* Delay execution for specified milliseconds
*/
private static delay;
/**
* Clear all cached results
*/
static clearCache(): void;
/**
* Get cache statistics
*/
static getCacheStats(): {
size: number;
keys: string[];
};
/**
* Common Git commands with pre-configured caching
*/
static readonly commands: {
/**
* Get Git version (cacheable for 1 hour)
*/
getVersion: () => Promise<GitCommandResult>;
/**
* Get global user name (cacheable for 5 minutes)
*/
getGlobalUserName: () => Promise<GitCommandResult>;
/**
* Get global user email (cacheable for 5 minutes)
*/
getGlobalUserEmail: () => Promise<GitCommandResult>;
/**
* Initialize repository (not cacheable)
*/
init: (directory: string) => Promise<GitCommandResult>;
/**
* Set local user name (not cacheable)
*/
setLocalUserName: (directory: string, name: string) => Promise<GitCommandResult>;
/**
* Set local user email (not cacheable)
*/
setLocalUserEmail: (directory: string, email: string) => Promise<GitCommandResult>;
/**
* Check if directory is a Git repository (cacheable for 1 minute)
*/
isRepository: (directory: string) => Promise<GitCommandResult>;
};
}
//# sourceMappingURL=git-command-executor.d.ts.map