public void MergeHooksDataThrowsOnFoundGVFSHooks()
 {
     Assert.Throws <HooksInstaller.HooksConfigurationException>(
         () => HooksInstaller.MergeHooksData(
             new string[] { "first", GVFSPlatform.Instance.Constants.GVFSHooksExecutableName },
             Filename,
             this.expectedAbsoluteGvfsHookPath));
 }
 public void MergeHooksDataThrowsOnFoundGSDHooks()
 {
     Assert.Throws<HooksInstaller.HooksConfigurationException>(
         () => HooksInstaller.MergeHooksData(
             new string[] { "first", GSDPlatform.Instance.Constants.GSDHooksExecutableName },
             Filename,
             GSDConstants.DotGit.Hooks.PreCommandHookName));
 }
        public void MergeHooksDataEmptyConfig()
        {
            string result = HooksInstaller.MergeHooksData(new string[] { }, Filename, GVFSConstants.DotGit.Hooks.PreCommandHookName);
            IEnumerable <string> resultLines = result
                                               .Split(new char[] { '\n', '\r' }, StringSplitOptions.RemoveEmptyEntries)
                                               .Where(line => !line.StartsWith("#"));

            resultLines.Single().ShouldEqual(this.expectedAbsoluteGvfsHookPath);
        }
        public void MergeHooksDataEmptyConfig()
        {
            string result = HooksInstaller.MergeHooksData(new string[] { }, Filename, GSDConstants.DotGit.Hooks.PreCommandHookName);
            IEnumerable<string> resultLines = result
                .Split(new char[] { '\n', '\r' }, StringSplitOptions.RemoveEmptyEntries)
                .Where(line => !line.StartsWith("#"));

            resultLines.Single().ShouldEqual(GSDPlatform.Instance.Constants.GSDHooksExecutableName);
        }
        public void MergeHooksDataDiscardBlankLines()
        {
            string result = HooksInstaller.MergeHooksData(new string[] { "first", "second", string.Empty, " " }, Filename, GVFSConstants.DotGit.Hooks.PreCommandHookName);
            IEnumerable <string> resultLines = result
                                               .Split(new char[] { '\n', '\r' }, StringSplitOptions.RemoveEmptyEntries)
                                               .Where(line => !line.StartsWith("#"));

            resultLines.Count().ShouldEqual(3);
            resultLines.ElementAt(0).ShouldEqual("first");
            resultLines.ElementAt(1).ShouldEqual("second");
            resultLines.ElementAt(2).ShouldEqual(this.expectedAbsoluteGvfsHookPath);
        }
示例#6
0
        public void MergeHooksDataPostCommandFirst()
        {
            string result = HooksInstaller.MergeHooksData(new string[] { "first", "second" }, Filename, GVFSConstants.DotGit.Hooks.PostCommandHookName);
            IEnumerable <string> resultLines = result
                                               .Split(new char[] { '\n', '\r' }, StringSplitOptions.RemoveEmptyEntries)
                                               .Where(line => !line.StartsWith("#"));

            resultLines.Count().ShouldEqual(3);
            resultLines.ElementAt(0).ShouldEqual(GVFSConstants.GVFSHooksExecutableName);
            resultLines.ElementAt(1).ShouldEqual("first");
            resultLines.ElementAt(2).ShouldEqual("second");
        }
示例#7
0
        private static string MergeHooks(GVFSContext context, string configSettingName, string hookName)
        {
            GitProcess configProcess = new GitProcess(context.Enlistment);
            string     filename;

            string[] defaultHooksLines = { };

            if (configProcess.TryGetFromConfig(configSettingName, forceOutsideEnlistment: true, value: out filename) && filename != null)
            {
                filename          = filename.Trim(' ', '\n');
                defaultHooksLines = File.ReadAllLines(filename);
            }

            return(HooksInstaller.MergeHooksData(defaultHooksLines, filename, hookName));
        }
示例#8
0
 public void MergeHooksDataThrowsOnFoundGVFSHooks()
 {
     Assert.Throws <HooksInstaller.HooksConfigurationException>(
         () => HooksInstaller.MergeHooksData(new string[] { "first", "gvfs.hooks.exe" }, Filename, GVFSConstants.DotGit.Hooks.PreCommandHookName));
 }