Skip to content

Commit

Permalink
Merge pull request #125 from jirkakara/213
Browse files Browse the repository at this point in the history
add ability to retrieve VCS changes to IssuesService
  • Loading branch information
rekolobov authored Mar 16, 2023
2 parents e19272b + 1b75411 commit 3330f0f
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 6 deletions.
5 changes: 5 additions & 0 deletions src/YouTrackSharp/Issues/Change.cs
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,11 @@ internal static Change FromApiEntity(ActivityItem entity)
fieldChange.From.Value = a.Removed == null ? new JArray() : JArray.FromObject(a.Removed);
fieldChange.To.Value = a.Added == null ? new JArray() : JArray.FromObject(a.Added);
break;
case VcsChangeActivityItem a:
fieldChange.Name = "vcs";
fieldChange.From.Value = a.Removed == null ? new JArray() : JArray.FromObject(a.Removed);
fieldChange.To.Value = a.Added == null ? new JArray() : JArray.FromObject(a.Added);
break;
case ProjectActivityItem a:
fieldChange.Name = "project";
fieldChange.From.Value = new JArray() {JObject.FromObject(a.Removed)};
Expand Down
5 changes: 3 additions & 2 deletions src/YouTrackSharp/Issues/IIssuesService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -130,11 +130,12 @@ Task<ICollection<Issue>> GetIssues(string filter = null, int? skip = null, int?
/// </summary>
/// <remarks>Uses the REST API <a href="https://www.jetbrains.com/help/youtrack/devportal/resource-api-issues-issueID-activities.html#get_all-ActivityItem-method">Get Changes of an Issue</a>.</remarks>
/// <param name="issueId">Id of the issue to get change history for.</param>
/// <param name="categories">Comma separated category types e.g. IssueResolvedCategory.</param>
/// <returns>An <see cref="T:System.Collections.Generic.IEnumerable`1" /> of <see cref="Change" /> for the requested issue <paramref name="issueId"/>.</returns>
/// <exception cref="T:System.ArgumentNullException">When the <paramref name="issueId"/> is null or empty.</exception>
/// <exception cref="T:System.Net.HttpRequestException">When the call to the remote YouTrack server instance failed.</exception>
Task<IEnumerable<Change>> GetChangeHistoryForIssue(string issueId);

Task<IEnumerable<Change>> GetChangeHistoryForIssue(string issueId, string categories = "AttachmentsCategory,CustomFieldCategory,DescriptionCategory,IssueResolvedCategory,LinksCategory,ProjectCategory,IssueVisibilityCategory,SprintCategory,SummaryCategory,TagsCategory,VcsChangeCategory");
/// <summary>
/// Get comments for a specific issue from the server.
/// </summary>
Expand Down
8 changes: 4 additions & 4 deletions src/YouTrackSharp/Issues/IssuesService.History.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ namespace YouTrackSharp.Issues
{
public partial class IssuesService
{
private static string ACTIVITIES_CATEGORIES =
"AttachmentsCategory,CustomFieldCategory,DescriptionCategory,IssueResolvedCategory,LinksCategory,ProjectCategory,IssueVisibilityCategory,SprintCategory,SummaryCategory,TagsCategory";
private const string ACTIVITIES_CATEGORIES =
"AttachmentsCategory,CustomFieldCategory,DescriptionCategory,IssueResolvedCategory,LinksCategory,ProjectCategory,IssueVisibilityCategory,SprintCategory,SummaryCategory,TagsCategory,VcsChangeCategory";

/// <inheritdoc />
public async Task<IEnumerable<Change>> GetChangeHistoryForIssue(string issueId)
public async Task<IEnumerable<Change>> GetChangeHistoryForIssue(string issueId, string categories = ACTIVITIES_CATEGORIES)
{
if (string.IsNullOrEmpty(issueId))
{
Expand All @@ -20,7 +20,7 @@ public async Task<IEnumerable<Change>> GetChangeHistoryForIssue(string issueId)

var client = await _connection.GetAuthenticatedApiClient();
var response = await client.IssuesActivitiesGetAsync(issueId,
ACTIVITIES_CATEGORIES, false, null, null, null, Constants.FieldsQueryStrings.Activities);
categories, false, null, null, null, Constants.FieldsQueryStrings.Activities);

return response.Select(Change.FromApiEntity).ToList();
}
Expand Down

0 comments on commit 3330f0f

Please sign in to comment.