Implement Torch auto-update. Sadly does not work for Patron branch.

This commit is contained in:
Brant Martin
2019-03-03 17:42:02 -05:00
parent 796feb05e6
commit 34616607a8
9 changed files with 234 additions and 104 deletions

View File

@@ -7,36 +7,36 @@ using System.Threading.Tasks;
namespace Torch.API
{
/// <summary>
/// Version in the form v#.#.#.#-info
/// Version in the form v#.#.#.#-branch
/// </summary>
public class InformationalVersion
{
public Version Version { get; set; }
public string[] Information { get; set; }
public string Branch { get; set; }
public static bool TryParse(string input, out InformationalVersion version)
{
version = default(InformationalVersion);
var trim = input.TrimStart('v');
var info = trim.Split('-');
var info = trim.Split(new[]{'-'}, 2);
if (!Version.TryParse(info[0], out Version result))
return false;
version = new InformationalVersion { Version = result };
if (info.Length > 1)
version.Information = info.Skip(1).ToArray();
version.Branch = info[1];
return true;
}
/// <inheritdoc />
public override string ToString()
{
if (Information == null || Information.Length == 0)
if (Branch == null)
return $"v{Version}";
return $"v{Version}-{string.Join("-", Information)}";
return $"v{Version}-{string.Join("-", Branch)}";
}
public static explicit operator InformationalVersion(Version v)
@@ -48,5 +48,15 @@ namespace Torch.API
{
return v.Version;
}
public static bool operator >(InformationalVersion lhs, InformationalVersion rhs)
{
return lhs.Version > rhs.Version;
}
public static bool operator <(InformationalVersion lhs, InformationalVersion rhs)
{
return lhs.Version < rhs.Version;
}
}
}