refactor!: rename Titano to Chronos and move CI and releases to Gitea (#6)
CI / Build and test (push) Successful in 8m14s
CI / Windows tests and installer (push) Skipped
CI / YAML check (push) Successful in 7s
Release / Build, test and publish (push) Successful in 13m19s
CI / PostgreSQL 16 integration (push) Successful in 4m49s
CI / PostgreSQL 17 integration (push) Successful in 5m28s
CI / Docker image (push) Successful in 53s
Release / Server image (push) Failing after 10s

The owner renamed the product and moved the repository to the self-hosted
Gitea (https://gitea.encke-hake.ts.net/BalboSoft/Chronos) for more control,
and asked for Actions and a first automatic release with the server package
and the Windows exe (docs/requests/2026-10-23-chronos-gitea.md).

- Chronos everywhere: a byte-exact rename of contents and paths, then a
  per-language review of the forms the old name's ending had dictated.
- Gitea instead of GitHub: the update check, licence, issue and support
  links read ChronosReleasesUrl; the update check takes the highest stable
  version, offers a pre-release build its final release and reports a
  repository it cannot see as a failed check. EULA, security policy and
  Gitea issue forms live at the repository root.
- Gitea Actions for the Linux act_runner (.gitea/workflows): CI, release,
  nightly image and performance gates in the .NET SDK container with git
  checkout and the system SQLite. The release cross-compiles the Windows
  programs, checks their icon, version and DPI manifest, packs installers
  and zips, publishes the Gitea release and pushes the server image
  (REGISTRY_TOKEN). Windows-only tests run in an opt-in job on a Windows
  runner (WINDOWS_RUNNER).
- New Chronos.Tools commands: zip, gitea-release, postgres-ci (replaces the
  docker-exec script, which Gitea's service containers do not allow; the
  throw-away server runs without durability) and pe-check.
- Timed tests take their budget from TestTiming (CHRONOS_TEST_TIME_FACTOR,
  3 on the shared runner; the weekly performance gates keep theirs).

BREAKING CHANGE: programs, settings, data folders, file types, environment
variables and the Docker image use the new name; nothing is migrated from
Titano, which never had a release.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: Alberto Balbo <alberto.balbo.96@gmail.com>
This commit was merged in pull request #6.
This commit is contained in:
Alby96andClaude Opus 5.5 authored and Alby96 committed 2026-10-23 12:45:18 +02:00
1 parent c99842cc86
commit f2b58522b9
1801 files changed
+11804 -10676

No files matched your search

+174
View File
@@ -0,0 +1,174 @@
using System.Globalization;
using System.Text.Json;
using Chronos.Core.IO;
using Chronos.Core.Localization;
using Chronos.Core.Naming;
namespace Chronos.Core.Archiving;
/// <summary>What the planner needs to know about a sequence to rename it.</summary>
public sealed record RenameSubject(Guid SequenceId, string Folder, string? Title, DateTime? FirstCapture, string? CameraMake, string? CameraModel, string? Lens);
/// <summary>One sequence's change: its folder, its title, or both.</summary>
/// <param name="Carried">The folder moves only because a folder it is inside moves (a sequence nested in another).</param>
public sealed record RenameStep(Guid SequenceId, string FromFolder, string ToFolder, string? FromTitle, string? ToTitle, bool Carried = false)
{
public bool MovesFolder => !string.Equals(FromFolder, ToFolder, StringComparison.Ordinal);
}
/// <summary>A planned folder would lie inside a sequence's folder (nesting one sequence in another); nothing is planned.</summary>
public sealed class NestedRenameException(string target, string folder)
: ArgumentException(Loc.L("Archive.Error.NestedTarget", target, folder))
{
public string Target { get; } = target;
public string Folder { get; } = folder;
}
/// <summary>The exact changes a mass rename will make (its dry run); applying it makes exactly these.</summary>
public sealed record RenamePlan(Guid Id, Guid ArchiveId, IReadOnlyList<RenameStep> Steps);
/// <summary>A plan being applied, with the steps already completed; lets an interrupted rename resume (BRIEF §7).</summary>
public sealed record RenameJournal(RenamePlan Plan, IReadOnlyList<Guid> Completed)
{
public static string PathFor(ArchivePaths archive, Guid planId) => Path.Combine(archive.JournalDirectory, $"rename-{planId:N}.json");
public static void Write(ArchivePaths archive, RenameJournal journal)
{
Directory.CreateDirectory(archive.JournalDirectory);
AtomicFile.WriteAllBytes(PathFor(archive, journal.Plan.Id), JsonSerializer.SerializeToUtf8Bytes(journal, ArchiveJsonIndented.Default.RenameJournal));
}
/// <summary>Journals left by interrupted renames.</summary>
public static IReadOnlyList<RenameJournal> ListPending(ArchivePaths archive)
{
if (!Directory.Exists(archive.JournalDirectory)) return [];
var list = new List<RenameJournal>();
foreach (var path in Directory.EnumerateFiles(archive.JournalDirectory, "rename-*.json").Order(StringComparer.Ordinal))
{
if (JsonSerializer.Deserialize(File.ReadAllBytes(path), ArchiveJson.Default.RenameJournal) is { } journal) list.Add(journal);
}
return list;
}
public static void Delete(ArchivePaths archive, Guid planId) => File.Delete(PathFor(archive, planId));
}
/// <summary>Builds rename plans from folder/title templates (BRIEF §7.1, §12.5).</summary>
public static class RenamePlanner
{
/// <summary>
/// Expands <paramref name="titleTemplate"/> (where <c>{title}</c> is the current title) and then
/// <paramref name="folderTemplate"/> (where <c>{title}</c> is the new title) for every subject. A target folder
/// that is any current sequence folder, exists on disk or was given to an earlier subject gets " (2)", " (3)"….
/// Null templates leave that part unchanged; subjects without a change produce no step. A folder that moves takes
/// the sequences inside it along: each gets a <see cref="RenameStep.Carried"/> step after every move, so the index
/// follows its files; a selected sequence inside a moving folder that moves elsewhere leaves first.
/// </summary>
/// <param name="occupied">Every sequence folder of the archive (renamed or not).</param>
/// <param name="nested">The archive's other sequences inside a subject's folder, with their titles.</param>
/// <exception cref="NestedRenameException">A target lies inside a sequence's folder, or inside another target.</exception>
public static RenamePlan Plan(Guid archiveId, IReadOnlyList<RenameSubject> subjects, string? folderTemplate, string? titleTemplate,
IEnumerable<string> occupied, Func<string, bool> existsOnDisk, IReadOnlyList<RenameSubject>? nested = null)
{
var folder = folderTemplate is null ? null : PathTemplate.Parse(folderTemplate);
var title = titleTemplate is null ? null : PathTemplate.Parse(titleTemplate);
var taken = occupied.ToList();
var claimed = new HashSet<string>(taken, StringComparer.OrdinalIgnoreCase);
var own = new List<RenameStep>(subjects.Count);
foreach (var s in subjects)
{
var context = new NamingContext
{
CapturedAt = s.FirstCapture ?? DateTime.Today,
SessionStart = s.FirstCapture ?? DateTime.Today,
CameraMake = s.CameraMake,
CameraModel = s.CameraModel,
Lens = s.Lens,
Title = s.Title,
};
var newTitle = title is null ? s.Title : Blank(title.ExpandFile(context)) ?? s.Title;
var newFolder = s.Folder;
// The archive root itself (a folder adopted in place) cannot move; only its title changes.
if (folder is not null && s.Folder.Length > 0 && Blank(folder.ExpandFolder(context with { Title = newTitle })) is { } expanded
&& !expanded.Equals(s.Folder, StringComparison.Ordinal))
{
newFolder = expanded.Equals(s.Folder, StringComparison.OrdinalIgnoreCase) ? expanded : Unique(expanded, claimed, existsOnDisk);
claimed.Add(newFolder);
}
own.Add(new RenameStep(s.SequenceId, s.Folder, newFolder, s.Title, newTitle));
}
var moving = own.Where(s => s.MovesFolder).ToList();
foreach (var step in moving)
{
// Into a sequence's folder (its own included) or another target: one sequence would end up inside another.
var host = taken.Concat(moving.Where(m => m != step).Select(m => m.ToFolder)).FirstOrDefault(f => IsInside(f, step.ToFolder));
if (host is not null) throw new NestedRenameException(step.ToFolder, host);
}
var steps = new List<(RenameStep Step, int Order)>();
foreach (var step in own.Concat((nested ?? []).Select(n => new RenameStep(n.SequenceId, n.Folder, n.Folder, n.Title, n.Title))))
{
// The nearest folder around it that moves carries it; a sequence that moves elsewhere leaves before its folder does.
var carrier = step.MovesFolder ? null : moving.Where(m => IsInside(m.FromFolder, step.FromFolder)).MaxBy(m => m.FromFolder.Length);
if (carrier is not null)
steps.Add((step with { ToFolder = carrier.ToFolder + step.FromFolder[carrier.FromFolder.Length..], Carried = true }, 1));
else if (step.MovesFolder)
steps.Add((step, -moving.Count(m => m != step && IsInside(m.FromFolder, step.FromFolder))));
else if (step.FromTitle != step.ToTitle)
steps.Add((step, 0));
}
// Stable: subjects keep their order, sequences inside moving folders move out first, carried ones come last.
return new RenamePlan(Guid.CreateVersion7(), archiveId, [.. steps.OrderBy(s => s.Order).Select(s => s.Step)]);
}
/// <summary>
/// Whether <paramref name="path"/> lies inside <paramref name="folder"/> (archive-relative, forward slashes); the
/// archive root, a sequence only when a folder was adopted in place, counts as containing nothing.
/// </summary>
public static bool IsInside(string folder, string path) =>
folder.Length > 0 && path.Length > folder.Length + 1 && path[folder.Length] == '/' && path.StartsWith(folder, StringComparison.OrdinalIgnoreCase);
/// <summary>
/// Moves the folder of a step; idempotent so a resumed plan can repeat it: an already moved folder is accepted,
/// a case-only change goes through a temporary name (case-insensitive file systems).
/// </summary>
/// <exception cref="IOException">The target is occupied by something else, or neither folder exists.</exception>
public static void MoveFolder(ArchivePaths archive, RenameStep step)
{
if (!step.MovesFolder) return;
var from = archive.FromRelative(step.FromFolder);
var to = archive.FromRelative(step.ToFolder);
var caseOnly = step.FromFolder.Equals(step.ToFolder, StringComparison.OrdinalIgnoreCase);
if (Directory.Exists(to) && (!caseOnly || HasExactName(to)))
{
if (Directory.Exists(from) && !caseOnly) throw new IOException($"Rename target {step.ToFolder} already exists.");
return;
}
if (!Directory.Exists(from)) throw new DirectoryNotFoundException($"Sequence folder {step.FromFolder} is missing.");
Directory.CreateDirectory(Path.GetDirectoryName(to)!);
if (caseOnly)
{
var temp = from + ".rename-" + Guid.NewGuid().ToString("N")[..8];
Directory.Move(from, temp);
Directory.Move(temp, to);
}
else
{
Directory.Move(from, to);
}
}
private static bool HasExactName(string path) =>
Directory.EnumerateDirectories(Path.GetDirectoryName(path)!, Path.GetFileName(path))
.Any(d => Path.GetFileName(d).Equals(Path.GetFileName(path), StringComparison.Ordinal));
private static string? Blank(string value) => string.IsNullOrWhiteSpace(value) ? null : value;
private static string Unique(string folder, HashSet<string> claimed, Func<string, bool> existsOnDisk)
{
var candidate = folder;
for (var n = 2; claimed.Contains(candidate) || existsOnDisk(candidate); n++)
candidate = string.Create(CultureInfo.InvariantCulture, $"{folder} ({n})");
return candidate;
}
}