@pimzino/claude-code-spec-workflow
Version:
Automated workflows for Claude Code. Includes spec-driven development (Requirements → Design → Tasks → Implementation) with intelligent task execution, optional steering documents and streamlined bug fix workflow (Report → Analyze → Fix → Verify). We have
69 lines • 2.79 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.GitUtils = void 0;
const simple_git_1 = __importDefault(require("simple-git"));
class GitUtils {
static async getGitInfo(projectPath) {
const info = {};
try {
const git = (0, simple_git_1.default)(projectPath);
// Check if it's a git repository
const isRepo = await git.checkIsRepo();
if (!isRepo) {
return info;
}
// Get current branch
const status = await git.status();
info.branch = status.current || undefined;
// Get remote origin URL
try {
const remotes = await git.getRemotes(true);
const origin = remotes.find((r) => r.name === 'origin');
if (origin?.refs?.fetch) {
info.remoteUrl = origin.refs.fetch;
// Convert to GitHub URL if it's a git URL
info.githubUrl = this.convertToGithubUrl(info.remoteUrl) || undefined;
}
}
catch {
// No remote configured
}
}
catch {
// Not a git repository or git not available
}
return info;
}
static convertToGithubUrl(remoteUrl) {
if (!remoteUrl)
return undefined;
// Handle SSH format: git@github.com:user/repo.git
if (remoteUrl.startsWith('git@github.com:')) {
const path = remoteUrl.slice('git@github.com:'.length).replace(/\.git$/, '');
return `https://github.com/${path}`;
}
// Handle HTTPS format: https://github.com/user/repo.git
if (remoteUrl.startsWith('https://github.com/')) {
return remoteUrl.replace(/\.git$/, '');
}
// Handle other Git hosting services
const gitHostPatterns = [
{ pattern: /git@gitlab\.com:(.+)\.git/, replacement: 'https://gitlab.com/$1' },
{ pattern: /https:\/\/gitlab\.com\/(.+)\.git/, replacement: 'https://gitlab.com/$1' },
{ pattern: /git@bitbucket\.org:(.+)\.git/, replacement: 'https://bitbucket.org/$1' },
{ pattern: /https:\/\/bitbucket\.org\/(.+)\.git/, replacement: 'https://bitbucket.org/$1' },
];
for (const { pattern, replacement } of gitHostPatterns) {
const match = remoteUrl.match(pattern);
if (match) {
return remoteUrl.replace(pattern, replacement);
}
}
return undefined;
}
}
exports.GitUtils = GitUtils;
//# sourceMappingURL=git.js.map