diff --git a/build/BuildContext.cs b/build/BuildContext.cs index 50c41ee..a4c2588 100644 --- a/build/BuildContext.cs +++ b/build/BuildContext.cs @@ -33,7 +33,17 @@ public class BuildContext : FrostingContext /// public ConvertableFilePath CreateModuleManifestScript { get; set; } + /// + /// Suffix to tag the build with, defaults to pre-release. + /// + /// Immediately follows the version number and before the commit hash. + /// + /// public string BuildSuffix { get; set; } + + /// + /// Disable the commit hash from being added + /// public bool DisableCommitHash { get; set; } public BuildContext(ICakeContext context) @@ -45,7 +55,7 @@ public class BuildContext : FrostingContext PowershellModuleOutputDir = context.Directory("../") + context.Directory("output") + context.Directory("PowershellModule"); var buildScriptDirectory = context.Directory("./Scripts"); CreateModuleManifestScript = buildScriptDirectory + context.File("CreateModuleManifest.ps1"); - BuildSuffix = context.Configuration.GetValue(nameof(BuildSuffix)); + BuildSuffix = context.Configuration.GetValue(nameof(BuildSuffix)) ?? "pre-release"; DisableCommitHash = context.Configuration.GetBoolValue(nameof(DisableCommitHash)); } } \ No newline at end of file diff --git a/build/Helpers.cs b/build/Helpers.cs index 95855e6..a8f2bcb 100644 --- a/build/Helpers.cs +++ b/build/Helpers.cs @@ -6,8 +6,14 @@ namespace Build; public class Helpers { + /// + /// Returns a formatted version of the assembly that contains PowerShell cmdlets + /// + /// + /// public static string GetPowershellModuleVersion(string powershelModuleOutputLocation) { + // When the project name changes, this dll will also need to be updated var moduleVersionInfo = FileVersionInfo.GetVersionInfo(Path.Combine(powershelModuleOutputLocation, "PowershellModule.dll")); // It's (almost) impossible to not have a product version tag here. There is a reason why the implementation diff --git a/build/Program.cs b/build/Program.cs index 4d9909c..d94f389 100644 --- a/build/Program.cs +++ b/build/Program.cs @@ -8,8 +8,6 @@ public static class Program { return new CakeHost() .UseContext() - // Uncomment this if you don't want to set the suffix via the run profile program arguments - .UseCakeSetting(nameof(BuildContext.BuildSuffix), "pre-release") .Run(args); } } \ No newline at end of file diff --git a/src/ModuleCore/Database/DatabaseManager.cs b/src/ModuleCore/Database/DatabaseManager.cs index beac4f2..f4e8afe 100644 --- a/src/ModuleCore/Database/DatabaseManager.cs +++ b/src/ModuleCore/Database/DatabaseManager.cs @@ -26,12 +26,22 @@ public class DatabaseManager } } + /// + /// Runs the given action within a new database connection + /// + /// public void InConnection(Action dbAction) { using var conn = new SQLiteConnection(_databaseLocation.FullName); dbAction(conn); } + /// + /// Runs the given func in a new database connection, returning the result + /// + /// + /// + /// public T InConnection(Func dbAction) { using var conn = new SQLiteConnection(_databaseLocation.FullName); diff --git a/src/ModuleCore/Git/GitManager.cs b/src/ModuleCore/Git/GitManager.cs index bd7a135..f16a313 100644 --- a/src/ModuleCore/Git/GitManager.cs +++ b/src/ModuleCore/Git/GitManager.cs @@ -24,6 +24,10 @@ public class GitManager InitialiseRegistrations(); } + /// + /// Returns the current instance. If no instance has been created, returns a new instance + /// and then the same instance every call after. + /// public static GitManager Instance => GitManagerInstance.Value; /// @@ -128,6 +132,11 @@ public class GitManager }); } + /// + /// Unregisters a git repo registration by name. If no registration exists an exception will be thrown. + /// + /// + /// public void UnregisterRepo(string registrationName) { _db.InConnection(conn => @@ -195,7 +204,13 @@ public class GitManager .ToList(); } - public string GetRepo(string? registeredName) + /// + /// Returns the file location for a git repo registration by name. + /// + /// + /// + /// + public string GetDirectoryForRegisteredRepo(string? registeredName) { if (string.IsNullOrEmpty(registeredName)) { diff --git a/src/ModuleCore/Git/Models/GitRegistration.cs b/src/ModuleCore/Git/Models/GitRegistration.cs index 1a94184..8c38d03 100644 --- a/src/ModuleCore/Git/Models/GitRegistration.cs +++ b/src/ModuleCore/Git/Models/GitRegistration.cs @@ -1,8 +1,21 @@ namespace ModuleCore.Git.Models; +/// +/// Details for a registered git repo +/// public class GitRegistration { + /// + /// Display name for the registration. Can either be the name of the repo retrieved from git, or a user supplied + /// alias + /// public required string Name { get; set; } + /// + /// Location on disk for the top level of the registered git repo. Not guaranteed to exist on disk + /// public required string Location { get; set; } + /// + /// Current branch for the git repo + /// public required string CurrentBranch { get; set; } } \ No newline at end of file diff --git a/src/PowershellModule/Git/Commands/ShowGitRepoRegistrationCommand.cs b/src/PowershellModule/Git/Commands/ShowGitRepoRegistrationCommand.cs index a0e6e85..4300f71 100644 --- a/src/PowershellModule/Git/Commands/ShowGitRepoRegistrationCommand.cs +++ b/src/PowershellModule/Git/Commands/ShowGitRepoRegistrationCommand.cs @@ -21,7 +21,7 @@ public class ShowGitRepoRegistrationCommand : PSCmdlet protected override void BeginProcessing() { - var location = GitManager.Instance.GetRepo(Name); + var location = GitManager.Instance.GetDirectoryForRegisteredRepo(Name); // By default instead of doing the same as cd, we instead do pushd so a user can popd straight back to where // they came from.