public void test000_openrepo_alternate_index_file_and_objdirs() { DirectoryInfo repo1Parent = PathUtil.CombineDirectoryPath(trash.Parent, "r1"); FileInfo indexFile = PathUtil.CombineFilePath(trash, "idx"); DirectoryInfo objDir = PathUtil.CombineDirectoryPath(trash, "../obj"); DirectoryInfo[] altObjDirs = new[] { db.ObjectsDirectory }; using (global::GitSharp.Core.Repository repo1initial = new global::GitSharp.Core.Repository(PathUtil.CombineDirectoryPath(repo1Parent, Constants.DOT_GIT))) { repo1initial.Create(); } DirectoryInfo theDir = PathUtil.CombineDirectoryPath(repo1Parent, Constants.DOT_GIT); using (global::GitSharp.Core.Repository r = new global::GitSharp.Core.Repository(theDir, null, objDir, altObjDirs, indexFile)) { assertEqualsPath(theDir, r.Directory); assertEqualsPath(theDir.Parent, r.WorkingDirectory); assertEqualsPath(indexFile, r.getIndexFile()); assertEqualsPath(objDir, r.ObjectsDirectory); Assert.IsNotNull(r.MapCommit("6db9c2ebf75590eef973081736730a9ea169a0c4")); // Must close or the default repo pack files created by this test gets // locked via the alternate object directories on Windows. r.Close(); } GC.Collect(); // To be removed once the repository resource releasing is fixed. }
public void test000_openrepo_default_gitDirSet() { DirectoryInfo repo1Parent = PathUtil.CombineDirectoryPath(trash.Parent, "r1"); using (global::GitSharp.Core.Repository repo1initial = new global::GitSharp.Core.Repository(PathUtil.CombineDirectoryPath(repo1Parent, Constants.DOT_GIT))) { repo1initial.Create(); } DirectoryInfo theDir = PathUtil.CombineDirectoryPath(repo1Parent, Constants.DOT_GIT); using (global::GitSharp.Core.Repository r = new global::GitSharp.Core.Repository(theDir, null)) { assertEqualsPath(theDir, r.Directory); assertEqualsPath(repo1Parent, r.WorkingDirectory); assertEqualsPath(PathUtil.CombineFilePath(theDir, "index"), r.getIndexFile()); assertEqualsPath(PathUtil.CombineDirectoryPath(theDir, "objects"), r.ObjectsDirectory); } }
public void test000_openrepo_default_relative_workdirconfig() { DirectoryInfo repo1Parent = PathUtil.CombineDirectoryPath(trash.Parent, "r1"); DirectoryInfo workdir = PathUtil.CombineDirectoryPath(trash.Parent, "rw"); workdir.Mkdirs(); using (global::GitSharp.Core.Repository repo1initial = new global::GitSharp.Core.Repository(PathUtil.CombineDirectoryPath(repo1Parent, Constants.DOT_GIT))) { repo1initial.Create(); repo1initial.Config.setString("core", null, "worktree", "../../rw"); repo1initial.Config.save(); } DirectoryInfo theDir = PathUtil.CombineDirectoryPath(repo1Parent, Constants.DOT_GIT); using (global::GitSharp.Core.Repository r = new global::GitSharp.Core.Repository(theDir, null)) { assertEqualsPath(theDir, r.Directory); assertEqualsPath(workdir, r.WorkingDirectory); assertEqualsPath(PathUtil.CombineFilePath(theDir, "index"), r.getIndexFile()); assertEqualsPath(PathUtil.CombineDirectoryPath(theDir, "objects"), r.ObjectsDirectory); } }