feat: Add GitRepoRegistration cmdlets #5
No reviewers
Labels
No labels
area:build
area:git
area:intrinsics
area:prompts
area:tests
breaking-change
discussion
docs
enhancement
feature
requires-docs-update
No project
No assignees
1 participant
Notifications
Total time spent: 6 days 5 hours
Due date
pascal_nulah
6 days 5 hours
No due date set.
Depends on
#6 Create GitRepoRegistration cmdlets
pascal_nulah/Nulah.PowerShell
Reference
pascal_nulah/Nulah.PowerShell!5
Loading…
Reference in a new issue
No description provided.
Delete branch "feature/git-provider"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Adds cmdlets for registering a git repo by name.
Full documentation for the commands (and what I'd basically be putting in this description anyway)
Build
Adds an initial build project using Cake.Frosting. This project will also tag the current commit with a version tag with the intent to be used in the future to trigger an action to run this build to create a release and automatically create a pre-release for it.
Tests
Adds tests for GitRepoProvider cmdlets, they aren't fully in-depth, but cover the basic surface level implementations for now.
Pre-Releases
Pre-releases created to verify without building from source
https://moar.ws/git/pascal_nulah/Nulah.PowerShell/releases/tag/0.0.1-pre-release+69e0f824
@ -49,0 +124,4 @@context.Log.Information($"Bundle files copied");GenerateModuleImportScript(bundleOutputLocation, context);// TODO: zip the bundle directory contents to NulahModule.zip, and have a top level folder inside that called NulahModule.todo(maybe): Create a pre-release action for this in a later ticket for when I want to do PRs for easier checking later maybe?
Create a pre-release action that triggers when tagged commits are pushed in a PR #7
@ -49,0 +135,4 @@using var scriptFile = File.Create(Path.Combine(bundleLocation, "NulahPowershell.ps1"));using var fileWriter = new StreamWriter(scriptFile);// TODO: Document the set up functiontodo: Will document this later, probably as a readme in the output bundle so everything can be stand alone
Covered by Flesh out script setup to create aliases and set up custom prompt #8
@ -49,0 +147,4 @@# Just the module: Use the following to just import just the powershell module# Import-Module -Name "$PSScriptRoot/NulahModule/PowershellModule"function SetupNulahPowershelltodo: Make a ticket for adding cmdlet aliases later
Flesh out script setup to create aliases and set up custom prompt #8
@ -0,0 +33,4 @@/// </summary>public ConvertableFilePath CreateModuleManifestScript { get; set; }public string BuildSuffix { get; set; }todo: Document public property
@ -0,0 +34,4 @@public ConvertableFilePath CreateModuleManifestScript { get; set; }public string BuildSuffix { get; set; }public bool DisableCommitHash { get; set; }todo: Document public property
@ -0,0 +6,4 @@public class Helpers{public static string GetPowershellModuleVersion(string powershelModuleOutputLocation)todo: Document public method
@ -12,2 +9,4 @@return new CakeHost().UseContext<BuildContext>()// Uncomment this if you don't want to set the suffix via the run profile program arguments.UseCakeSetting(nameof(BuildContext.BuildSuffix), "pre-release")todo: Make this build configuration controlled in
DefaultTaskwhere the build context is first available or alternatively do so inBuildContextitself as that seems to be what the Cake docs hint at.They aren't very good docs though but that's hardly surprising for most things.
Decided to make
pre-releasethe default build suffix and move it to theBuildContext@ -13,3 +15,4 @@public override void Run(BuildContext context){var powershellModuleName = "PowershellModule";// TODO: probably don't create full file locations when I can pass the output dir in and have the scriptnote: Make follow up ticket for this, not majorly important
Refactor file paths used in build project to be more explict and easier to understand #10
@ -0,0 +48,4 @@// // from the executing assembly directory first, and the built output of the module includes a lot of other dlls that// // are already available with the dotnet runtime so there's no need for us to include them.// // I mean, we could, but we'd also be terrible software engineers if we couldn't do something as basic as reducing files we need.// // TODO: Account for other runtimes such as linux based ones where the dotnet runtime might _not_ provide these files for free.note: Make a ticket for this later, I don't see myself getting around to it in any speed but it'd be good to have a ticket number to keep note of it at least
Update build project to support linux builds #9
@ -0,0 +26,4 @@}}public void InConnection(Action<SQLiteConnection> dbAction)todo: Document public method
@ -0,0 +32,4 @@dbAction(conn);}public T InConnection<T>(Func<SQLiteConnection, T> dbAction)todo: Document public method
@ -0,0 +22,4 @@InitialiseRegistrations();}public static GitManager Instance => GitManagerInstance.Value;todo: Document public property
@ -0,0 +185,4 @@.ToList();}public string GetRepo(string? registeredName)todo: Document public method
@ -0,0 +118,4 @@});}public void UnregisterRepo(string registrationName)todo: Document public method
@ -0,0 +128,4 @@,{nameof(InternalGitRegistration.Name)},{nameof(InternalGitRegistration.Location)}FROM {InternalGitRegistration.TableName}WHERE {nameof(InternalGitRegistration.Name)} = ?thought: Not sure if I should be suspect about this as the value is coming from arbitrary user supplied input, but also it's a local sqlite database and if an attacker has access to the command that could exploit this then they already have the same privileges (or higher) than the current user so it's very who cares to me
Investigate if user supplied input for commands for SQLite are a concern or not #14
@ -0,0 +1,8 @@namespace ModuleCore.Git.Models;public class GitRegistrationtodo: Document public model class
@ -0,0 +5,4 @@namespace ModuleTests.Git;public class AddRegistrationTeststodo: All of the tests in this suite should be wrapped in a
try .. finallywith the finally block callingDeleteDatabaseso test databases don't linger around.Alternatively (or in addition to), each test should attempt to rest any previously existing database with a
ResetDatabase()method for instances where a test is run in debug with breakpoints and a dev hits stop instead of letting the test fail (which will result in thefinallyblock never being called)GitRepoRegistration tests should reset database at start of each test #12
@ -0,0 +340,4 @@public string CurrentBranch => GetCurrentBranch();// TODO: not fully decided on if I want this feature or not, but keeping it in for nowprivate string GetCurrentBranch()nit: I think this method should be made public and moved to a class that centralises calls to a git process. I can tell it'll cause me hassles in the future if I don't
Create ticket for this issue
Create GitManager to centralise calls to git process #13
WIP: feat: Add GitRepoRegistration cmdletsto feat: Add GitRepoRegistration cmdletscloses: #6