blob: d510008c708539260ace0e9a77f4f13dbe13741d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
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;
}
}
|