/// <summary> /// Gets the files modified by the pull request. /// </summary> /// <returns>The collection of the modified files paths.</returns> public IEnumerable <FilePath> GetModifiedFiles() { if (!this.ValidatePullRequest()) { return(new List <FilePath>()); } var targetVersionDescriptor = new GitTargetVersionDescriptor { VersionType = GitVersionType.Commit, Version = this.LastSourceCommitId, }; var baseVersionDescriptor = new GitBaseVersionDescriptor { VersionType = GitVersionType.Commit, Version = this.LastTargetCommitId, }; using (var gitClient = this.gitClientFactory.CreateGitClient(this.CollectionUrl, this.credentials)) { var commitDiffs = gitClient .GetCommitDiffsAsync( this.ProjectName, this.RepositoryId, true, // bool? diffCommonCommit null, // int? top null, // int? skip baseVersionDescriptor, targetVersionDescriptor, null) // object userState .ConfigureAwait(false) .GetAwaiter() .GetResult(); this.log.Verbose( "Found {0} changed file(s) in the pull request", commitDiffs.Changes.Count()); if (!commitDiffs.ChangeCounts.Any()) { return(new List <FilePath>()); } return (from change in commitDiffs.Changes where change != null && !change.Item.IsFolder select new FilePath(change.Item.Path.TrimStart('/'))); } }
/// <inheritdoc /> protected override IEnumerable <FilePath> InternalGetModifiedFilesInPullRequest() { if (!this.PullRequestSystem.ValidatePullRequest()) { return(new List <FilePath>()); } this.Log.Verbose("Computing the list of files changed in this pull request..."); var targetVersionDescriptor = new GitTargetVersionDescriptor { VersionType = GitVersionType.Commit, Version = this.PullRequestSystem.TfsPullRequest.LastSourceCommitId }; var baseVersionDescriptor = new GitBaseVersionDescriptor { VersionType = GitVersionType.Commit, Version = this.PullRequestSystem.TfsPullRequest.LastTargetCommitId }; using (var gitClient = this.PullRequestSystem.CreateGitClient()) { var commitDiffs = gitClient.GetCommitDiffsAsync( this.PullRequestSystem.TfsPullRequest.ProjectName, this.PullRequestSystem.TfsPullRequest.RepositoryId, true, // bool? diffCommonCommit null, // int? top null, // int? skip baseVersionDescriptor, targetVersionDescriptor, null, // object userState CancellationToken.None).Result; this.Log.Verbose( "Found {0} changed file(s) in the pull request", commitDiffs.Changes.Count()); if (!commitDiffs.ChangeCounts.Any()) { return(new List <FilePath>()); } return (from change in commitDiffs.Changes where change != null && !change.Item.IsFolder select new FilePath(change.Item.Path.TrimStart('/'))); } }
public GitCommitDiffs GetGitCommitDiffsByBranch() { GitCommitDiffs diffs; using (var client = new GitHttpClient(_uri, _credentials)) { var baseVersion = new GitBaseVersionDescriptor { Version = _configuration.GitBaseVersionBranch }; var targetVersion = new GitTargetVersionDescriptor { Version = _configuration.GitTargetVersionBranch }; diffs = client.GetCommitDiffsAsync( _configuration.Project, _configuration.GitRepositoryId, baseVersionDescriptor: baseVersion, targetVersionDescriptor: targetVersion) .Result; } return(diffs); }