Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

history change can also return VCS changes #125

Merged
merged 1 commit into from
Mar 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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