Files
windmill/cli/src/utils/git.ts
T
Alexander Petricandellipsis-dev[bot] cb649b2689 feat: git sync v2 + cli git_branches support (#6327)
* adding branch support

* gitsync settings refactor

* promotionOverride

* require branches and initialize them

* branches -> git_branches

* profiles

* format

* format

* only warn instead of error when branches: not set in git context

* error handling

* formatting

* modal job handling improvement

* respect --yes

* logging + apply effective settings

* nit

* ui updates

* npm check

* Update frontend/src/lib/components/git_sync/PullWorkspaceModal.svelte

Co-authored-by: ellipsis-dev[bot] <65095814+ellipsis-dev[bot]@users.noreply.github.com>

* hubpaths

---------

Co-authored-by: ellipsis-dev[bot] <65095814+ellipsis-dev[bot]@users.noreply.github.com>
2025-08-06 23:03:03 +00:00

30 lines
690 B
TypeScript

import { log } from "../../deps.ts";
import { execSync } from "node:child_process";
export function getCurrentGitBranch(): string | null {
try {
const result = execSync("git rev-parse --abbrev-ref HEAD", {
encoding: "utf8",
stdio: "pipe"
});
const branch = result.trim();
return branch || null;
} catch (error) {
log.debug(`Failed to get Git branch: ${error}`);
return null;
}
}
export function isGitRepository(): boolean {
try {
execSync("git rev-parse --git-dir", {
encoding: "utf8",
stdio: "pipe"
});
return true;
} catch (error) {
log.debug(`Failed to check Git repository: ${error}`);
return false;
}
}