예제 #1
0
        public void Arm_WhenIsNotArmed_ShouldArmIt()
        {
            var configPath        = Path.Combine(m_repositoryFolder, @".git\gitarmor\config");
            var preCommitHookPath = Path.Combine(m_repositoryFolder, @".git\hooks\pre-commit");

            A.CallTo(() => m_fs.Exists(configPath)).Returns(false);
            A.CallTo(() => m_fs.Exists(preCommitHookPath)).Returns(false);
            A.CallTo(() => m_app.GetApplicationDirectory()).Returns(@"C:\AppPath");

            m_repository.Arm();

            A.CallTo(() => m_repoConfigFactory.LoadOrCreate(m_repositoryFolder)).MustHaveHappened();
            A.CallTo(() => m_fs.Copy(@"C:\AppPath\Hooks\pre-commit", preCommitHookPath, false)).MustHaveHappened();
        }
예제 #2
0
        public void Arm()
        {
            if (IsArmed)
            {
                return;
            }

            var preComitHookPath = Path.Combine(m_repositoryFolder, @".git\hooks\pre-commit");

            if (m_files.Exists(preComitHookPath))
            {
                throw new HooksAlreadyExistsException();
            }

            m_repoConfigFactory.LoadOrCreate(m_repositoryFolder);

            var preCommitHookSourcePath = Path.Combine(m_application.GetApplicationDirectory(), @"Hooks\pre-commit");

            m_files.Copy(preCommitHookSourcePath, preComitHookPath);
        }