private IBuildServerSettingsUserControl?CreateBuildServerSettingsUserControl()
        {
            Validates.NotNull(Module);

            if (BuildServerType.SelectedIndex == 0 || string.IsNullOrEmpty(Module.WorkingDir))
            {
                return(null);
            }

            var defaultProjectName = Module.WorkingDir.Split(new[] { Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar }, StringSplitOptions.RemoveEmptyEntries).Last();

            var exports        = ManagedExtensibility.GetExports <IBuildServerSettingsUserControl, IBuildServerTypeMetadata>();
            var selectedExport = exports.SingleOrDefault(export => export.Metadata.BuildServerType == GetSelectedBuildServerType());

            if (selectedExport is not null)
            {
                var buildServerSettingsUserControl = selectedExport.Value;
                Validates.NotNull(_remotesManager);
                var remoteUrls = _remotesManager.LoadRemotes(false).Select(r => string.IsNullOrEmpty(r.PushUrl) ? r.Url : r.PushUrl);

                buildServerSettingsUserControl.Initialize(defaultProjectName, remoteUrls);
                return(buildServerSettingsUserControl);
            }

            return(null);
        }
Esempio n. 2
0
        protected void SetCredentials(SettingLevel settingLevel, string name, NetworkCredential?value)
        {
            var targetName = GetWindowsCredentialsTarget(name, settingLevel);

            Validates.NotNull(targetName);
            Credentials.AddOrUpdate(targetName, value, (s, credential) => value);
        }
            private Nodes FillBranchTree(IReadOnlyList <IGitRef> branches, CancellationToken token)
            {
                #region example

                // (input)
                // a-branch
                // develop/crazy-branch
                // develop/features/feat-next
                // develop/features/feat-next2
                // develop/issues/iss444
                // develop/wild-branch
                // issues/iss111
                // master
                //
                // ->
                // (output)
                // 0 a-branch
                // 0 develop/
                // 1   features/
                // 2      feat-next
                // 2      feat-next2
                // 1   issues/
                // 2      iss444
                // 1   wild-branch
                // 1   wilds/
                // 2      card
                // 0 issues/
                // 1     iss111
                // 0 master

                #endregion

                Nodes nodes           = new(this);
                var   aheadBehindData = _aheadBehindDataProvider?.GetData();

                var currentBranch = Module.GetSelectedBranch();
                Dictionary <string, BaseBranchNode> pathToNode = new();
                foreach (IGitRef branch in branches)
                {
                    token.ThrowIfCancellationRequested();

                    Validates.NotNull(branch.ObjectId);

                    bool            isVisible       = !IsFiltering.Value || _refsSource.Contains(branch.ObjectId);
                    LocalBranchNode localBranchNode = new(this, branch.ObjectId, branch.Name, branch.Name == currentBranch, isVisible);

                    if (aheadBehindData is not null && aheadBehindData.ContainsKey(localBranchNode.FullPath))
                    {
                        localBranchNode.UpdateAheadBehind(aheadBehindData[localBranchNode.FullPath].ToDisplay());
                    }

                    var parent = localBranchNode.CreateRootNode(pathToNode, (tree, parentPath) => new BranchPathNode(tree, parentPath));
                    if (parent is not null)
                    {
                        nodes.AddNode(parent);
                    }
                }

                return(nodes);
            }
        protected override ISettingsSource GetCurrentSettings()
        {
            Validates.NotNull(_settingsContainer);

            _settingsContainer.SetSettingsSource(base.GetCurrentSettings());
            return(_settingsContainer);
        }
Esempio n. 5
0
        public static void LoadThemeData()
        {
            Validates.NotNull(_renderers);
            Validates.NotNull(_scrollBarRenderer);
            Validates.NotNull(_headerRenderer);
            Validates.NotNull(_listViewRenderer);
            Validates.NotNull(_treeViewRenderer);
            Validates.NotNull(_tabRenderer);

            foreach (ThemeRenderer renderer in _renderers)
            {
                renderer.AddThemeData(IntPtr.Zero);
            }

            var editorHandle   = new ICSharpCode.TextEditor.TextEditorControl().Handle;
            var listViewHandle = new NativeListView().Handle;
            var treeViewHandle = new NativeTreeView().Handle;

            _scrollBarRenderer.AddThemeData(editorHandle);
            _scrollBarRenderer.AddThemeData(listViewHandle);
            _headerRenderer.AddThemeData(listViewHandle);
            _listViewRenderer.AddThemeData(listViewHandle);
            _treeViewRenderer.AddThemeData(treeViewHandle);
            _tabRenderer.AddThemeData(new TabControl().Handle);
        }
Esempio n. 6
0
        public IReadOnlyList <FileStatusWithDescription> SetDiffs(IReadOnlyList <GitRevision>?revisions, Func <ObjectId, string>?describeRevision, Func <ObjectId, GitRevision?>?getRevision = null)
        {
            var selectedRev = revisions?.FirstOrDefault();

            if (selectedRev is null)
            {
                return(Array.Empty <FileStatusWithDescription>());
            }

            GitModule module = GetModule();

            List <FileStatusWithDescription> fileStatusDescs = new();

            if (revisions !.Count == 1)
            {
                if (selectedRev.ParentIds is null || selectedRev.ParentIds.Count == 0)
                {
                    Validates.NotNull(selectedRev.TreeGuid);

                    // No parent for the initial commit
                    fileStatusDescs.Add(new FileStatusWithDescription(
                                            firstRev: null,
                                            secondRev: selectedRev,
                                            summary: GetDescriptionForRevision(describeRevision, selectedRev.ObjectId),
                                            statuses: module.GetTreeFiles(selectedRev.TreeGuid, full: true)));
                }
Esempio n. 7
0
        /// <summary>
        /// Initialises all available plugins on the background thread.
        /// </summary>
        public static void Initialize()
        {
            lock (Plugins)
            {
                if (Plugins.Count > 0)
                {
                    return;
                }

                try
                {
                    ManagedExtensibility.SetUserPluginsPath(AppSettings.UserPluginsPath);

                    foreach (var plugin in ManagedExtensibility.GetExports <IGitPlugin>().Select(lazy => lazy.Value))
                    {
                        Validates.NotNull(plugin.Description);

                        // Description for old plugin setting processing as key
                        plugin.SettingsContainer = new GitPluginSettingsContainer(plugin.Id, plugin.Description);

                        if (plugin is IRepositoryHostPlugin repositoryHostPlugin)
                        {
                            GitHosters.Add(repositoryHostPlugin);
                        }

                        Plugins.Add(plugin);
                    }
                }
                catch
                {
                    // no-op
                }
            }
        }
        private static IEnumerable <string> ReadOrInitializeAutoCompleteRegexes()
        {
            string?appDataPath = AppSettings.ApplicationDataPath.Value;

            Validates.NotNull(appDataPath);

            var path = PathUtil.Combine(appDataPath, "AutoCompleteRegexes.txt");

            if (File.Exists(path))
            {
                return(File.ReadLines(path));
            }

            var entryAssembly = Assembly.GetEntryAssembly();

            if (entryAssembly is null)
            {
                // This will be null during integration tests, for example
                return(Enumerable.Empty <string>());
            }

            Stream?s = entryAssembly.GetManifestResourceStream("GitExtensions.AutoCompleteRegexes.txt");

            if (s is null)
            {
                throw new NotImplementedException("Please add AutoCompleteRegexes.txt file into .csproj");
            }

            using var sr = new StreamReader(s);
            return(sr.ReadToEnd().Split(new[] { '\n', '\r' }, StringSplitOptions.RemoveEmptyEntries));
        }
Esempio n. 9
0
        public IReadOnlyList <IBuild> QueryBuilds(DateTime?sinceDate, bool?running)
        {
            Validates.NotNull(_buildDefinitions);

            var result = new List <IBuild>();

            foreach (var buildDefinition in _buildDefinitions)
            {
                Validates.NotNull(_buildServer);

                var buildSpec = _buildServer.CreateBuildDetailSpec(buildDefinition);
                buildSpec.InformationTypes = null;
                if (sinceDate.HasValue)
                {
                    buildSpec.MinFinishTime = sinceDate.Value;
                }

                if (running.HasValue && running.Value)
                {
                    buildSpec.Status = Microsoft.TeamFoundation.Build.Client.BuildStatus.InProgress;
                }

                result.AddRange(_buildServer.QueryBuilds(buildSpec).Builds.Select(b =>
                {
                    var id          = b.Uri.AbsoluteUri.Substring(b.Uri.AbsoluteUri.LastIndexOf('/') + 1);
                    string duration = string.Empty;
                    if (b.Status != Microsoft.TeamFoundation.Build.Client.BuildStatus.NotStarted &&
                        b.Status != Microsoft.TeamFoundation.Build.Client.BuildStatus.None &&
                        b.Status != Microsoft.TeamFoundation.Build.Client.BuildStatus.Stopped)
                    {
                        if (b.Status == Microsoft.TeamFoundation.Build.Client.BuildStatus.InProgress)
                        {
                            duration = " / " + GetDuration(DateTime.Now - b.StartTime);
                        }
                        else
                        {
                            duration = " / " + GetDuration(b.FinishTime - b.StartTime);
                        }
                    }

                    return(new BuildInfo
                    {
                        Id = id,
                        Label = b.BuildNumber,
                        StartDate = b.StartTime,
                        Status = ConvertStatus(b.Status),
                        IsFinished = b.BuildFinished,
                        Description = GetStatus(b) + duration,
                        Revision = b.SourceGetVersion,
                        Url = _urlPrefix + (_isWebServer
                                      ? Uri.EscapeDataString(b.Uri.AbsoluteUri) + "&_a=summary"
                                      : id),
                    });
                }).Cast <IBuild>().ToList());
            }

            result = ThreadHelper.JoinableTaskFactory.Run(() => QueryBuilds2015Async(result, sinceDate, running));
            return(result);
        }
Esempio n. 10
0
 private IEnumerable <(string name, object item)> GetMenuCommandsForTranslationImpl()
 {
     foreach (MenuCommand menuCommand in GetMenuCommandsForTranslation())
     {
         Validates.NotNull(menuCommand.Name);
         yield return(menuCommand.Name, menuCommand);
     }
 }
Esempio n. 11
0
        /// <summary>
        /// Parses <paramref name="data"/> into a <see cref="CommitData"/> object.
        /// </summary>
        /// <param name="data">Data produced by a <c>git log</c> or <c>git show</c> command where <c>--format</c>
        /// was provided the string <see cref="CommitDataFormat"/>.</param>
        /// <returns>CommitData object populated with parsed info from git string.</returns>
        internal CommitData CreateFromFormattedData(string data)
        {
            if (data is null)
            {
                throw new ArgumentNullException(nameof(data));
            }

            var module = GetModule();

            // $ git log --pretty="format:%H%n%T%n%P%n%aN <%aE>%n%at%n%cN <%cE>%n%ct%n%e%n%B%nNotes:%n%-N" -1
            // 4bc1049fc3b9191dbd390e1ae6885aedd1a4e34b
            // a59c21f0b2e6f43ae89b76a216f9f6124fc359f8
            // 8e3873685d89f8cb543657d1b9e66e516cae7e1d dfd353d3b02d24a0d98855f6a1848c51d9ba4d6b
            // RussKie <*****@*****.**>
            // 1521115435
            // GitHub <*****@*****.**>
            // 1521115435
            //
            // Merge pull request #4615 from drewnoakes/modernise-3
            //
            // New language features
            // Notes:

            // commit id
            // tree id
            // parent ids (separated by spaces)
            // author
            // authored date (unix time)
            // committer
            // committed date (unix time)
            // encoding (may be blank)
            // diff notes
            // ...

            var lines = data.Split(Delimiters.LineFeed);

            var guid = ObjectId.Parse(lines[0]);

            // TODO: we can use this to add more relationship info like gitk does if wanted
            var treeGuid = ObjectId.Parse(lines[1]);

            // TODO: we can use this to add more relationship info like gitk does if wanted
            var parentIds      = lines[2].LazySplit(' ').Where(id => !string.IsNullOrWhiteSpace(id)).Select(id => ObjectId.Parse(id)).ToList();
            var author         = module.ReEncodeStringFromLossless(lines[3]);
            var authorDate     = DateTimeUtils.ParseUnixTime(lines[4]);
            var committer      = module.ReEncodeStringFromLossless(lines[5]);
            var commitDate     = DateTimeUtils.ParseUnixTime(lines[6]);
            var commitEncoding = lines[7];
            var message        = ProcessDiffNotes(startIndex: 8, lines);

            // commit message is not re-encoded by git when format is given
            var body = module.ReEncodeCommitMessage(message, commitEncoding);

            Validates.NotNull(author);
            Validates.NotNull(committer);

            return(new CommitData(guid, treeGuid, parentIds, author, authorDate, committer, commitDate, body));
        }
Esempio n. 12
0
        /// <summary>
        /// Adds the given working directory to the list of Recent for future quick access.
        /// </summary>
        public void AddToRecent(string workingDir)
        {
            if (!IsSupported)
            {
                return;
            }

            if (!ToolbarButtonsCreated)
            {
                _deferredAddToRecent = workingDir;
                return;
            }

            if (string.IsNullOrWhiteSpace(workingDir))
            {
                throw new ArgumentException(nameof(workingDir));
            }

            SafeInvoke(() =>
            {
                string repositoryDescription = _repositoryDescriptionProvider.Get(workingDir);
                if (string.IsNullOrWhiteSpace(repositoryDescription))
                {
                    return;
                }

                string baseFolder = Path.Combine(AppSettings.ApplicationDataPath.Value, "Recent");
                if (!Directory.Exists(baseFolder))
                {
                    Directory.CreateDirectory(baseFolder);
                }

                // sanitise
                StringBuilder sb = new(repositoryDescription);
                foreach (char c in Path.GetInvalidFileNameChars())
                {
                    sb.Replace(c, '_');
                }

                string path = Path.Combine(baseFolder, $"{sb}.gitext");
                File.WriteAllText(path, workingDir);
                JumpList.AddToRecent(path);

                if (!ToolbarButtonsCreated)
                {
                    return;
                }

                Validates.NotNull(_commitButton);
                Validates.NotNull(_pushButton);
                Validates.NotNull(_pullButton);

                _commitButton.Enabled = true;
                _pushButton.Enabled   = true;
                _pullButton.Enabled   = true;
            }, nameof(AddToRecent));
        }
Esempio n. 13
0
        private void Init(IGitPlugin gitPlugin)
        {
            Validates.NotNull(gitPlugin.Name);

            _gitPlugin         = gitPlugin;
            _settingsContainer = new GitPluginSettingsContainer(gitPlugin.Name);
            CreateSettingsControls();
            InitializeComplete();
        }
        /// <summary>
        /// Generate header.
        /// </summary>
        public string Render(CommitData commitData, bool showRevisionsAsLinks)
        {
            if (commitData is null)
            {
                throw new ArgumentNullException(nameof(commitData));
            }

            bool   isArtificial      = commitData.ObjectId.IsArtificial;
            bool   authorIsCommitter = string.Equals(commitData.Author, commitData.Committer, StringComparison.CurrentCulture);
            bool   datesEqual        = commitData.AuthorDate.EqualsExact(commitData.CommitDate);
            var    padding           = _headerRendererStyleProvider.GetMaxWidth();
            string authorEmail       = GetEmail(commitData.Author);

            Validates.NotNull(_linkFactory);

            var header = new StringBuilder();

            header.AppendLine(_labelFormatter.FormatLabel(TranslatedStrings.Author, padding) + _linkFactory.CreateLink(commitData.Author, "mailto:" + authorEmail));

            if (!isArtificial)
            {
                header.AppendLine(_labelFormatter.FormatLabel(datesEqual ? TranslatedStrings.Date : TranslatedStrings.AuthorDate, padding) + WebUtility.HtmlEncode(_dateFormatter.FormatDateAsRelativeLocal(commitData.AuthorDate)));
            }

            if (!authorIsCommitter)
            {
                string committerEmail = GetEmail(commitData.Committer);
                header.AppendLine(_labelFormatter.FormatLabel(TranslatedStrings.Committer, padding) + _linkFactory.CreateLink(commitData.Committer, "mailto:" + committerEmail));
            }

            if (!isArtificial)
            {
                if (!datesEqual)
                {
                    header.AppendLine(_labelFormatter.FormatLabel(TranslatedStrings.CommitDate, padding) + WebUtility.HtmlEncode(_dateFormatter.FormatDateAsRelativeLocal(commitData.CommitDate)));
                }

                header.AppendLine(_labelFormatter.FormatLabel(TranslatedStrings.CommitHash, padding) + WebUtility.HtmlEncode(commitData.ObjectId.ToString()));
            }

            if (commitData.ChildIds is not null && commitData.ChildIds.Count != 0)
            {
                header.AppendLine(_labelFormatter.FormatLabel(TranslatedStrings.GetChildren(commitData.ChildIds.Count), padding) + RenderObjectIds(commitData.ChildIds, showRevisionsAsLinks));
            }

            var parentIds = commitData.ParentIds;

            if (parentIds.Count != 0)
            {
                header.AppendLine(_labelFormatter.FormatLabel(TranslatedStrings.GetParents(parentIds.Count), padding) + RenderObjectIds(parentIds, showRevisionsAsLinks));
            }

            // remove the trailing newline character
            header.Length = header.Length - Environment.NewLine.Length;

            return(header.ToString());
        }
Esempio n. 15
0
        public async Task <IList <Build> > QueryRunningBuildsAsync(string buildDefinitionsToQuery)
        {
            string queryUrl = QueryForBuildStatus(buildDefinitionsToQuery, "cancelling,inProgress,none,notStarted,postponed") + "&api-version=2.0";

            var runningBuilds = (await HttpGetAsync <ListWrapper <Build> >(queryUrl)).Value;

            Validates.NotNull(runningBuilds);
            return(runningBuilds);
        }
Esempio n. 16
0
 async void Handle_Clicked(object sender, System.EventArgs e)
 {
     if (Validates.validateSearch(fromCity, toCity))
     {
         await Navigation.PushAsync(new ShowFlightsPage(this.repositoryList, toCity, fromCity, datePicker.Date));
     }
     else
     {
         await App.Current.MainPage.DisplayAlert("Alert", "Fill all fields", "OK");
     }
 }
        private void Init(IGitPlugin gitPlugin)
        {
            Validates.NotNull(gitPlugin.Description);

            _gitPlugin = gitPlugin;

            // Description for old plugin setting processing as key
            _settingsContainer = new GitPluginSettingsContainer(gitPlugin.Id, gitPlugin.Description);
            CreateSettingsControls();
            InitializeComplete();
        }
Esempio n. 18
0
 public void UpdateCommitIcon(Image image)
 {
     SafeInvoke(() =>
     {
         if (ToolbarButtonsCreated && IsSupportedAndVisible)
         {
             Validates.NotNull(_commitButton);
             _commitButton.Icon = MakeIcon(image, 48, true);
         }
     }, nameof(UpdateCommitIcon));
 }
Esempio n. 19
0
        private void monospaceFontChangeButton_Click(object sender, EventArgs e)
        {
            monospaceFontDialog.Font = _monospaceFont;
            DialogResult result = monospaceFontDialog.ShowDialog(this);

            if (result is (DialogResult.OK or DialogResult.Yes))
            {
                Validates.NotNull(monospaceFontDialog.Font);
                SetCurrentMonospaceFont(monospaceFontDialog.Font);
            }
        }
Esempio n. 20
0
        private void applicationFontChangeButton_Click(object sender, EventArgs e)
        {
            applicationDialog.Font = _applicationFont;
            DialogResult result = applicationDialog.ShowDialog(this);

            if (result is (DialogResult.OK or DialogResult.Yes))
            {
                Validates.NotNull(applicationDialog.Font);
                SetCurrentApplicationFont(applicationDialog.Font);
            }
        }
Esempio n. 21
0
        private void diffFontChangeButton_Click(object sender, EventArgs e)
        {
            diffFontDialog.Font = _diffFont;
            DialogResult result = diffFontDialog.ShowDialog(this);

            if (result is (DialogResult.OK or DialogResult.Yes))
            {
                Validates.NotNull(diffFontDialog.Font);
                SetCurrentDiffFont(diffFontDialog.Font);
            }
        }
Esempio n. 22
0
        private void ValidBirthYearButton_Click(object sender, EventArgs e)
        {
            List <string> yearList = new() { "1900", "1956", "2000", DateAndTime.Now.Year.ToString() };

            foreach (var currentYear in yearList)
            {
                Debug.WriteLine(Validates.ValidateBirthYear(currentYear) ?
                                $"{currentYear} is valid" :
                                $"{currentYear} is not valid");
            }
        }
Esempio n. 23
0
        private void consoleFontChangeButton_Click(object sender, System.EventArgs e)
        {
            consoleFontDialog.Font = _consoleFont;
            DialogResult result = consoleFontDialog.ShowDialog(this);

            if (result is (DialogResult.OK or DialogResult.Yes))
            {
                Validates.NotNull(consoleFontDialog.Font);
                SetCurrentConsoleFont(consoleFontDialog.Font);
            }
        }
Esempio n. 24
0
        protected override ISettingsLayout CreateSettingsLayout()
        {
            Validates.NotNull(_gitPlugin);

            labelNoSettings.Visible = !_gitPlugin.HasSettings;

            var layout = base.CreateSettingsLayout();

            tableLayoutPanel1.Controls.Add(layout.GetControl(), 0, 1);

            return(layout);
        }
Esempio n. 25
0
        protected override void PageToSettings()
        {
            Validates.NotNull(_diffFont);
            Validates.NotNull(_applicationFont);
            Validates.NotNull(_commitFont);
            Validates.NotNull(_monospaceFont);

            AppSettings.FixedWidthFont = _diffFont;
            AppSettings.Font           = _applicationFont;
            AppSettings.CommitFont     = _commitFont;
            AppSettings.MonospaceFont  = _monospaceFont;
        }
Esempio n. 26
0
        private string?GetWindowsCredentialsTarget(string name, SettingLevel settingLevel)
        {
            if (settingLevel == SettingLevel.Global)
            {
                return($"{name}");
            }

            Validates.NotNull(_getWorkingDir);
            var suffix = _getWorkingDir();

            return(Strings.IsNullOrWhiteSpace(suffix) ? null : $"{name}_{suffix}");
        }
        public void FillBuildReport(GitRevision?revision)
        {
            SetSelectedRevision(revision);

            _tabControl.SuspendLayout();

            try
            {
                var buildResultPageEnabled = IsBuildResultPageEnabled();
                var buildInfoIsAvailable   = !string.IsNullOrEmpty(revision?.BuildStatus?.Url);

                if (buildResultPageEnabled && buildInfoIsAvailable)
                {
                    Validates.NotNull(revision);

                    if (_buildReportTabPage is null)
                    {
                        CreateBuildReportTabPage(_tabControl);
                        Validates.NotNull(_buildReportTabPage);
                    }

                    _buildReportTabPage.Controls.Clear();

                    SetTabPageContent(revision);

                    var isFavIconMissing = _buildReportTabPage.ImageIndex < 0;

                    if (isFavIconMissing || _tabControl.SelectedTab == _buildReportTabPage)
                    {
                        LoadReportContent(revision, isFavIconMissing);
                    }

                    if (!_tabControl.Controls.Contains(_buildReportTabPage))
                    {
                        _tabControl.Controls.Add(_buildReportTabPage);
                    }
                }
                else
                {
                    if (_buildReportTabPage is not null && _buildReportWebBrowser is not null && _tabControl.Controls.Contains(_buildReportTabPage))
                    {
                        _buildReportWebBrowser.Stop();
                        _buildReportWebBrowser.Document.Write(string.Empty);
                        _tabControl.Controls.Remove(_buildReportTabPage);
                    }
                }
            }
            finally
            {
                _tabControl.ResumeLayout();
            }
        }
Esempio n. 28
0
        public async Task <IList <Build> > QueryFinishedBuildsAsync(string buildDefinitionsToQuery, DateTime?sinceDate)
        {
            string queryUrl = QueryForBuildStatus(buildDefinitionsToQuery, "completed");

            queryUrl += sinceDate.HasValue
                ? $"&minTime={sinceDate.Value.ToUniversalTime():s}&api-version=4.1"
                : "&api-version=2.0";

            var finishedBuilds = (await HttpGetAsync <ListWrapper <Build> >(queryUrl)).Value;

            Validates.NotNull(finishedBuilds);
            return(finishedBuilds);
        }
        private void SaveSettings()
        {
            Validates.NotNull(_repositoryHistory);

            AppSettings.ShorteningRecentRepoPathStrategy = GetShorteningStrategy();
            AppSettings.SortMostRecentRepos           = sortMostRecentRepos.Checked;
            AppSettings.SortLessRecentRepos           = sortLessRecentRepos.Checked;
            AppSettings.MaxMostRecentRepositories     = (int)_NO_TRANSLATE_maxRecentRepositories.Value;
            AppSettings.RecentReposComboMinWidth      = (int)comboMinWidthEdit.Value;
            AppSettings.RecentRepositoriesHistorySize = (int)_NO_TRANSLATE_RecentRepositoriesHistorySize.Value;

            ThreadHelper.JoinableTaskFactory.Run(() => RepositoryHistoryManager.Locals.SaveRecentHistoryAsync(_repositoryHistory));
        }
Esempio n. 30
0
        public override void StartProcess(string command, string arguments, string workDir, Dictionary <string, string> envVariables)
        {
            ProcessOperation operation = CommandLog.LogProcessStart(command, arguments, workDir);

            try
            {
                var commandLine = new ArgumentBuilder {
                    command.Quote(), arguments
                }.ToString();
                ConsoleCommandLineOutputProcessor outputProcessor = new(commandLine.Length, FireDataReceived);

                ConEmuStartInfo startInfo = new()
                {
                    ConsoleProcessCommandLine        = commandLine,
                    IsEchoingConsoleCommandLine      = true,
                    WhenConsoleProcessExits          = WhenConsoleProcessExits.KeepConsoleEmulatorAndShowMessage,
                    AnsiStreamChunkReceivedEventSink = outputProcessor.AnsiStreamChunkReceived,
                    StartupDirectory = workDir
                };

                foreach (var(name, value) in envVariables)
                {
                    startInfo.SetEnv(name, value);
                }

                startInfo.ConsoleProcessExitedEventSink = (_, args) =>
                {
                    _nLastExitCode = args.ExitCode;
                    operation.LogProcessEnd(_nLastExitCode);
                    outputProcessor.Flush();
                    FireProcessExited();
                };

                startInfo.ConsoleEmulatorClosedEventSink = (sender, _) =>
                {
                    Validates.NotNull(_terminal);
                    if (sender == _terminal.RunningSession)
                    {
                        FireTerminated();
                    }
                };

                Validates.NotNull(_terminal);
                _terminal.Start(startInfo, ThreadHelper.JoinableTaskFactory, AppSettings.ConEmuStyle.Value, AppSettings.ConEmuConsoleFont.Name, AppSettings.ConEmuConsoleFont.Size.ToString(CultureInfo.InvariantCulture));
            }
            catch (Exception ex)
            {
                operation.LogProcessEnd(ex);
                throw;
            }
        }