Skip to content

Myrddyn/GitObjectDb

 
 

Repository files navigation

GitObjectDb

GitObjectDb simplifies the configuration management versioning by backing it in Git.

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:

  1. Define your own data model by inheriting from AbstractObjectRepository:
    public class ObjectRepository : AbstractObjectRepository
    {
        public ObjectRepository(IServiceProvider serviceProvider, Guid id, string name, ILazyChildren<IMigration> migrations, ILazyChildren<Application> applications)
            : base(serviceProvider, id, name, migrations)
        {
            Applications = (applications ?? throw new ArgumentNullException(nameof(applications))).AttachToParent(this);
        }
    
        public ILazyChildren<Application> Applications { get; }
    }
    Note that this object contains Applications of type ILazyChildren<Application>. That's how you can create nested objects. They must be of type ILazyChildren<Application>.
  2. Create nested object types:
    [DataContract]
    public class Application : AbstractModel
    {
        public Application(IServiceProvider serviceProvider, Guid id, string name, ILazyChildren<Page> pages)
            : base(serviceProvider, id, name)
        {
            Pages = (pages ?? throw new ArgumentNullException(nameof(pages))).AttachToParent(this);
        }
    
        public ILazyChildren<Page> Pages { get; }
    }
  3. Basic commands
    • Initialize a new repository

      var repo = new ObjectRepository(...);
      repo.SaveInNewRepository(signature, message, new RepositoryDescription(path));
    • Commit a new change

      var modifiedPage = page.With(p => p.Name == "modified");
      instance.Commit(modifiedPage.Repository, signature, message);
    • Branch management

    • Migrations:

      Migrations allows to define any action that must be executed when the commit containing the migration will be processed by a pull. See the unit tests for more details.

    • Pre/post commit hook

Prerequisites

  • Windows: .NET 4.0+
  • Linux/Mac OS X: Mono 3.6+

Online resources

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)

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C# 100.0%