Ejemplo n.º 1
0
        public virtual void TestExecutableRetention()
        {
            StoredConfig config = ((FileBasedConfig)db.GetConfig());

            config.SetBoolean(ConfigConstants.CONFIG_CORE_SECTION, null, ConfigConstants.CONFIG_KEY_FILEMODE
                              , true);
            config.Save();
            FS     executableFs = new _FS_87();
            Git    git          = Git.Open(db.Directory, executableFs);
            string path         = "a.txt";

            WriteTrashFile(path, "content");
            git.Add().AddFilepattern(path).Call();
            RevCommit commit1 = git.Commit().SetMessage("commit").Call();
            TreeWalk  walk    = TreeWalk.ForPath(db, path, commit1.Tree);

            NUnit.Framework.Assert.IsNotNull(walk);
            NUnit.Framework.Assert.AreEqual(FileMode.EXECUTABLE_FILE, walk.GetFileMode(0));
            FS nonExecutableFs = new _FS_132();

            config = ((FileBasedConfig)db.GetConfig());
            config.SetBoolean(ConfigConstants.CONFIG_CORE_SECTION, null, ConfigConstants.CONFIG_KEY_FILEMODE
                              , false);
            config.Save();
            Git git2 = Git.Open(db.Directory, nonExecutableFs);

            WriteTrashFile(path, "content2");
            RevCommit commit2 = git2.Commit().SetOnly(path).SetMessage("commit2").Call();

            walk = TreeWalk.ForPath(db, path, commit2.Tree);
            NUnit.Framework.Assert.IsNotNull(walk);
            NUnit.Framework.Assert.AreEqual(FileMode.EXECUTABLE_FILE, walk.GetFileMode(0));
        }
Ejemplo n.º 2
0
        public virtual void TestOpen()
        {
            Git git = Git.Open(db.Directory);

            NUnit.Framework.Assert.AreEqual(1, git.BranchList().Call().Count);
            git = Git.Open(bareRepo.Directory);
            NUnit.Framework.Assert.AreEqual(1, git.BranchList().SetListMode(ListBranchCommand.ListMode
                                                                            .ALL).Call().Count);
            git = Git.Open(db.WorkTree);
            NUnit.Framework.Assert.AreEqual(1, git.BranchList().SetListMode(ListBranchCommand.ListMode
                                                                            .ALL).Call().Count);
            try
            {
                Git.Open(db.ObjectsDirectory);
                NUnit.Framework.Assert.Fail("Expected exception has not been thrown");
            }
            catch (RepositoryNotFoundException)
            {
            }
        }