예제 #1
0
파일: Program.cs 프로젝트: xnohat/VFSForGit
        private static void VerifyRenameDetectionSettings(string[] args)
        {
            string srcRoot = Path.Combine(enlistmentRoot, GVFSConstants.WorkingDirectoryRootName);

            if (File.Exists(Path.Combine(srcRoot, GVFSConstants.DotGit.MergeHead)) ||
                File.Exists(Path.Combine(srcRoot, GVFSConstants.DotGit.RevertHead)))
            {
                // If no-renames is specified, avoid reading config.
                if (!args.Contains("--no-renames"))
                {
                    // To behave properly, this needs to check for the status.renames setting the same
                    // way that git does including global and local config files, setting inheritance from
                    // diff.renames, etc.  This is probably best accomplished by calling "git config --get status.renames"
                    // to ensure we are getting the correct value and then checking for "true" (rather than
                    // just existance like below).
                    Dictionary <string, GitConfigSetting> statusConfig = GitConfigHelper.GetSettings(
                        File.ReadAllLines(Path.Combine(srcRoot, GVFSConstants.DotGit.Config)),
                        "test");

                    if (!statusConfig.ContainsKey("renames"))
                    {
                        ExitWithError(
                            "git status requires rename detection to be disabled during a merge or revert conflict.",
                            "Run 'git status --no-renames'");
                    }
                }
            }
        }
예제 #2
0
        public void GetSettingsTest()
        {
            string fileContents = @"
[core]
    gvfs = true
[gc]
    auto = 0
[section]
    key1 = 1
    key2 = 2
    key3 = 3
[notsection]
    keyN1 = N1
    keyN2 = N2
    keyN3 = N3
[section]
[section]
    key4 = 4
    key5 = 5
[section]
    key6 = 6
    key7 =
         = emptyKey";
            string filename     = Guid.NewGuid().ToString();

            File.WriteAllText(filename, fileContents);

            Dictionary <string, GitConfigSetting> result = GitConfigHelper.GetSettings(filename, "Section");

            int expectedCount = 7; // empty keys will not be included.

            result.Count.ShouldEqual(expectedCount);

            // Verify keyN = N
            for (int i = 1; i <= expectedCount - 1; i++)
            {
                result["key" + i.ToString()].Values.ShouldContain(v => v == i.ToString());
            }

            // Verify empty value
            result["key7"].Values.Single().ShouldEqual(string.Empty);
        }
예제 #3
0
        private static void VerifyRenameDetectionSettings(string[] args)
        {
            string srcRoot = Path.Combine(enlistmentRoot, GVFSConstants.WorkingDirectoryRootName);

            if (File.Exists(Path.Combine(srcRoot, GVFSConstants.DotGit.MergeHead)) ||
                File.Exists(Path.Combine(srcRoot, GVFSConstants.DotGit.RevertHead)))
            {
                // If no-renames and no-breaks are specified, avoid reading config.
                if (!args.Contains("--no-renames") || !args.Contains("--no-breaks"))
                {
                    Dictionary <string, GitConfigSetting> statusConfig = GitConfigHelper.GetSettings(
                        File.ReadAllLines(Path.Combine(srcRoot, GVFSConstants.DotGit.Config)),
                        "status");

                    if (!IsRunningWithParamOrSetting(args, statusConfig, "--no-renames", "renames") ||
                        !IsRunningWithParamOrSetting(args, statusConfig, "--no-breaks", "breaks"))
                    {
                        ExitWithError(
                            "git status requires rename detection to be disabled during a merge or revert conflict.",
                            "Run 'git status --no-renames --no-breaks'");
                    }
                }
            }
        }