public static RepoVersion Build(Patchalyzer patchalyzer, SemVersion version, string path, string name, string changelog = "", long releaseDate = -1) { RepoConfig config = patchalyzer.GetRepoConfig(); string repoPath = patchalyzer.GetRepoPath(); // If releaseDate is missing then set it to the current time. if (releaseDate == -1) { releaseDate = DateTimeOffset.Now.ToUnixTimeSeconds(); } RepoVersion repoVersion = new RepoVersion { Name = name, ReleaseDate = releaseDate, Changelog = changelog }; bool isUpdate = false; // Check if a previous version exists if (config.LatestVersion != null && config.Versions.ContainsKey(config.LatestVersion)) { SemVersion latestVersion; if (SemVersion.TryParse(config.LatestVersion, out latestVersion)) { isUpdate = (latestVersion < version); } } repoVersion.Files = isUpdate ? AddFiles(repoPath, version, path, config.LatestVersion, config.Versions[config.LatestVersion]) : AddFiles(repoPath, version, path); repoVersion.DeletedFiles = isUpdate ? GetDeletedFiles(repoVersion.Files, config.Versions[config.LatestVersion].Files) : new List <string>(); return(repoVersion); }
static void Main(string[] args) { if (Directory.Exists("..//Tests//ExampleRepo//")) { Directory.Delete("..//Tests//ExampleRepo//", true); } Patchalyzer proj = Patchalyzer.InitRepo("..//Tests//ExampleRepo//", "ExampleRepo"); proj.AddVersion(new SemVersion(1), "..//Tests//ExampleProject//v1", "Initial Release", "The first release"); proj.AddVersion(new SemVersion(1, 1), "..//Tests//ExampleProject//v2", "Update", "We changed logo.png and added a new file"); proj.SaveRepo(); // Wait for user input Console.WriteLine("Press any key to continue..."); Console.ReadKey(); }