private void Update() { if (CurrentStatus != WorkingStatus.Started) { return; } if (Environment.TickCount >= _nextUpdateTime || (Environment.TickCount < 0 && _nextUpdateTime > 0)) { // If the previous status call hasn't exited yet, we'll wait until it is // so we don't queue up a bunch of commands if (_commandIsRunning || UICommands.RepoChangedNotifier.IsLocked || Module.IsRunningGitProcess()) { _statusIsUpToDate = false;//tell that computed status isn't up to date return; } _commandIsRunning = true; _statusIsUpToDate = true; AsyncLoader.DoAsync(RunStatusCommand, UpdatedStatusReceived, OnUpdateStatusError); // Always update every 5 min, even if we don't know anything changed ScheduleNextJustInCaseUpdate(); } }
private void Update() { if (CurrentStatus != WorkingStatus.Started) { return; } if (Environment.TickCount >= _nextUpdateTime || (Environment.TickCount < 0 && _nextUpdateTime > 0)) { // If the previous status call hasn't exited yet, we'll wait until it is // so we don't queue up a bunch of commands if (_commandIsRunning || //don't update status while repository is being modyfied by GitExt //or while any git process is running, mostly repository status will change //after these actions. Moreover, calling git status while other git command is performed //can cause repository crash UICommands.RepoChangedNotifier.IsLocked || GitCommandHelpers.VersionInUse.RaceConditionWhenGitStatusIsUpdatingIndex && Module.IsRunningGitProcess()) { _statusIsUpToDate = false;//tell that computed status isn't up to date return; } _commandIsRunning = true; _statusIsUpToDate = true; if (_ignoredFilesAreStale) { UpdateIgnoredFiles(false); } AsyncLoader.DoAsync(RunStatusCommand, UpdatedStatusReceived, OnUpdateStatusError); // Always update every 5 min, even if we don't know anything changed ScheduleNextJustInCaseUpdate(); } }
private void _getFromUserBtn_Click(object sender, EventArgs e) { var search = _searchTB.Text; if (search == null || search.Trim().Length == 0) { return; } PrepareSearch(sender, e); AsyncLoader.DoAsync( () => _gitHoster.GetRepositoriesOfUser(search.Trim()), HandleSearchResult, ex => { if (ex.Exception.Message.Contains("404")) { MessageBox.Show(this, _strUserNotFound.Text, _strError.Text); } else { MessageBox.Show(this, _strCouldNotFetchReposOfUser.Text + Environment.NewLine + ex.Exception.Message, _strError.Text); } _searchBtn.Enabled = true; }); }
private void LoadDiffPatch() { AsyncLoader.DoAsync( () => _currentPullRequestInfo.DiffData, SplitAndLoadDiff, ex => MessageBox.Show(this, _strFailedToLoadDiffData.Text + ex.Message, _strError.Text)); }
private void UpdateMyRepos() { _myReposLV.Items.Clear(); _myReposLV.Items.Add(new ListViewItem { Text = _strLoading.Text }); AsyncLoader.DoAsync( () => _gitHoster.GetMyRepos(), repos => { _myReposLV.Items.Clear(); foreach (var repo in repos) { var lvi = new ListViewItem { Tag = repo, Text = repo.Name }; lvi.SubItems.Add(repo.IsAFork ? _strYes.Text : _strNo.Text); lvi.SubItems.Add(repo.Forks.ToString()); lvi.SubItems.Add(repo.IsPrivate ? _strYes.Text : _strNo.Text); _myReposLV.Items.Add(lvi); } }, ex => { _myReposLV.Items.Clear(); _helpTextLbl.Text = string.Format(_strFailedToGetRepos.Text, _gitHoster.Description) + "\r\n\r\nException: " + ex.Exception.Message + "\r\n\r\n" + _helpTextLbl.Text; }); }
private void _selectedOwner_SelectedIndexChanged(object sender, EventArgs e) { var hostedRemote = _selectHostedRepoCB.SelectedItem as IHostedRemote; if (hostedRemote == null) { return; } var hostedRepo = hostedRemote.GetHostedRepository(); if (hostedRepo == null) { return; } _selectHostedRepoCB.Enabled = false; ResetAllAndShowLoadingPullRequests(); AsyncLoader.DoAsync( hostedRepo.GetPullRequests, res => { SetPullRequestsData(res); _selectHostedRepoCB.Enabled = true; }, ex => MessageBox.Show(this, _strFailedToFetchPullData.Text + Environment.NewLine + ex.Exception.Message, _strError.Text)); }
public void InitToolStripBranchFilter() { bool local = localToolStripMenuItem.Checked; bool tag = tagsToolStripMenuItem.Checked; bool remote = remoteToolStripMenuItem.Checked; _NO_TRANSLATE_toolStripBranches.Items.Clear(); if (Module.IsValidGitWorkingDir()) { AsyncLoader.DoAsync(() => GetBranchAndTagRefs(local, tag, remote), branches => { foreach (var branch in branches) { _NO_TRANSLATE_toolStripBranches.Items.Add(branch); } var autoCompleteList = _NO_TRANSLATE_toolStripBranches.AutoCompleteCustomSource.Cast <string>(); if (!autoCompleteList.SequenceEqual(branches)) { _NO_TRANSLATE_toolStripBranches.AutoCompleteCustomSource.Clear(); _NO_TRANSLATE_toolStripBranches.AutoCompleteCustomSource.AddRange(branches.ToArray()); } }); } _NO_TRANSLATE_toolStripBranches.Enabled = Module.IsValidGitWorkingDir(); }
private void _pullReqTargetsCB_SelectedIndexChanged(object sender, EventArgs e) { _currentHostedRemote = _pullReqTargetsCB.SelectedItem as IHostedRemote; _remoteBranchesCB.Items.Clear(); _remoteBranchesCB.Text = _strLoading.Text; AsyncLoader.DoAsync( () => _currentHostedRemote.GetHostedRepository().Branches, branches => { branches.Sort((a, b) => string.Compare(a.Name, b.Name, true)); int selectItem = 0; _remoteBranchesCB.Items.Clear(); for (int i = 0; i < branches.Count; i++) { if (branches[i].Name == _currentBranch) { selectItem = i; } _remoteBranchesCB.Items.Add(branches[i].Name); } _createBtn.Enabled = true; if (branches.Count > 0) { _remoteBranchesCB.SelectedIndex = selectItem; } }, ex => { ex.Handled = false; }); }
private void LoadMyBranches() { _yourBranchesCB.Items.Clear(); if (MyRemote == null) { return; } AsyncLoader.DoAsync( () => MyRemote.GetHostedRepository().Branches, branches => { branches.Sort((a, b) => string.Compare(a.Name, b.Name, true)); int selectItem = 0; for (int i = 0; i < branches.Count; i++) { if (branches[i].Name == _currentBranch) { selectItem = i; } _yourBranchesCB.Items.Add(branches[i].Name); } _createBtn.Enabled = true; if (branches.Count > 0) { _yourBranchesCB.SelectedIndex = selectItem; } }, ex => { ex.Handled = false; }); }
private void LoadDiscussion() { AsyncLoader.DoAsync( () => _currentPullRequestInfo.Discussion, LoadDiscussion, ex => { MessageBox.Show(this, _strCouldNotLoadDiscussion.Text + Environment.NewLine + ex.Exception.Message, _strError.Text); LoadDiscussion(null); }); }
private void UpdateIgnoredFiles(bool clearImmediately) { if (clearImmediately) { _ignoredFiles = new HashSet <string>(); } AsyncLoader.DoAsync( LoadIgnoredFiles, (ignoredSet) => { _ignoredFiles = ignoredSet; _ignoredFilesAreStale = false; }, (e) => { _ignoredFiles = new HashSet <string>(); } ); }
private void _searchBtn_Click(object sender, EventArgs e) { var search = _searchTB.Text; if (search == null || search.Trim().Length == 0) { return; } PrepareSearch(sender, e); AsyncLoader.DoAsync( () => _gitHoster.SearchForRepository(search), HandleSearchResult, ex => { MessageBox.Show(this, _strSearchFailed.Text + ex.Message, _strError.Text); _searchBtn.Enabled = true; }); }
private void _selectedOwner_SelectedIndexChanged(object sender, EventArgs e) { var hostedRepo = _selectHostedRepoCB.SelectedItem as IHostedRepository; if (hostedRepo == null) { return; } _selectHostedRepoCB.Enabled = false; ResetAllAndShowLoadingPullRequests(); AsyncLoader.DoAsync <List <IPullRequestInformation> >( hostedRepo.GetPullRequests, res => { SetPullRequestsData(res); _selectHostedRepoCB.Enabled = true; }, ex => MessageBox.Show(this, _strFailedToFetchPullData.Text + ex.Message, _strError.Text) ); }
private void Update() { if (Environment.TickCount >= nextUpdateTime || (Environment.TickCount < 0 && nextUpdateTime > 0)) { // If the previous status call hasn't exited yet, we'll wait until it is // so we don't queue up a bunch of commands if (commandIsRunning) { statusIsUpToDate = false;//tell that computed status isn't up to date return; } commandIsRunning = true; statusIsUpToDate = true; AsyncLoader.DoAsync(RunStatusCommand, UpdatedStatusReceived, (e) => { CurrentStatus = WorkingStatus.Stopped; }); // Always update every 5 min, even if we don't know anything changed ScheduleNextJustInCaseUpdate(); } }
private void InitializeSoft() { GitStash gitStash = Stashes.SelectedItem as GitStash; Stashed.GitItemStatuses = null; Loading.Visible = true; Stashes.Enabled = false; toolStripButton1.Enabled = false; toolStripButton_customMessage.Enabled = false; if (gitStash == null) { Stashed.GitItemStatuses = null; } else if (gitStash == currentWorkingDirStashItem) { toolStripButton_customMessage.Enabled = true; AsyncLoader.DoAsync(() => Module.GetAllChangedFiles(), LoadGitItemStatuses); } else { AsyncLoader.DoAsync(() => Module.GetStashDiffFiles(gitStash.Name), LoadGitItemStatuses); } }
public void InitToolStripBranchFilter() { bool local = localToolStripMenuItem.Checked; bool remote = remoteToolStripMenuItem.Checked; _NO_TRANSLATE_toolStripBranches.Items.Clear(); AsyncLoader.DoAsync(() => GetBranchAndTagHeads(local, remote), (List <string> branches) => { foreach (var branch in branches) { _NO_TRANSLATE_toolStripBranches.Items.Add(branch); } var autoCompleteList = _NO_TRANSLATE_toolStripBranches.AutoCompleteCustomSource.Cast <string>(); if (!autoCompleteList.SequenceEqual(branches)) { _NO_TRANSLATE_toolStripBranches.AutoCompleteCustomSource.Clear(); _NO_TRANSLATE_toolStripBranches.AutoCompleteCustomSource.AddRange(branches.ToArray()); } } ); }
private void Update() { if (CurrentStatus != GitStatusMonitorState.Running) { return; } if (Environment.TickCount < _nextUpdateTime && (Environment.TickCount >= 0 || _nextUpdateTime <= 0)) { return; } // If the previous status call hasn't exited yet, we'll wait until it is // so we don't queue up a bunch of commands if (_commandIsRunning || // don't update status while repository is being modified by GitExt // or while any git process is running, mostly repository status will change // after these actions. Moreover, calling git status while other git command is performed // can cause repository crash UICommandsSource.UICommands.RepoChangedNotifier.IsLocked || (GitVersion.Current.RaceConditionWhenGitStatusIsUpdatingIndex && Module.IsRunningGitProcess())) { _statusIsUpToDate = false; // tell that computed status isn't up to date return; } _commandIsRunning = true; _statusIsUpToDate = true; _previousUpdateTime = Environment.TickCount; AsyncLoader.DoAsync(RunStatusCommand, UpdatedStatusReceived, OnUpdateStatusError); // Schedule update every 5 min, even if we don't know that anything changed CalculateNextUpdateTime(MaxUpdatePeriod); return; string RunStatusCommand() { _ignoredFilesPending = _ignoredFilesAreStale; // git-status with ignored files when needed only string command = GitCommandHelpers.GetAllChangedFilesCmd(!_ignoredFilesPending, UntrackedFilesMode.Default, noLocks: true); return(Module.RunGitCmd(command)); } void UpdatedStatusReceived(string updatedStatus) { // Adjust the interval between updates. (This does not affect an update already scheduled). _currentUpdateInterval = Math.Max(MinUpdateInterval, 3 * (Environment.TickCount - _previousUpdateTime)); _commandIsRunning = false; if (CurrentStatus != GitStatusMonitorState.Running) { return; } var allChangedFiles = GitCommandHelpers.GetStatusChangedFilesFromString(Module, updatedStatus); GitWorkingDirectoryStatusChanged?.Invoke(this, new GitWorkingDirectoryStatusEventArgs(allChangedFiles.Where(item => !item.IsIgnored))); if (_ignoredFilesPending) { _ignoredFilesPending = false; _ignoredFiles = new HashSet <string>(allChangedFiles.Where(item => item.IsIgnored).Select(item => item.Name)); if (_statusIsUpToDate) { _ignoredFilesAreStale = false; } } if (!_statusIsUpToDate) { // Still not up-to-date, but present what received, GetAllChangedFilesCmd() is the heavy command CalculateNextUpdateTime(UpdateDelay); } } void OnUpdateStatusError(AsyncErrorEventArgs e) { _commandIsRunning = false; CurrentStatus = GitStatusMonitorState.Stopped; } }