MCPcopy Create free account
hub / github.com/firebase/firebase-tools / getGitFolderPath

Function getGitFolderPath

src/init/features/hosting/github.ts:226–243  ·  view source on GitHub ↗

* Finds the folder that contains the .git folder * * For example, if the .git folder is /Users/sparky/projects/my-web-app/.git * This function will return /Users/sparky/projects/my-web-app * * Modeled after https://github.com/firebase/firebase-tools/blob/main/src/detectProjectRoot.ts * * @ret

()

Source from the content-addressed store, hash-verified

224 * @return {string} The folder that contains the .git folder
225 */
226function getGitFolderPath(): string {
227 const commandDir = process.cwd();
228 let projectRootDir = commandDir;
229
230 while (!fs.existsSync(path.resolve(projectRootDir, ".git"))) {
231 const parentDir = path.dirname(projectRootDir);
232
233 // Stop searching if we get to the root of the filesystem
234 if (parentDir === projectRootDir) {
235 logBullet(`Didn't detect a .git folder. Assuming ${commandDir} is the project root.`);
236 return commandDir;
237 }
238 projectRootDir = parentDir;
239 }
240
241 logBullet(`Detected a .git folder at ${projectRootDir}`);
242 return projectRootDir;
243}
244
245function defaultGithubRepo(): string | undefined {
246 const gitConfigPath = path.join(GIT_DIR, "config");

Callers 1

initGitHubFunction · 0.85

Calls 1

logBulletFunction · 0.90

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…