public virtual void RepositoryWithRootLevelSubmoduleRelativeRef() { ObjectId id = ObjectId.FromString("abcd1234abcd1234abcd1234abcd1234abcd1234"); string path = "sub"; FilePath dotGit = new FilePath(db.WorkTree, path + FilePath.separatorChar + Constants .DOT_GIT); if (!dotGit.GetParentFile().Exists()) { dotGit.GetParentFile().Mkdirs(); } FilePath modulesGitDir = new FilePath(db.Directory, "modules" + FilePath.separatorChar + path); new FileWriter(dotGit).Append("gitdir: " + "../" + Constants.DOT_GIT + "/modules/" + path).Close(); FileRepositoryBuilder builder = new FileRepositoryBuilder(); builder.SetWorkTree(new FilePath(db.WorkTree, path)); builder.Build().Create(); DirCache cache = db.LockDirCache(); DirCacheEditor editor = cache.Editor(); editor.Add(new _PathEdit_203(id, path)); editor.Commit(); SubmoduleWalk gen = SubmoduleWalk.ForIndex(db); NUnit.Framework.Assert.IsTrue(gen.Next()); NUnit.Framework.Assert.AreEqual(path, gen.GetPath()); NUnit.Framework.Assert.AreEqual(id, gen.GetObjectId()); NUnit.Framework.Assert.AreEqual(new FilePath(db.WorkTree, path), gen.GetDirectory ()); NUnit.Framework.Assert.IsNull(gen.GetConfigUpdate()); NUnit.Framework.Assert.IsNull(gen.GetConfigUrl()); NUnit.Framework.Assert.IsNull(gen.GetModulesPath()); NUnit.Framework.Assert.IsNull(gen.GetModulesUpdate()); NUnit.Framework.Assert.IsNull(gen.GetModulesUrl()); Repository subRepo = gen.GetRepository(); AddRepoToClose(subRepo); NUnit.Framework.Assert.IsNotNull(subRepo); NUnit.Framework.Assert.AreEqual(modulesGitDir, subRepo.Directory); NUnit.Framework.Assert.AreEqual(new FilePath(db.WorkTree, path), subRepo.WorkTree ); NUnit.Framework.Assert.IsFalse(gen.Next()); }
private static FileRepository GetRepository() { FileRepositoryBuilder fileRepositoryBuilder = new FileRepositoryBuilder(); _currentDirectory = Directory.GetCurrentDirectory(); //_currentDirectory = _debugRepoPath; FileRepository repository = null; try { fileRepositoryBuilder.FindGitDir(_currentDirectory); repository = fileRepositoryBuilder.Build(); } catch (System.ArgumentNullException) { Console.WriteLine("ERROR: Repo not found"); Environment.Exit(0); } return(repository); }
public virtual void ScanWithGitDirRef() { FileRepository repo1 = CreateWorkRepository(); FilePath dir = CreateTempDirectory("dir"); FilePath dotGit = new FilePath(dir, Constants.DOT_GIT); new FileWriter(dotGit).Append("gitdir: " + repo1.Directory.GetAbsolutePath()).Close (); FileRepositoryBuilder builder = new FileRepositoryBuilder(); builder.SetWorkTree(dir); builder.FindGitDir(dir); NUnit.Framework.Assert.AreEqual(repo1.Directory, builder.GetGitDir()); builder.SetMustExist(true); FileRepository repo2 = builder.Build(); NUnit.Framework.Assert.AreEqual(repo1.Directory, repo2.Directory); NUnit.Framework.Assert.AreEqual(dir, repo2.WorkTree); }
public virtual void RelativeGitDirRef() { FileRepository repo1 = CreateWorkRepository(); FilePath dir = new FilePath(repo1.WorkTree, "dir"); NUnit.Framework.Assert.IsTrue(dir.Mkdir()); FilePath dotGit = new FilePath(dir, Constants.DOT_GIT); new FileWriter(dotGit).Append("gitdir: ../" + Constants.DOT_GIT).Close(); FileRepositoryBuilder builder = new FileRepositoryBuilder(); builder.SetWorkTree(dir); builder.SetMustExist(true); FileRepository repo2 = builder.Build(); NUnit.Framework.Assert.AreEqual(repo1.Directory, repo2.Directory); NUnit.Framework.Assert.AreEqual(dir, repo2.WorkTree); }