UNPKG

repomix

Version:

A tool to pack repository contents to single file for AI consumption

41 lines 1.93 kB
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } return new (P || (P = Promise))(function (resolve, reject) { function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; import { RepomixError } from '../../shared/errorHandle.js'; import { logger } from '../../shared/logger.js'; import { execLsRemote, validateGitUrl } from './gitCommand.js'; export const getRemoteRefs = (url_1, ...args_1) => __awaiter(void 0, [url_1, ...args_1], void 0, function* (url, deps = { execLsRemote, }) { validateGitUrl(url); try { const stdout = yield deps.execLsRemote(url); // Extract ref names from the output // Format is: hash\tref_name const refs = stdout .split('\n') .filter(Boolean) .map((line) => { // Skip the hash part and extract only the ref name const parts = line.split('\t'); if (parts.length < 2) return ''; // Remove 'refs/heads/' or 'refs/tags/' prefix return parts[1].replace(/^refs\/(heads|tags)\//, ''); }) .filter(Boolean); logger.trace(`Found ${refs.length} refs in repository: ${url}`); return refs; } catch (error) { logger.trace('Failed to get remote refs:', error.message); throw new RepomixError(`Failed to get remote refs: ${error.message}`); } }); //# sourceMappingURL=gitRemoteHandle.js.map