private async Task InstallCommitMsgHookAsync()
        {
            await _mainForm.SwitchToMainThreadAsync();

            var settings = GerritSettings.Load(_mainForm, _gitUiCommands.GitModule);

            if (settings == null)
            {
                return;
            }

            string path = Path.Combine(
                _gitUiCommands.GitModule.ResolveGitInternalPath("hooks"),
                "commit-msg");

            string content;

            try
            {
                content = await DownloadFromScpAsync(settings);
            }
            catch
            {
                content = null;
            }

            await _mainForm.SwitchToMainThreadAsync();

            if (content == null)
            {
                MessageBox.Show(
                    _mainForm,
                    _installCommitMsgHookFailed.Text,
                    _installCommitMsgHookShortText.Text,
                    MessageBoxButtons.OK,
                    MessageBoxIcon.Error);
            }
            else
            {
                File.WriteAllText(path, content);

                // Update the cache.

                HaveValidCommitMsgHook(_gitUiCommands.GitModule, true);
            }
        }
        protected override void OnLoad(EventArgs e)
        {
            if (DesignMode)
            {
                return;
            }

            Settings = GerritSettings.Load(Module);

            if (Settings == null)
            {
                Dispose();
                return;
            }

            base.OnLoad(e);
        }
Beispiel #3
0
        private void InstallCommitMsgHook()
        {
            var settings = GerritSettings.Load(_mainForm, _gitUiCommands.GitModule);

            if (settings == null)
            {
                return;
            }

            string path = Path.Combine(
                _gitUiCommands.GitModule.GetGitDirectory(),
                "hooks",
                "commit-msg"
                );

            string content;

            try
            {
                content = DownloadFromScp(settings);
            }
            catch
            {
                content = null;
            }

            if (content == null)
            {
                MessageBox.Show(
                    _mainForm,
                    _installCommitMsgHookFailed.Text,
                    _installCommitMsgHookShortText.Text,
                    MessageBoxButtons.OK,
                    MessageBoxIcon.Error
                    );
            }
            else
            {
                File.WriteAllText(path, content);

                // Update the cache.

                HaveValidCommitMsgHook(_gitUiCommands.GitModule.GetGitDirectory(), true);
            }
        }
Beispiel #4
0
        protected override void OnLoad(EventArgs e)
        {
            if (DesignMode)
            {
                return;
            }

            Settings = GerritSettings.Load();

            if (Settings == null)
            {
                MessageBox.Show(this, "There was a problem loading the .gitreview file. Please review your settings.");
                Dispose();
                return;
            }

            base.OnLoad(e);
        }
        protected override void OnLoad(EventArgs e)
        {
            if (DesignMode)
            {
                return;
            }

            Settings = GerritSettings.Load(Module);

            if (Settings == null)
            {
                Dispose();
                return;
            }

            SetRestClientUrl();
            Version = GetGerritVersion();

            base.OnLoad(e);
        }
Beispiel #6
0
        private async Task InstallCommitMsgHookAsync()
        {
            await _mainForm.SwitchToMainThreadAsync();

            var settings = GerritSettings.Load(_mainForm, _gitUiCommands.GitModule);

            if (settings == null)
            {
                return;
            }

            var hooksFolderPath = _gitUiCommands.GitModule.ResolveGitInternalPath(HooksFolderName);

            if (!Directory.Exists(hooksFolderPath))
            {
                try
                {
                    Directory.CreateDirectory(hooksFolderPath);
                }
                catch
                {
                    MessageBox.Show(
                        _mainForm,
                        _installCommitMsgHookFolderCreationFailed.Text,
                        _installCommitMsgHookShortText.Text,
                        MessageBoxButtons.OK,
                        MessageBoxIcon.Error);

                    return;
                }
            }

            var commitMessageHookPath = Path.Combine(hooksFolderPath, CommitMessageHookFileName);

            string content;

            try
            {
                content = await DownloadFromScpAsync(settings);
            }
            catch
            {
                content = null;
            }

            await _mainForm.SwitchToMainThreadAsync();

            if (content == null)
            {
                MessageBox.Show(
                    _mainForm,
                    _installCommitMsgHookDownloadFileFailed.Text,
                    _installCommitMsgHookShortText.Text,
                    MessageBoxButtons.OK,
                    MessageBoxIcon.Error);
            }
            else
            {
                File.WriteAllText(commitMessageHookPath, content);

                // Update the cache.

                HaveValidCommitMsgHook(_gitUiCommands.GitModule, true);
            }
        }