Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,15 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
NuGetApiKey: ${{ secrets.NUGET_API_KEY }}
- name: 'Publish: tests'
uses: actions/upload-artifact@v4
if: always()
with:
name: tests
path: output/tests
- name: 'Publish: nuget'
uses: actions/upload-artifact@v4
if: always()
with:
name: nuget
path: output/nuget
8 changes: 0 additions & 8 deletions NuGet.Config

This file was deleted.

41 changes: 19 additions & 22 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,10 @@ Here's a simple example:
```
2. Manipulate objects as follows:
```csharp
var existingApplication = connection.Lookup<Application>("main", "applications", new UniqueId(id));
var existingApplication = await connection.LookupAsync<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));
var updates = await connection.UpdateAsync("main", c => c.CreateOrUpdateAsync(newTable, parent: existingApplication));
await updates.CommitAsync(new("Added new table.", author, committer));
```

# Features
Expand Down Expand Up @@ -84,19 +83,15 @@ new Resource(node, "Some/Folder", "File.txt", new Resource.Data("Value stored in
## Branching

```csharp
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));
connection.Branches.Add("newBranch", "main~1");
var updates = await connection.UpdateAsync("main", c => c.CreateOrUpdateAsync(table with { Name = newName }));
await updates..CommitAsync(new("Another message", signature, signature));
```

## Comparing commits

```csharp
var comparison = connection.Compare("main~5", "main");
var comparison = await connection.CompareAsync("main~5", "main");
var nodeChanges = comparison.Modified.OfType<Change.NodeChange>();
```

Expand All @@ -116,7 +111,7 @@ 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();
var order = (await connection.GetNodesAsync<Order>("main", referenceCache: cache)).First();
Console.WriteLine(order.Client.Id);
```

Expand All @@ -127,15 +122,17 @@ Console.WriteLine(order.Client.Id);
// \ -> \ \
// newBranch: C C---x

connection
.Update("main", c => c.CreateOrUpdate(table with { Description = newDescription }))
.Commit(new("B", signature, signature));
var mainChanges = await connection.Update("main", c => c.CreateOrUpdateAsync(table with { Description = newDescription }));
await mainChanges.CommitAsync(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));
var newBranchChanges = await connection.UpdateAsync("newBranch", c => c.CreateOrUpdateAsync(table with { Name = newName }));
await newBranchChanges.CommitAsync(new("C", signature, signature));

sut.Merge(upstreamCommittish: "main");
var merge = await sut.MergeAsync(branchName: "newBranch", upstreamCommittish: "main");
if (merge.Status = MergeStatus.Conflicts)
{
// ...
}
```

## Node versioning management
Expand Down Expand Up @@ -200,9 +197,9 @@ See [documentation][Documentation].

# Online resources

- [LibGit2Sharp][LibGit2Sharp] (Requires NuGet 2.7+)
- [GitDotNet][GitDotNet] (Requires NuGet 2.7+)

[LibGit2Sharp]: https://github.com/libgit2/libgit2sharp
[GitDotNet]: https://github.com/frblondin/GitDotNet

# Quick contributing guide

Expand Down
6 changes: 5 additions & 1 deletion build/Build.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
using System.Xml.Linq;
using Nuke.Common.CI.GitHubActions.Configuration;
using static Nuke.Common.EnvironmentInfo;
using static Nuke.Common.IO.FileSystemTasks;
using static Nuke.Common.IO.PathConstruction;
using static Nuke.Common.Tooling.ProcessTasks;
using static Nuke.Common.Tools.DotNet.DotNetTasks;
Expand Down Expand Up @@ -54,6 +53,7 @@

InvokedTargets = [nameof(Pack)],
ImportSecrets = ["GITHUB_TOKEN", "SONAR_TOKEN", nameof(NuGetApiKey)],
PublishCondition = "always()",
FetchDepth = 0)]
class Build : NukeBuild
{
Expand Down Expand Up @@ -162,6 +162,7 @@ class Build : NukeBuild

Target Test => _ => _
.DependsOn(Compile)
.Produces(TestDirectory / "**/*.dmp")
.Executes(() =>
{
Collect(new DotNetCollectSettings()
Expand All @@ -173,6 +174,9 @@ class Build : NukeBuild
.EnableNoRestore()
.SetLoggers("trx")
.AddProcessAdditionalArguments("-m:1") // Make sure only one assembly gets tested at a time for coverage collect
.AddProcessAdditionalArguments("--timeout", "600000") // 10 minutes timeout per test
.AddProcessAdditionalArguments("--blame-hang-timeout", "2m") // Kill hanging tests
.AddProcessAdditionalArguments("--blame-hang-dump-type", "full") // Get full dump for hanging tests
.SetResultsDirectory(TestDirectory))
.SetConfigFile(SourceDirectory / "CoverageConfig.xml")
.SetFormat("xml")
Expand Down
10 changes: 5 additions & 5 deletions build/_build.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Nuke.Common" Version="9.0.3" />
<PackageReference Include="Nuke.Common" Version="9.0.4" />
</ItemGroup>

<ItemGroup>
<PackageDownload Include="dotnet-coverage" Version="[17.13.1]" />
<PackageDownload Include="dotnet-sonarscanner" Version="[9.0.2]" />
<PackageDownload Include="nbgv" Version="[3.7.112]" />
<PackageDownload Include="ReportGenerator" Version="[5.4.1]" />
<PackageDownload Include="dotnet-coverage" Version="[17.14.2]" />
<PackageDownload Include="dotnet-sonarscanner" Version="[10.3.0]" />
<PackageDownload Include="nbgv" Version="[3.7.115]" />
<PackageDownload Include="ReportGenerator" Version="[5.4.12]" />
</ItemGroup>

</Project>
5 changes: 4 additions & 1 deletion build/_build.csproj.DotSettings
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/PLACE_SIMPLE_ANONYMOUSMETHOD_ON_SINGLE_LINE/@EntryValue">False</s:Boolean>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/PredefinedNamingRules/=PrivateInstanceFields/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" /&gt;</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/PredefinedNamingRules/=PrivateStaticFields/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" /&gt;</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/UserRules/=4a98fdf6_002D7d98_002D4f5a_002Dafeb_002Dea44ad98c70c/@EntryIndexedValue">&lt;Policy&gt;&lt;Descriptor Staticness="Instance" AccessRightKinds="Private" Description="Instance fields (private)"&gt;&lt;ElementKinds&gt;&lt;Kind Name="FIELD" /&gt;&lt;Kind Name="READONLY_FIELD" /&gt;&lt;/ElementKinds&gt;&lt;/Descriptor&gt;&lt;Policy Inspect="True" WarnAboutPrefixesAndSuffixes="False" Prefix="" Suffix="" Style="AaBb" /&gt;&lt;/Policy&gt;</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/UserRules/=f9fce829_002De6f4_002D4cb2_002D80f1_002D5497c44f51df/@EntryIndexedValue">&lt;Policy&gt;&lt;Descriptor Staticness="Static" AccessRightKinds="Private" Description="Static fields (private)"&gt;&lt;ElementKinds&gt;&lt;Kind Name="FIELD" /&gt;&lt;/ElementKinds&gt;&lt;/Descriptor&gt;&lt;Policy Inspect="True" WarnAboutPrefixesAndSuffixes="False" Prefix="" Suffix="" Style="AaBb" /&gt;&lt;/Policy&gt;</s:String>
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ECSharpAttributeForSingleLineMethodUpgrade/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ECSharpKeepExistingMigration/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ECSharpPlaceEmbeddedOnSameLineMigration/@EntryIndexedValue">True</s:Boolean>
Expand All @@ -24,4 +26,5 @@
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ESettingsUpgrade_002EAddAccessorOwnerDeclarationBracesMigration/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ESettingsUpgrade_002ECSharpPlaceAttributeOnSameLineMigration/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ESettingsUpgrade_002EMigrateBlankLinesAroundFieldToBlankLinesAroundProperty/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ESettingsUpgrade_002EMigrateThisQualifierSettings/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary>
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ESettingsUpgrade_002EMigrateThisQualifierSettings/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ESettingsUpgrade_002EPredefinedNamingRulesToUserRulesUpgrade/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary>
12 changes: 5 additions & 7 deletions docs/basic/10-commit-changes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,11 @@ Direct update

.. code-block:: csharp

connection
.Update("main", c => c.CreateOrUpdate(table, parent: application))
.Commit("Added table.", author, committer);
var updates = await connection.UpdateAsync("main", c => c.CreateOrUpdateAsync(table, parent: application));
await updates.CommitAsync("Added table.", author, committer);

.. note::
Within the Update(...) method, multiple transformations can be defined using nested calls.
Within the UpdateAsync(...) method, multiple transformations can be defined using nested calls.


Stage in the index, then commit
Expand All @@ -23,9 +22,8 @@ Previous method stores transformation in-memory then creates a commit. In the ca

.. code-block:: csharp

connection
.GetIndex("main", c => c.CreateOrUpdate(table, parent: application))
.Commit("Added table.", author, committer);
var index = await connection.GetIndexAsync("main", c => c.CreateOrUpdateAsync(table, parent: application));
await index.CommitAsync("Added table.", author, committer);

.. note::
Since GitObjectDb uses a bare repository, the internal Git index database file cannot be used. GitObjectDb uses its own independant dbindex file that has the advantage that multiple indices can be used simultaneously on different branches.
10 changes: 3 additions & 7 deletions docs/basic/15-branches.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,6 @@ Direct update

.. code-block:: csharp

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));
connection.Repository.Branches.Add("newBranch", "main~1");
var updates = await connection.UpdateAsync("main", c => c.CreateOrUpdateAsync(table with { Name = newName }));
await updates.CommitAsync(new("Another message", signature, signature));
2 changes: 1 addition & 1 deletion docs/basic/20-comparing-commits.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ Log can be analyzed to extract changes made to nodes and resources.

.. code-block:: csharp

var comparison = connection.Compare("main~5", "main");
var comparison = await connection.CompareAsync("main~5", "main");
var nodeChanges = comparison.Modified.OfType<Change.NodeChange>();
2 changes: 1 addition & 1 deletion docs/basic/25-node-references.rst
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,5 @@ Node references allows linking existing nodes in a repository.
}
// Nodes get loaded with their references (using a shared )
var cache = new Dictionary<DataPath, ITreeItem>();
var order = connection.GetNodes<Order>("main", referenceCache: cache).First();
var order = (await connection.GetNodesAsync<Order>("main", referenceCache: cache)).First();
Console.WriteLine(order.Client.Id);
16 changes: 9 additions & 7 deletions docs/basic/30-merging-rebasing-cherry-picking.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,14 @@ Just like with Git, GitObjectDb let you do these different operations.
// \ -> \ \
// newBranch: C C---x

connection
.Update("main", c => c.CreateOrUpdate(table with { Description = newDescription }))
.Commit(new("B", signature, signature));
var mainUpdates = await connection.UpdateAsync("main", c => c.CreateOrUpdateAsync(table with { Description = newDescription }));
await mainUpdates.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));
var newBranchUpdates = await connection.UpdateAsync("newBranch", c => c.CreateOrUpdateAsync(table with { Name = newName }));
await newBranchUpdates.CommitAsync(new("C", signature, signature));

sut.Merge(upstreamCommittish: "main");
var merge = await sut.MergeAsync(branchName: "newBranch", upstreamCommittish: "main");
if (merge.Status = MergeStatus.Conflicts)
{
// ...
}
10 changes: 9 additions & 1 deletion nuget.config
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,14 @@
<packageSources>
<!--To inherit the global NuGet package sources remove the <clear/> line below -->
<clear />
<add key="nuget" value="https://api.nuget.org/v3/index.json" />
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" />
</packageSources>

<!-- Define mappings by adding package patterns beneath the target source. -->
<packageSourceMapping>
<!-- key value for <packageSource> should match key values from <packageSources> element -->
<packageSource key="nuget.org">
<package pattern="*" />
</packageSource>
</packageSourceMapping>
</configuration>
Loading
Loading