2024-03-17 18:37:06 -07:00
|
|
|
|
using System;
|
2021-04-29 05:05:55 -07:00
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
2024-03-17 18:37:06 -07:00
|
|
|
|
using Avalonia;
|
|
|
|
|
|
|
|
|
|
namespace SourceGit.Models
|
|
|
|
|
{
|
|
|
|
|
public class Commit
|
|
|
|
|
{
|
2023-10-09 20:25:57 -07:00
|
|
|
|
public string SHA { get; set; } = string.Empty;
|
|
|
|
|
public User Author { get; set; } = User.Invalid;
|
|
|
|
|
public ulong AuthorTime { get; set; } = 0;
|
|
|
|
|
public User Committer { get; set; } = User.Invalid;
|
|
|
|
|
public ulong CommitterTime { get; set; } = 0;
|
|
|
|
|
public string Subject { get; set; } = string.Empty;
|
|
|
|
|
public string Message { get; set; } = string.Empty;
|
2021-04-29 05:05:55 -07:00
|
|
|
|
public List<string> Parents { get; set; } = new List<string>();
|
|
|
|
|
public List<Decorator> Decorators { get; set; } = new List<Decorator>();
|
|
|
|
|
public bool HasDecorators => Decorators.Count > 0;
|
|
|
|
|
public bool IsMerged { get; set; } = false;
|
|
|
|
|
public Thickness Margin { get; set; } = new Thickness(0);
|
2023-10-09 20:25:57 -07:00
|
|
|
|
|
2024-02-05 23:08:37 -08:00
|
|
|
|
public string AuthorTimeStr => _utcStart.AddSeconds(AuthorTime).ToString("yyyy/MM/dd HH:mm:ss");
|
|
|
|
|
public string CommitterTimeStr => _utcStart.AddSeconds(CommitterTime).ToString("yyyy/MM/dd HH:mm:ss");
|
|
|
|
|
public string AuthorTimeShortStr => _utcStart.AddSeconds(AuthorTime).ToString("yyyy/MM/dd");
|
|
|
|
|
public string CommitterTimeShortStr => _utcStart.AddSeconds(CommitterTime).ToString("yyyy/MM/dd");
|
|
|
|
|
|
2024-03-17 18:37:06 -07:00
|
|
|
|
public bool IsCommitterVisible
|
|
|
|
|
{
|
2024-02-05 23:08:37 -08:00
|
|
|
|
get => Author != Committer || AuthorTime != CommitterTime;
|
|
|
|
|
}
|
|
|
|
|
|
2024-04-01 03:11:22 -07:00
|
|
|
|
public bool IsCurrentHead
|
|
|
|
|
{
|
2024-05-25 11:05:32 -07:00
|
|
|
|
get => Decorators.Find(x => x.Type is DecoratorType.CurrentBranchHead or DecoratorType.CurrentCommitHead) != null;
|
2024-04-01 03:11:22 -07:00
|
|
|
|
}
|
|
|
|
|
|
2024-03-17 18:37:06 -07:00
|
|
|
|
public string FullMessage
|
|
|
|
|
{
|
2024-02-05 23:08:37 -08:00
|
|
|
|
get => string.IsNullOrWhiteSpace(Message) ? Subject : $"{Subject}\n\n{Message}";
|
|
|
|
|
}
|
2023-10-09 20:25:57 -07:00
|
|
|
|
|
2024-02-05 23:08:37 -08:00
|
|
|
|
private static readonly DateTime _utcStart = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc).ToLocalTime();
|
2021-04-29 05:05:55 -07:00
|
|
|
|
}
|
2024-03-31 01:54:29 -07:00
|
|
|
|
}
|