1 /**
2 look for the .git repo in "test/repo/a/".
3 The .git directory will be found one dir up, and will
4 contain the line 'gitdir: ../../.git/modules/test/repo'.
5 The function will expand this line and return the true
6 repository location.
7 */
8 string path = buildPath(_testRepo.dirName, "a");
9 string repoPath = discoverRepo(path);
10 assert(repoPath.relativePath.toPosixPath == ".git/modules/test/repo");
11
12 // verify the repo can be opened
13 auto repo = openRepository(repoPath);
// ceiling dir is found before any git repository
string path = buildPath(_testRepo.dirName, "a");
string[] ceils = [_testRepo.dirName.absolutePath.buildNormalizedPath];
assertThrown!GitException(discoverRepo(path, ceils));
// all ceiling paths must be absolute
string[] ceils = ["../.."];
assertThrown!AssertError(discoverRepo(_testRepo.dirName, ceils));
Discover a git repository and return its path if found.
The lookup starts from startPath and continues searching across parent directories. The lookup stops when one of the following becomes true:
Parameters:
startPath: The base path where the lookup starts.
ceilingDirs: An array of absolute paths which are symbolic-link-free. If any of these paths are reached a GitException will be thrown.
acrossFS: If equal to AcrossFS.yes the lookup will continue when a filesystem device change is detected while exploring parent directories, otherwise GitException is thrown.
Note: The lookup always performs on startPath even if startPath is listed in ceilingDirs.