-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Repo fixes, remove rule application, and update documentation (#54)
This allows checkout of a branch when no commits exists, create a tracked branch, and remove a rule application from a branch. This also update the documentation to have a better quickstart sample. This fixes #51, #52, #53.
- Loading branch information
1 parent
ff3f085
commit cbfcf47
Showing
14 changed files
with
798 additions
and
257 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
mode: ContinuousDelivery | ||
next-version: 0.1.0 | ||
next-version: 0.2.0 | ||
branches: {} | ||
ignore: | ||
sha: [] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,80 +1,88 @@ | ||
# Git Storage for InRule | ||
InRuleGitStorage | ||
==== | ||
|
||
This project adds support for storing and managing InRule rule applications in a custom Git repository. | ||
[](https://www.nuget.org/packages/Sknet.InRuleGitStorage) | ||
|
||
## Getting Started | ||
This project allows you to store and manage your [InRule](https://www.inrule.com/)® business rules in a Git repository as an alternative to the built-in support of the file system and irCatalog. | ||
|
||
### Installing | ||
# Features | ||
|
||
- Initialize a new InRule git repository | ||
- Open an existing InRule git repository | ||
- Clone, pull from, and push to a remote InRule git repository | ||
- Create, remove, and checkout a branch | ||
- Commit (serialize a `RuleApplicationDef` into a git commit) | ||
- Merge branches (_merge conflict support is a work in progress_) | ||
- Get rule application (deserialize the current branch into a `RuleApplicationDef`) | ||
- Get a list of rule applications | ||
|
||
# Quickstart | ||
|
||
## Installing | ||
|
||
```powershell | ||
Install-Package Sknet.InRuleGitStorage -IncludePrerelease | ||
``` | ||
|
||
## Usage | ||
|
||
### Create a new repository | ||
```csharp | ||
InRuleGitRepository.Init(@"C:\path\to\your\repo"); | ||
```batch | ||
dotnet add package Sknet.InRuleGitStorage --version 0.2.0 | ||
``` | ||
|
||
### Create your first commit | ||
```csharp | ||
using (var repo = InRuleGitRepository.Open(@"C:\path\to\your\repo")) | ||
{ | ||
var ruleAppDef = new RuleApplicationDef("MyRuleApp"); | ||
## Basic example | ||
|
||
var identity = new Identity("Alex Doe", "[email protected]"); | ||
var signature = new Signature(identity, DateTimeOffset.Now); | ||
repo.Commit(ruleAppDef, "My first commit", signature, signature); | ||
} | ||
``` | ||
|
||
### Get a rule application from the current branch | ||
```csharp | ||
using (var repo = InRuleGitRepository.Open(@"C:\path\to\your\repo")) | ||
// Create a new repository in a local directory | ||
InRuleGitRepository.Init("/path/to/local/repo"); | ||
|
||
// Get a new instance of your local InRule Git repository | ||
using (var repo = InRuleGitRepository.Open("/path/to/local/repo")) | ||
{ | ||
var ruleAppDef = repo.GetRuleApplication("MyRuleApp"); | ||
// Create a new rule application and commit it to the "master" branch | ||
var ruleApp = new RuleApplicationDef("QuickstartSample"); | ||
repo.Commit(ruleApp, "Add quickstart sample rule application"); | ||
|
||
// Get the rule application from the Git repository | ||
ruleApp = repo.GetRuleApplication("QuickstartSample"); | ||
} | ||
``` | ||
|
||
## Examples | ||
|
||
### Create multiple commits across different branches | ||
## Remote repository example | ||
|
||
```csharp | ||
var repoPath = Path.Combine( | ||
Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), | ||
"MyInRuleRepository"); | ||
|
||
var identity = new Identity("John Doe", "[email protected]"); | ||
// Clone the public samples repository to a local directory | ||
InRuleGitRepository.Clone( | ||
sourceUrl: "https://github.com/stevenkuhn/InRuleGitStorage-Samples.git", | ||
destinationPath: "/path/to/local/repo"); | ||
|
||
// Create a repository in the current user's _My Documents_ folder | ||
InRuleGitRepository.Init(repoPath); | ||
using (var repo = InRuleGitRepository.Open(repoPath)) | ||
// Get a new instance of your local InRule Git repository | ||
using (var repo = InRuleGitRepository.Open("/path/to/local/repo")) | ||
{ | ||
// Update the rule application and create commits in `master`. | ||
var ruleAppDef = new RuleApplicationDef("MyRuleApp"); | ||
var entityDef = ruleAppDef.Entities.Add(new EntityDef("MyEntity")); | ||
|
||
repo.Commit(ruleAppDef, "My first commit", | ||
new Signature(identity, DateTimeOffset.Now), | ||
new Signature(identity, DateTimeOffset.Now)); | ||
|
||
entityDef.Fields.Add(new FieldDef("MyField1", DataType.String)); | ||
|
||
repo.Commit(ruleAppDef, "My second commit", | ||
new Signature(identity, DateTimeOffset.Now), | ||
new Signature(identity, DateTimeOffset.Now)); | ||
|
||
// Create a new branch called `my-new-branch` and set it as the current branch. | ||
repo.CreateBranch("my-new-branch"); | ||
repo.Checkout("my-new-branch"); | ||
entityDef.Fields.Add(new FieldDef("MyField2", DataType.String)); | ||
entityDef.Fields.Add(new FieldDef("MyField3", DataType.Integer)); | ||
|
||
// Update the rule application and commit the change to `my-new-branch`. | ||
repo.Commit(ruleAppDef, "My third commit", | ||
new Signature(identity, DateTimeOffset.Now), | ||
new Signature(identity, DateTimeOffset.Now)); | ||
// Create a local branch that is tracked to the remote "v0.2.0" branch | ||
repo.CreateTrackedBranch("v0.2.0", "origin"); | ||
|
||
// Switch the current branch to the newly created tracked branch | ||
repo.Checkout("v0.2.0"); | ||
|
||
// Create a local branch from the "v0.2.0" branch | ||
repo.CreateBranch("invoice-date-field"); | ||
|
||
// Switch the current branch to the newly created local branch | ||
repo.Checkout("invoice-date-field"); | ||
|
||
// Get the InvoiceSample rule application from the repository, add an invoice date | ||
// field, and commit that change to the current branch | ||
var ruleApp = repo.GetRuleApplication("InvoiceSample"); | ||
ruleApp.Entities["Invoice"].Fields.Add(new FieldDef("Date", DataType.DateTime)); | ||
repo.Commit(ruleApp, "Add invoice date field"); | ||
|
||
// Switch back to the previous branch that does not have the field change | ||
repo.Checkout("v0.2.0"); | ||
|
||
// Merge the invoice date field change into the current branch | ||
repo.Merge("invoice-date-field"); | ||
|
||
// Delete the original branch containing the invoice date field change since the | ||
// change now exists in the "v0.2.0" branch | ||
repo.RemoveBranch("invoice-date-field"); | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.