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_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. }
/** * Wrap a repository with test building tools. * * @param db * the test repository to write into. * @param rw * the RevObject pool to use for object lookup. * @throws Exception */ public TestRepository(global::GitSharp.Core.Repository db, CoreRevWalk rw) { this.db = db; this.pool = rw; this.writer = new ObjectWriter(db); this.now = 1236977987000L; }
public override void setUp() { base.setUp(); diskRepo = createBareRepository(); refdir = (RefDirectory)diskRepo.RefDatabase; repo = new TestRepository(diskRepo); A = repo.commit().create(); B = repo.commit(repo.getRevWalk().parseCommit(A)); v1_0 = repo.tag("v1_0", B); repo.getRevWalk().parseBody(v1_0); }
public override void setUp() { base.setUp(); diskRepo = createBareRepository(); refdir = (RefDirectory)diskRepo.RefDatabase; repo = new TestRepository(diskRepo); A = repo.commit().create(); B = repo.commit(repo.getRevWalk().parseCommit(A)); v1_0 = repo.tag("v1_0", B); repo.getRevWalk().parseBody(v1_0); }
public void test002_WriteEmptyTree() { // One of our test packs contains the empty tree object. If the pack is // open when we Create it we won't write the object file out as a loose // object (as it already exists in the pack). // global::GitSharp.Core.Repository newdb = createBareRepository(); var t = new global::GitSharp.Core.Tree(newdb); t.Accept(new WriteTree(trash, newdb), TreeEntry.MODIFIED_ONLY); Assert.AreEqual("4b825dc642cb6eb9a060e54bf8d69288fbee4904", t.Id.Name); var o = new FileInfo(newdb.Directory + "/objects/4b/825dc642cb6eb9a060e54bf8d69288fbee4904"); Assert.IsTrue(o.IsFile(), "Exists " + o); Assert.IsTrue(o.IsReadOnly, "Read-only " + o); }
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 testTreeWalk_LsFiles() { global::GitSharp.Core.Repository db = createBareRepository(); List <CGitIndexRecord> ls = ReadLsFiles(); var dc = new DirCache(_index); Assert.AreEqual(0, dc.getEntryCount()); dc.read(); Assert.AreEqual(ls.Count, dc.getEntryCount()); var rItr = ls.GetEnumerator(); var tw = new TreeWalk(db); tw.reset(); tw.Recursive = true; tw.addTree(new DirCacheIterator(dc)); while (rItr.MoveNext()) { Assert.IsTrue(tw.next()); var dcItr = tw.getTree <DirCacheIterator>(0, typeof(DirCacheIterator)); Assert.IsNotNull(dcItr); AssertAreEqual(rItr.Current, dcItr.getDirCacheEntry()); } }
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); } }
public void test000_openRepoBadArgs() { var e = AssertHelper.Throws <ArgumentException>(() => { using (var r = new global::GitSharp.Core.Repository(null, null)) { } }); Assert.AreEqual("Either GIT_DIR or GIT_WORK_TREE must be passed to Repository constructor", e.Message); }
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_openRepoBadArgs() { var e = AssertHelper.Throws<ArgumentException>(() => { using (var r = new global::GitSharp.Core.Repository(null, null)) { } }); Assert.AreEqual("Either GIT_DIR or GIT_WORK_TREE must be passed to Repository constructor", e.Message); }
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); } }
/** * Wrap a repository with test building tools. * * @param db * the test repository to write into. * @throws Exception */ public TestRepository(global::GitSharp.Core.Repository db) : this(db, new CoreRevWalk(db)) { }
public MockRefWriter(global::GitSharp.Core.Repository db, IEnumerable <global::GitSharp.Core.Ref> refs) : base(refs) { _db = db; }