diff options
| author | JeromeJu <[email protected]> | 2025-07-31 18:14:22 -0400 |
|---|---|---|
| committer | GitHub <[email protected]> | 2025-07-31 22:14:22 +0000 |
| commit | 574015edd91a651b0a4770e595be7ff10d67e5ab (patch) | |
| tree | 8283bdc1e4f37ae3b034234752b7b51ca62f20f5 /packages/cli/src/utils/gitUtils.ts | |
| parent | f9a05401c1d2d93d1251d3ebf2c079ee1f4ba8df (diff) | |
feat: Implement /setup-github command (#5069)
Diffstat (limited to 'packages/cli/src/utils/gitUtils.ts')
| -rw-r--r-- | packages/cli/src/utils/gitUtils.ts | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/packages/cli/src/utils/gitUtils.ts b/packages/cli/src/utils/gitUtils.ts new file mode 100644 index 00000000..d510008c --- /dev/null +++ b/packages/cli/src/utils/gitUtils.ts @@ -0,0 +1,26 @@ +/** + * @license + * Copyright 2025 Google LLC + * SPDX-License-Identifier: Apache-2.0 + */ + +import { execSync } from 'child_process'; + +/** + * Checks if a directory is within a git repository hosted on GitHub. + * @returns true if the directory is in a git repository with a github.com remote, false otherwise + */ +export function isGitHubRepository(): boolean { + try { + const remotes = execSync('git remote -v', { + encoding: 'utf-8', + }); + + const pattern = /github\.com/; + + return pattern.test(remotes); + } catch (_error) { + // If any filesystem error occurs, assume not a git repo + return false; + } +} |
