Exemple #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));
        }
		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));
		}