GitObjectDb 0.2.99-alpha
See the version list below for details.
dotnet add package GitObjectDb --version 0.2.99-alpha
NuGet\Install-Package GitObjectDb -Version 0.2.99-alpha
<PackageReference Include="GitObjectDb" Version="0.2.99-alpha" />
paket add GitObjectDb --version 0.2.99-alpha
#r "nuget: GitObjectDb, 0.2.99-alpha"
// Install GitObjectDb as a Cake Addin #addin nuget:?package=GitObjectDb&version=0.2.99-alpha&prerelease // Install GitObjectDb as a Cake Tool #tool nuget:?package=GitObjectDb&version=0.2.99-alpha&prerelease
GitObjectDb simplifies the configuration management versioning by backing it in Git.
Name | Badge |
---|---|
GitObjectDb | |
GitObjectDb.Api | |
GitObjectDb.Api.OData | |
GitObjectDb.Api.GraphQL |
Overview
GitObjectDb is designed to simplify the configuration management versioning. It does so by removing the need for hand-coding the commands needed to interact with Git.
The Git repository is used as a pure database as the files containing the serialized copy of the objects are never fetched in the filesystem. GitObjectDb only uses the blob storage provided by Git.
Here's a simple example:
- Define your own repository data model:
[GitFolder("Applications")] public record Application : Node { public string Name { get; set; } public string Description { get; set; } } [GitFolder("Pages")] public record Table : Node { public string Name { get; set; } public string Description { get; set; } }
- Manipulate objects as follows:
var existingApplication = connection.Lookup<Application>("main", "applications", new UniqueId(id)); var newTable = new Table { ... }; connection .Update("main", c => c.CreateOrUpdate(newTable, parent: existingApplication)) .Commit(new("Added new table.", author, committer));
Features
Structured & unstructured data storage
var node = new SomeNode
{
SomeProperty = "Value stored as json",
EmbeddedResource = "Value stored as raw text in same Git blob",
}:
... gets stored in Git as follows:
{
"$type": "Sample.SomeNode",
"id": "zerzrzrz",
"someProperty": "Value stored as json"
}
/*
Value stored as raw text in same Git blob
*/
You can also store resources as separate files:
new Resource(node, "Some/Folder", "File.txt", new Resource.Data("Value stored in a separate file in <node path>/Resources/Some/Folder/File.txt"));
Branching
connection
.Update("main", c => c.CreateOrUpdate(table with { Description = newDescription }))
.Commit(new("Some message", signature, signature));
connection.Checkout("newBranch", "main~1");
connection
.Update("main", c => c.CreateOrUpdate(table with { Name = newName }))
.Commit(new("Another message", signature, signature));
History
var commits = sut.Commits
.QueryBy(new CommitFilter
{
IncludeReachableFrom = "main~10",
SortBy = CommitSortStrategies.Reverse | CommitSortStrategies.Topological,
})
.Take(5)
Compare commits
var comparison = connection.Compare("main~5", "main");
var nodeChanges = comparison.Modified.OfType<Change.NodeChange>();
Node references
Node references allows linking existing nodes in a repository:
public record Order : Node
{
public Client Client { get; set; }
// ...
}
public record Client : Node
{
// ...
}
// Nodes get loaded with their references (using a shared )
var cache = new Dictionary<DataPath, ITreeItem>();
var order = connection.GetNodes<Order>("main", referenceCache: cache).First();
Console.WriteLine(order.Client.Id);
Merge, Rebase, Cherry-pick
// main: A---B A---B
// \ -> \ \
// newBranch: C C---x
connection
.Update("main", c => c.CreateOrUpdate(table with { Description = newDescription }))
.Commit(new("B", signature, signature));
connection.Repository.Branches.Add("newBranch", "main~1");
connection
.Update("newBranch", c => c.CreateOrUpdate(table with { Name = newName }))
.Commit(new("C", signature, signature));
sut.Merge(upstreamCommittish: "main");
Node versioning management
Imagine a scenario where you define in your code a first type:
[GitFolder(FolderName = "Items", UseNodeFolders = false)]
[IsDeprecatedNodeType(typeof(SomeNodeV2))]
private record SomeNodeV1 : Node
{
public int Flags { get; set; }
}
[GitFolder(FolderName = "Items", UseNodeFolders = false)]
private record SomeNodeV2 : Node
{
public BindingFlags TypedFlags { get; set; }
}
You then want to introduce a new change so that the Flags
property contains more meaningful information, relying on enums:
[GitFolder(FolderName = "Items", UseNodeFolders = false)]
private record SomeNodeV2 : Node
{
public BindingFlags TypedFlags { get; set; }
}
All you need to do is to #1 add the [IsDeprecatedNodeType(typeof(SomeNodeV2))]
attribute. This will instruct the deserializer to convert nodes to new version, using a converter. #2 converter needs to be provided in the model. You can use AutoMapper or other tools at your convenience.
[GitFolder(FolderName = "Items", UseNodeFolders = false)]
[IsDeprecatedNodeType(typeof(SomeNodeV2))]
private record SomeNodeV1 : Node
{
// ...
}
var model = new ConventionBaseModelBuilder()
.RegisterType<SomeNodeV1>()
.RegisterType<SomeNodeV2>()
.AddDeprecatedNodeUpdater(UpdateDeprecatedNode)
.Build();
Node UpdateDeprecatedNode(Node old, Type targetType)
{
var nodeV1 = (SomeNodeV1)old;
return new SomeNodeV2
{
Id = old.Id,
TypedFlags = (BindingFlags)nodeV1.Flags,
};
}
Documentation
See Documentation.
Prerequisites
- .NET Standard 2.0 or 2.1
Online resources
- LibGit2Sharp (Requires NuGet 2.7+)
Quick contributing guide
- Fork and clone locally
- Create a topic specific branch. Add some nice feature. Do not forget the tests 😉
- Send a Pull Request to spread the fun!
License
The MIT license (Refer to the LICENSE file).
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
.NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.0 is compatible. netstandard2.1 is compatible. |
.NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen40 was computed. tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.0
- CompareNETObjects (>= 4.78.0)
- fasterflect.reflect (>= 3.1.0)
- LibGit2Sharp (>= 0.27.0-preview-0182)
- Microsoft.Extensions.Caching.Abstractions (>= 6.0.0)
- Microsoft.Extensions.Caching.Memory (>= 6.0.1)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 6.0.0)
- Microsoft.Extensions.Logging (>= 6.0.0)
- System.Collections.Immutable (>= 6.0.0)
- System.Runtime.Caching (>= 6.0.0)
-
.NETStandard 2.1
- CompareNETObjects (>= 4.78.0)
- fasterflect.reflect (>= 3.1.0)
- LibGit2Sharp (>= 0.27.0-preview-0182)
- Microsoft.Extensions.Caching.Abstractions (>= 6.0.0)
- Microsoft.Extensions.Caching.Memory (>= 6.0.1)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 6.0.0)
- Microsoft.Extensions.Logging (>= 6.0.0)
- System.Collections.Immutable (>= 6.0.0)
- System.Runtime.Caching (>= 6.0.0)
NuGet packages (6)
Showing the top 5 NuGet packages that depend on GitObjectDb:
Package | Downloads |
---|---|
GitObjectDb.SystemTextJson
Provides a Json serialization based on System.Text.Json for GitObjectDb nodes. |
|
GitObjectDb.Api.GraphQL
Provides GraphQL endpoints for querying and mutating GitObjectDb repository. |
|
GitObjectDb.Api.OData
Provides OData endpoints for querying GitObjectDb repository. |
|
GitObjectDb.YamlDotNet
Provides a Yaml serialization based on YamlDotNet for GitObjectDb nodes. |
|
GitObjectDb.Api.ProtoBuf
Provides Grpc endpoints for querying GitObjectDb repository. |
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
0.2.155-alpha | 59 | 3/29/2024 |
0.2.142-alpha | 211 | 12/6/2023 |
0.2.141-alpha | 97 | 11/15/2023 |
0.2.140-alpha | 91 | 11/9/2023 |
0.2.138-alpha | 105 | 10/2/2023 |
0.2.136-alpha | 80 | 9/26/2023 |
0.2.134-alpha | 78 | 9/22/2023 |
0.2.133-alpha | 160 | 5/19/2023 |
0.2.130-alpha | 85 | 5/12/2023 |
0.2.129-alpha | 80 | 5/12/2023 |
0.2.128-alpha | 100 | 4/5/2023 |
0.2.123-alpha | 108 | 3/28/2023 |
0.2.114-alpha | 117 | 3/7/2023 |
0.2.113-alpha | 100 | 3/7/2023 |
0.2.112-alpha | 103 | 3/7/2023 |
0.2.111-alpha | 115 | 2/4/2023 |
0.2.99-alpha | 125 | 12/22/2022 |
0.2.97-alpha | 115 | 11/15/2022 |
0.2.94-alpha | 124 | 10/18/2022 |
0.2.92-alpha | 118 | 9/28/2022 |
0.2.85-alpha | 135 | 9/22/2022 |
0.2.83-alpha | 122 | 9/21/2022 |