-
Notifications
You must be signed in to change notification settings - Fork 105
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
29 changed files
with
340 additions
and
134 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation"> | ||
<s:Boolean x:Key="/Default/CodeInspection/CodeAnnotations/NamespacesWithAnnotations/=YouTrackSharp_002EAnnotations/@EntryIndexedValue">True</s:Boolean> | ||
<s:String x:Key="/Default/CodeStyle/CodeCleanup/Profiles/=YouTrackSharp/@EntryIndexedValue"><?xml version="1.0" encoding="utf-16"?><Profile name="YouTrackSharp"><AspOptimizeRegisterDirectives>True</AspOptimizeRegisterDirectives><HtmlReformatCode>True</HtmlReformatCode><JsInsertSemicolon>True</JsInsertSemicolon><FormatAttributeQuoteDescriptor>True</FormatAttributeQuoteDescriptor><CorrectVariableKindsDescriptor>True</CorrectVariableKindsDescriptor><VariablesToInnerScopesDescriptor>True</VariablesToInnerScopesDescriptor><StringToTemplatesDescriptor>True</StringToTemplatesDescriptor><JsReformatCode>True</JsReformatCode><RemoveRedundantQualifiersTs>True</RemoveRedundantQualifiersTs><OptimizeImportsTs>True</OptimizeImportsTs><OptimizeReferenceCommentsTs>True</OptimizeReferenceCommentsTs><PublicModifierStyleTs>True</PublicModifierStyleTs><ExplicitAnyTs>True</ExplicitAnyTs><TypeAnnotationStyleTs>True</TypeAnnotationStyleTs><RelativePathStyleTs>True</RelativePathStyleTs><AsInsteadOfCastTs>True</AsInsteadOfCastTs><CSCodeStyleAttributes ArrangeTypeAccessModifier="True" ArrangeTypeMemberAccessModifier="True" SortModifiers="True" RemoveRedundantParentheses="True" AddMissingParentheses="True" ArrangeBraces="True" ArrangeAttributes="True" ArrangeArgumentsStyle="True" ArrangeCodeBodyStyle="False" /><CSEnforceVarKeywordUsageSettings>True</CSEnforceVarKeywordUsageSettings><RemoveCodeRedundanciesVB>True</RemoveCodeRedundanciesVB><CssAlphabetizeProperties>True</CssAlphabetizeProperties><VBOptimizeImports>True</VBOptimizeImports><VBShortenReferences>True</VBShortenReferences><CSUseAutoProperty>True</CSUseAutoProperty><CSMakeAutoPropertyGetOnly>True</CSMakeAutoPropertyGetOnly><CSArrangeQualifiers>True</CSArrangeQualifiers><CSFixBuiltinTypeReferences>True</CSFixBuiltinTypeReferences><CssReformatCode>True</CssReformatCode><VBReformatCode>True</VBReformatCode><VBFormatDocComments>True</VBFormatDocComments><CSOptimizeUsings><OptimizeUsings>True</OptimizeUsings><EmbraceInRegion>False</EmbraceInRegion><RegionName></RegionName></CSOptimizeUsings><CSShortenReferences>True</CSShortenReferences><CSReformatCode>True</CSReformatCode></Profile></s:String> | ||
<s:String x:Key="/Default/CodeStyle/CodeCleanup/SilentCleanupProfile/@EntryValue">YouTrackSharp</s:String> | ||
<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/SPACE_AFTER_TYPECAST_PARENTHESES/@EntryValue">False</s:Boolean> | ||
<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/USE_INDENT_FROM_VS/@EntryValue">False</s:Boolean> | ||
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ESettingsUpgrade_002EAddAccessorOwnerDeclarationBracesMigration/@EntryIndexedValue">True</s:Boolean> | ||
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ESettingsUpgrade_002EMigrateBlankLinesAroundFieldToBlankLinesAroundProperty/@EntryIndexedValue">True</s:Boolean> | ||
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ESettingsUpgrade_002EMigrateThisQualifierSettings/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using Newtonsoft.Json; | ||
|
||
namespace YouTrackSharp.Issues | ||
{ | ||
/// <summary> | ||
/// A class that represents a YouTrack issue change. | ||
/// </summary> | ||
public class Change | ||
{ | ||
/// <summary> | ||
/// Creates an instance of the <see cref="Change" /> class. | ||
/// </summary> | ||
public Change() | ||
{ | ||
Fields = new List<FieldChange>(); | ||
} | ||
|
||
/// <summary> | ||
/// Fields that have been changed. | ||
/// </summary> | ||
[JsonProperty("field")] | ||
public ICollection<FieldChange> Fields { get; set; } | ||
|
||
/// <summary> | ||
/// Get <see cref="FieldChange"/> for a field identified by <paramref name="fieldName"/>. | ||
/// </summary> | ||
/// <param name="fieldName">Name of the field to retrieve <see cref="FieldChange"/> for.</param> | ||
/// <returns><see cref="FieldChange"/> for a field identified by <paramref name="fieldName"/>. Can be <value>null</value>.</returns> | ||
public FieldChange ForField(string fieldName) | ||
{ | ||
return Fields.FirstOrDefault(field => string.Equals(field.Name, fieldName, StringComparison.OrdinalIgnoreCase)); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
using System.Collections.Generic; | ||
using Newtonsoft.Json; | ||
|
||
namespace YouTrackSharp.Issues | ||
{ | ||
/// <summary> | ||
/// Wrapper for <see cref="T:System.Collections.Generic.ICollection`1" /> of <see cref="Change" />. | ||
/// </summary> | ||
internal class ChangeCollectionWrapper | ||
{ | ||
/// <summary> | ||
/// Wrapped <see cref="T:System.Collections.Generic.ICollection`1" /> of <see cref="Change" />. | ||
/// </summary> | ||
[JsonProperty("change")] | ||
public ICollection<Change> Changes { get; set; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
using System.Diagnostics; | ||
using Newtonsoft.Json; | ||
|
||
namespace YouTrackSharp.Issues | ||
{ | ||
/// <summary> | ||
/// Represents a YouTrack issue field change. | ||
/// </summary> | ||
[DebuggerDisplay("{Name}: {GetDebuggerTransition()}")] | ||
public class FieldChange | ||
{ | ||
#region JsonProperties | ||
|
||
[JsonProperty("oldValue")] | ||
// ReSharper disable once InconsistentNaming | ||
private object _oldValue | ||
{ | ||
get => From.Value; | ||
set => From.Value = value; | ||
} | ||
|
||
[JsonProperty("value")] | ||
// ReSharper disable once InconsistentNaming | ||
private object _value | ||
{ | ||
get => To.Value; | ||
set => To.Value = value; | ||
} | ||
|
||
[JsonProperty("newValue")] | ||
// ReSharper disable once InconsistentNaming | ||
private object _newValue | ||
{ | ||
get => To.Value; | ||
set => To.Value = value; | ||
} | ||
|
||
#endregion | ||
|
||
/// <summary> | ||
/// Creates an instance of the <see cref="FieldChange" /> class. | ||
/// </summary> | ||
public FieldChange() | ||
{ | ||
From = new Field(); | ||
To = new Field(); | ||
} | ||
|
||
/// <summary> | ||
/// Name of the field. | ||
/// </summary> | ||
[JsonProperty("name")] | ||
public string Name | ||
{ | ||
get => To.Name; | ||
private set | ||
{ | ||
From.Name = value; | ||
To.Name = value; | ||
} | ||
} | ||
|
||
/// <summary> | ||
/// <see cref="Field" /> representing the original value. Can be <value>null</value>. | ||
/// </summary> | ||
[JsonIgnore] | ||
public Field From { get; } | ||
|
||
/// <summary> | ||
/// <see cref="Field" /> representing the new value. Can be <value>null</value>. | ||
/// </summary> | ||
[JsonIgnore] | ||
public Field To { get; } | ||
|
||
/// <summary> | ||
/// Is this a transition from an older value to a newer one? | ||
/// </summary> | ||
[JsonIgnore] | ||
public bool IsTransition => From.Value != null; | ||
|
||
private string GetDebuggerTransition() | ||
{ | ||
return IsTransition | ||
? $"{From.Value} -> {To.Value}" | ||
: To.Value.ToString(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Threading.Tasks; | ||
using Newtonsoft.Json; | ||
|
||
namespace YouTrackSharp.Issues | ||
{ | ||
public partial class IssuesService | ||
{ | ||
/// <summary> | ||
/// Get change history for a specific issue from the server. | ||
/// </summary> | ||
/// <remarks>Uses the REST API <a href="https://www.jetbrains.com/help/youtrack/standalone/Get-Historical-Changes-of-an-Issue.html">Get Changes of an Issue</a>.</remarks> | ||
/// <param name="issueId">Id of the issue to get change history for.</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> | ||
public async Task<IEnumerable<Change>> GetChangeHistoryForIssue(string issueId) | ||
{ | ||
if (string.IsNullOrEmpty(issueId)) | ||
{ | ||
throw new ArgumentNullException(nameof(issueId)); | ||
} | ||
|
||
var client = await _connection.GetAuthenticatedHttpClient(); | ||
var response = await client.GetAsync($"rest/issue/{issueId}/changes"); | ||
|
||
response.EnsureSuccessStatusCode(); | ||
|
||
var wrapper = JsonConvert.DeserializeObject<ChangeCollectionWrapper>(await response.Content.ReadAsStringAsync()); | ||
return wrapper.Changes; | ||
} | ||
} | ||
} |
Oops, something went wrong.