forked from sourcegit-scm/sourcegit
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSelfUpdate.cs
More file actions
58 lines (46 loc) · 1.45 KB
/
SelfUpdate.cs
File metadata and controls
58 lines (46 loc) · 1.45 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
using System;
using System.Reflection;
using System.Text.Json.Serialization;
namespace SourceGit.Models
{
public class Version
{
[JsonPropertyName("name")]
public string Name { get; set; }
[JsonPropertyName("tag_name")]
public string TagName { get; set; }
[JsonPropertyName("published_at")]
public DateTime PublishedAt { get; set; }
[JsonPropertyName("body")]
public string Body { get; set; }
[JsonIgnore]
public System.Version CurrentVersion { get; }
[JsonIgnore]
public string CurrentVersionStr => $"v{CurrentVersion.Major}.{CurrentVersion.Minor:D2}";
[JsonIgnore]
public bool IsNewVersion => CurrentVersion.CompareTo(new System.Version(TagName.Substring(1))) < 0;
[JsonIgnore]
public string ReleaseDateStr => PublishedAt.ToString(DateTimeFormat.Active.DateOnly);
public Version()
{
var assembly = Assembly.GetExecutingAssembly().GetName();
CurrentVersion = assembly.Version ?? new System.Version();
}
}
public class AlreadyUpToDate;
public class SelfUpdateFailed
{
public string Reason
{
get;
private set;
}
public SelfUpdateFailed(Exception e)
{
if (e.InnerException is { } inner)
Reason = inner.Message;
else
Reason = e.Message;
}
}
}