async private Task <bool> prepareStorageForDiffTool(MergeRequestKey mrk, ILocalCommitStorage storage, string leftSHA, string rightSHA) { if (storage == null) { MessageBox.Show("Cannot launch a diff tool without up-to-date storage.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning); return(false); } ICommitStorageUpdateContextProvider contextProvider = new CommitBasedContextProvider(new string[] { rightSHA }, leftSHA); return(await prepareCommitStorage(mrk, storage, contextProvider, true)); }
async protected override Task doUpdate(ILocalCommitStorage repo) { foreach (KeyValuePair <MergeRequestKey, Version> keyValuePair in collectLatestVersions(repo)) { DiffStatistic?diffStat = null; if (!String.IsNullOrEmpty(keyValuePair.Value.Base_Commit_SHA) && !String.IsNullOrEmpty(keyValuePair.Value.Head_Commit_SHA)) { GitDiffArguments args = new GitDiffArguments ( GitDiffArguments.DiffMode.ShortStat, new GitDiffArguments.CommonArguments ( keyValuePair.Value.Base_Commit_SHA, keyValuePair.Value.Head_Commit_SHA, null, null, null ), null ); bool finished = repo?.Updater == null; CommitBasedContextProvider contextProvider = new CommitBasedContextProvider( new string[] { keyValuePair.Value.Head_Commit_SHA }, keyValuePair.Value.Base_Commit_SHA); repo?.Updater?.RequestUpdate(contextProvider, () => finished = true); await TaskUtils.WhileAsync(() => !finished); try { if (repo?.Git != null) { await repo.Git.FetchAsync(args); } diffStat = parseGitDiffStatistic(repo, keyValuePair.Key, args); } catch (FetchFailedException ex) { ExceptionHandlers.Handle(String.Format( "Cannot update git statistic for MR with IID {0}", keyValuePair.Key), ex); } } _statistic[keyValuePair.Key] = new MergeRequestStatistic(keyValuePair.Value.Created_At, diffStat); Update?.Invoke(); } }