feat: Add GitRepoRegistration cmdlets #5

Merged
pascal_nulah merged 69 commits from feature/git-provider into dev 2026-09-06 09:33:36 +10:00
Owner

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

Adds cmdlets for registering a git repo by name. [Full documentation for the commands](https://moar.ws/git/pascal_nulah/Nulah.PowerShell/src/commit/cece927b3f924280aeb6681d19282870d4b65a2f/docs/GitRepositoryRegistration.md) (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
- add CopyLocalLockFileAssemblies to PowershellModule.csproj
- add postbuild script to copy Sqlite files and remove unneeded files in debug output
- add sqlite-net-pcl 1.11.285
- move GitManager to ModuleCore
- refactor SetGitRepoCommand to own file
- make ModuleCore internals visible to ModuleTests
- change setters to init when parsing git folders
- change Console.WriteLine to Debug.WriteLine in GitManager constructor
- rename private GitRegistration to InternalGitRegistration
- update PostBuild.ps1 to not delete data directory created during debug
- move sqlite-net-pcl to ModuleCore
- add way to redirect debug output
- remove unique constraint on Location
- move WriteDebug to IsGitRepo
- inline variable for SessionState.Path.CurrentLocation.Path
- create solution folder for docs
- output when no name is given
- update message when current location is confirmed to be a git repo
- update comments for related classes and methods
pascal_nulah added this to the Git project 2026-09-02 14:12:02 +10:00
pascal_nulah added this to the v1.0.0 milestone 2026-09-02 14:12:37 +10:00
pascal_nulah added spent time 2026-09-02 14:15:30 +10:00
3 days
pascal_nulah added spent time 2026-09-02 14:15:43 +10:00
3 days
pascal_nulah added spent time 2026-09-03 22:09:52 +10:00
2 hours
@ -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.
Author
Owner

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?

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?
Author
Owner
[Create a pre-release action that triggers when tagged commits are pushed in a PR #7](https://moar.ws/git/pascal_nulah/Nulah.PowerShell/issues/7)
pascal_nulah marked this conversation as resolved
@ -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 function
Author
Owner

todo: Will document this later, probably as a readme in the output bundle so everything can be stand alone

todo: Will document this later, probably as a readme in the output bundle so everything can be stand alone
Author
Owner
Covered by [Flesh out script setup to create aliases and set up custom prompt #8](https://moar.ws/git/pascal_nulah/Nulah.PowerShell/issues/8)
pascal_nulah marked this conversation as resolved
@ -49,0 +147,4 @@
# Just the module: Use the following to just import just the powershell module
# Import-Module -Name "$PSScriptRoot/NulahModule/PowershellModule"
function SetupNulahPowershell
Author
Owner

todo: Make a ticket for adding cmdlet aliases later

todo: Make a ticket for adding cmdlet aliases later
Author
Owner
[Flesh out script setup to create aliases and set up custom prompt #8](https://moar.ws/git/pascal_nulah/Nulah.PowerShell/issues/8)
pascal_nulah marked this conversation as resolved
pascal_nulah added spent time 2026-09-03 22:19:12 +10:00
15 minutes
- adjust the BaseSourceLocation to be absolute
- refactor getting the PowershellModule version to Helpers.cs
@ -0,0 +33,4 @@
/// </summary>
public ConvertableFilePath CreateModuleManifestScript { get; set; }
public string BuildSuffix { get; set; }
Author
Owner

todo: Document public property

todo: Document public property
pascal_nulah marked this conversation as resolved
@ -0,0 +34,4 @@
public ConvertableFilePath CreateModuleManifestScript { get; set; }
public string BuildSuffix { get; set; }
public bool DisableCommitHash { get; set; }
Author
Owner

todo: Document public property

todo: Document public property
pascal_nulah marked this conversation as resolved
@ -0,0 +6,4 @@
public class Helpers
{
public static string GetPowershellModuleVersion(string powershelModuleOutputLocation)
Author
Owner

todo: Document public method

todo: Document public method
pascal_nulah marked this conversation as resolved
build/Program.cs Outdated
@ -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")
Author
Owner

todo: Make this build configuration controlled in DefaultTask where the build context is first available or alternatively do so in BuildContext itself 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.

todo: Make this build configuration controlled in `DefaultTask` where the build context is first available or alternatively do so in `BuildContext` itself 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.
Author
Owner

Decided to make pre-release the default build suffix and move it to the BuildContext

Decided to make `pre-release` the default build suffix and move it to the `BuildContext`
pascal_nulah marked this conversation as resolved
@ -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 script
Author
Owner

note: Make follow up ticket for this, not majorly important

note: Make follow up ticket for this, not majorly important
Author
Owner
[Refactor file paths used in build project to be more explict and easier to understand #10](https://moar.ws/git/pascal_nulah/Nulah.PowerShell/issues/10)
pascal_nulah marked this conversation as resolved
@ -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.
Author
Owner

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

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
Author
Owner
[Update build project to support linux builds #9](https://moar.ws/git/pascal_nulah/Nulah.PowerShell/issues/9)
pascal_nulah marked this conversation as resolved
@ -0,0 +26,4 @@
}
}
public void InConnection(Action<SQLiteConnection> dbAction)
Author
Owner

todo: Document public method

todo: Document public method
pascal_nulah marked this conversation as resolved
@ -0,0 +32,4 @@
dbAction(conn);
}
public T InConnection<T>(Func<SQLiteConnection, T> dbAction)
Author
Owner

todo: Document public method

todo: Document public method
pascal_nulah marked this conversation as resolved
@ -0,0 +22,4 @@
InitialiseRegistrations();
}
public static GitManager Instance => GitManagerInstance.Value;
Author
Owner

todo: Document public property

todo: Document public property
pascal_nulah marked this conversation as resolved
@ -0,0 +185,4 @@
.ToList();
}
public string GetRepo(string? registeredName)
Author
Owner

todo: Document public method

todo: Document public method
pascal_nulah marked this conversation as resolved
@ -0,0 +118,4 @@
});
}
public void UnregisterRepo(string registrationName)
Author
Owner

todo: Document public method

todo: Document public method
pascal_nulah marked this conversation as resolved
@ -0,0 +128,4 @@
,{nameof(InternalGitRegistration.Name)}
,{nameof(InternalGitRegistration.Location)}
FROM {InternalGitRegistration.TableName}
WHERE {nameof(InternalGitRegistration.Name)} = ?
Author
Owner

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

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
Author
Owner
[Investigate if user supplied input for commands for SQLite are a concern or not #14](https://moar.ws/git/pascal_nulah/Nulah.PowerShell/issues/14)
pascal_nulah marked this conversation as resolved
@ -0,0 +1,8 @@
namespace ModuleCore.Git.Models;
public class GitRegistration
Author
Owner

todo: Document public model class

todo: Document public model class
pascal_nulah marked this conversation as resolved
pascal_nulah added spent time 2026-09-05 13:04:51 +10:00
1 hour
pascal_nulah added spent time 2026-09-05 13:20:45 +10:00
20 minutes
- rename GetRepo to GetDirectoryForRegisteredRepo so it's actually doing what it says
pascal_nulah added spent time 2026-09-05 13:42:31 +10:00
20 minutes
pascal_nulah added spent time 2026-09-05 13:45:46 +10:00
5 minutes
@ -0,0 +5,4 @@
namespace ModuleTests.Git;
public class AddRegistrationTests
Author
Owner

todo: All of the tests in this suite should be wrapped in a try .. finally with the finally block calling DeleteDatabase so 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 the finally block never being called)

todo: All of the tests in this suite should be wrapped in a `try .. finally` with the finally block calling `DeleteDatabase` so 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 the `finally` block never being called)
Author
Owner
[GitRepoRegistration tests should reset database at start of each test #12](https://moar.ws/git/pascal_nulah/Nulah.PowerShell/issues/12)
pascal_nulah marked this conversation as resolved
pascal_nulah added spent time 2026-09-05 13:50:19 +10:00
2 minutes
pascal_nulah added spent time 2026-09-06 08:49:41 +10:00
30 minutes
@ -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 now
private string GetCurrentBranch()
Author
Owner

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

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
Author
Owner
[Create GitManager to centralise calls to git process #13](https://moar.ws/git/pascal_nulah/Nulah.PowerShell/issues/13)
pascal_nulah marked this conversation as resolved
pascal_nulah changed title from WIP: feat: Add GitRepoRegistration cmdlets to feat: Add GitRepoRegistration cmdlets 2026-09-06 09:17:02 +10:00
pascal_nulah added spent time 2026-09-06 09:17:21 +10:00
30 minutes
Author
Owner

closes: #6

closes: #6
pascal_nulah deleted branch feature/git-provider 2026-09-06 09:33:36 +10:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Total time spent: 6 days 5 hours
pascal_nulah
6 days 5 hours
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Depends on
#6 Create GitRepoRegistration cmdlets
pascal_nulah/Nulah.PowerShell
Reference
pascal_nulah/Nulah.PowerShell!5
No description provided.