Exemplo n.º 1
0
        static AppSettings()
        {
            ApplicationDataPath = new Lazy <string>(() =>
            {
                if (IsPortable())
                {
                    return(GetGitExtensionsDirectory());
                }
                else
                {
                    //Make applicationdatapath version independent
                    return(Application.UserAppDataPath.Replace(Application.ProductVersion, string.Empty));
                }
            }
                                                    );

            _SettingsContainer = new RepoDistSettings(null, GitExtSettingsCache.FromCache(SettingsFilePath));

            GitLog = new CommandLogger();

            if (!File.Exists(SettingsFilePath))
            {
                ImportFromRegistry();
            }
        }
        public void SetUp()
        {
            _executable = new MockExecutable();

            // Work around: When running unittest, Application.UserAppDataPath always points to
            // %APPDATA%Roaming\Microsoft Corporation\Microsoft.TestHost.x86
            // We need to correct it to %APPDATA%\GitExtensions\GitExtensions for v3 at least
            var userAppDataPath = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
            var settingPath     = Path.Combine(userAppDataPath, "GitExtensions\\GitExtensions\\GitExtensions.settings");
            RepoDistSettings settingContainer = new(null, GitExtSettingsCache.FromCache(settingPath), SettingLevel.Unknown);

            _appPath = settingContainer.GetString("gitcommand", "git.exe");

            // Execute process in GitExtension working directory, so that git will return success exit-code
            // git always return non-zero exit code when run git reset outside of git repository
            // NUnit working directory always default to MS test host
            var workingDir = Path.GetDirectoryName(Assembly.GetAssembly(typeof(ExecutableExtensionsTests)).Location);

            _gitExecutable = new Executable(_appPath, workingDir);
        }
Exemplo n.º 3
0
        static AppSettings()
        {
            ApplicationDataPath = new Lazy <string>(() =>
            {
                if (IsPortable())
                {
                    return(GetGitExtensionsDirectory());
                }
                else
                {
                    //Make applicationdatapath version independent
                    return(Application.UserAppDataPath.Replace(Application.ProductVersion, string.Empty));
                }
            }
                                                    );

            SettingsContainer = new SettingsContainer <RepoDistSettings>(null, GitExtSettingsCache.FromCache(SettingsFilePath));
            Version version = AppVersion;

            GitExtensionsVersionString = version.Major.ToString() + '.' + version.Minor.ToString();
            if (version.Build > 0)
            {
                GitExtensionsVersionString += '.' + version.Build.ToString();
            }
            if (!EnvUtils.RunningOnWindows())
            {
                PathSeparator      = '/';
                PathSeparatorWrong = '\\';
            }

            GitLog = new CommandLogger();

            if (!File.Exists(SettingsFilePath))
            {
                ImportFromRegistry();
            }
        }