MCPcopy
hub / github.com/21st-dev/1code / getRepositoryState

Function getRepositoryState

src/main/lib/git/git-factory.ts:242–267  ·  view source on GitHub ↗
(worktreePath: string)

Source from the content-addressed store, hash-verified

240 * Checks if the repository is in a rebase or merge state.
241 */
242export async function getRepositoryState(worktreePath: string): Promise<{
243 isRebasing: boolean;
244 isMerging: boolean;
245 isCherryPicking: boolean;
246 isReverting: boolean;
247 hasConflicts: boolean;
248}> {
249 const git = createGit(worktreePath);
250 const status = await git.status();
251
252 // Check for state indicators via git status
253 const isRebasing = status.current?.includes("(no branch") || false;
254 const hasConflicts = status.conflicted.length > 0;
255
256 // More accurate state detection via git internals
257 const { existsSync } = await import("fs");
258 const gitDir = join(worktreePath, ".git");
259
260 return {
261 isRebasing: existsSync(join(gitDir, "rebase-merge")) || existsSync(join(gitDir, "rebase-apply")),
262 isMerging: existsSync(join(gitDir, "MERGE_HEAD")),
263 isCherryPicking: existsSync(join(gitDir, "CHERRY_PICK_HEAD")),
264 isReverting: existsSync(join(gitDir, "REVERT_HEAD")),
265 hasConflicts,
266 };
267}

Callers 1

Calls 1

createGitFunction · 0.85

Tested by

no test coverage detected