Safe Haskell | None |
---|---|
Language | Haskell2010 |
BDCS.API.Recipes
Description
Git Recipe storage functions
Recipes are stored in a bare git repository. The repository is created with
openOrCreateRepo
which returns the Repository which is passed to all of
the other functions.
- openOrCreateRepo :: FilePath -> IO Repository
- findOrCreateBranch :: Repository -> Text -> IO Branch
- getBranchOIdFromObject :: Repository -> Branch -> IO OId
- writeCommit :: Repository -> Text -> Text -> Text -> ByteString -> IO OId
- readCommit :: Repository -> Text -> Text -> Maybe Text -> IO ByteString
- readCommitSpec :: Repository -> Text -> IO ByteString
- listBranchFiles :: Repository -> Text -> IO [Text]
- listCommitFiles :: Repository -> Commit -> IO [Text]
- deleteFile :: Repository -> Text -> Text -> IO OId
- deleteRecipe :: Repository -> Text -> Text -> IO OId
- revertFile :: Repository -> Text -> Text -> Text -> IO OId
- revertFileCommit :: Repository -> Text -> Text -> OId -> IO OId
- revertRecipe :: Repository -> Text -> Text -> Text -> IO OId
- listRecipeCommits :: Repository -> Text -> Text -> IO [CommitDetails]
- listCommits :: Repository -> Text -> Text -> IO [CommitDetails]
- findCommitTag :: Repository -> Text -> Text -> OId -> IO (Maybe Text)
- getRevisionFromTag :: Maybe Text -> Maybe Int
- tagFileCommit :: Repository -> Text -> Text -> IO Bool
- tagRecipeCommit :: Repository -> Text -> Text -> IO Bool
- commitRecipeFile :: Repository -> Text -> FilePath -> IO OId
- commitRecipe :: Repository -> Text -> Recipe -> IO OId
- commitRecipeDirectory :: Repository -> Text -> FilePath -> IO [OId]
- readRecipeCommit :: Repository -> Text -> Text -> Maybe Text -> IO (Either String Recipe)
- recipeDiff :: Recipe -> Recipe -> [RecipeDiffEntry]
- runGitRepoTests :: IO Bool
- runWorkspaceTests :: IO Bool
- data CommitDetails = CommitDetails {}
- data RecipeDiffEntry = RecipeDiffEntry {}
- data RecipeDiffType
- data GitError
- = OpenRepoError
- | CreateRepoError
- | CreateBlobError
- | CreateCommitError
- | CreateBranchError
- | BranchNameError
- | WriteTreeError
- | GetIndexError
- | GetHeadError
- | RefLookupError
- | TreeBuilderError
- | GetByNameError
- | GetNameError
- | GetTargetError
- | GetTimeError
- | GetTimeZoneError
- | GetTreeError
- | GetTreeIdError
- | GetCommitterError
- | GetMessageError
- | GetParentsError
- | LookupError
- | LookupBlobError
- | LookupBranchError
- | LookupCommitError
- | LookupTagError
- | LookupTreeError
- | LookupReferenceError
- | RevparseError
- | BuilderWriteError
- | BuilderInsertError
- | GetEntryIdError
- | GetIdError
- | GetRawBlobError
- | GetTargetIdError
- | NewOIdError
- | NewOptionsError
- | NewTimeValError
- | NewTreeError
- | NewSignatureError
- | NewWalkerError
- | OIdError
- printOId :: OId -> IO ()
Documentation
openOrCreateRepo :: FilePath -> IO Repository Source #
Open a Git repository, or create the initial repository if one doesn't exist
path
- Path to the git repository
The bare git repository is created in ./git underneath path If the directory doesn't look like an existing git repo (no .gitHEAD file) then a new bare repository is created.
Can throw OpenRepoError
, CreateRepoError
, NewSignatureError
, GetIndexError
,
WriteTreeError
, LookupTreeError
, or CreateCommitError
findOrCreateBranch :: Repository -> Text -> IO Branch Source #
Lookup the Branch name or create a new branch and return a Git.Branch
repo
- Open git repository
branch
- Branch name
Can throw GetHeadError
, RefLookupError
, or CreateBranchError
getBranchOIdFromObject :: Repository -> Branch -> IO OId Source #
Convert a Branch object to an OId
repo
- Open git repository
branch
- Branch name
Can throw BranchNameError
, LookupReferenceError
, or GetTargetError
writeCommit :: Repository -> Text -> Text -> Text -> ByteString -> IO OId Source #
Make a new commit to a repository's branch
repo
- Open git repository
branch
- Branch name
filename
- Filename of the commit
message
- Commit message
content
- Data to be written to the commit
Returns the OId of the new commit.
Can throw CreateBlobError
, GetTreeError
, TreeBuilderError
, BuilderInsertError
, or CreateCommitError
readCommit :: Repository -> Text -> Text -> Maybe Text -> IO ByteString Source #
Read a commit and return a ByteString of the content
repo
- Open git repository
branch
- Branch name
filename
- Filename of the commit
commit
- Commit hash to read, or Nothing to read the HEAD
TODO Return the commit message too
readCommitSpec :: Repository -> Text -> IO ByteString Source #
Read a commit usinga revspec, return the ByteString content
repo
- Open git repository
spec
- revspec to read.
eg. <commit>:<filename> or <branch>:<filename>
Can throw RevparseError
, GetIdError
, LookupBlobError
, or GetRawBlobError
listBranchFiles :: Repository -> Text -> IO [Text] Source #
List the files on a branch
repo
- Open git repository
branch
- Branch name
listCommitFiles :: Repository -> Commit -> IO [Text] Source #
List the files in a commit
repo
- Open git repository
commit
- The commit to get the files from
Can throw GetTreeIdError
, or LookupTreeError
deleteFile :: Repository -> Text -> Text -> IO OId Source #
Delete a file from a branch
repo
- Open git repository
branch
- Branch name
filename
- The recipe filename to delete
Can throw GetTreeError
, TreeBuilderError
, or CreateCommitError
deleteRecipe :: Repository -> Text -> Text -> IO OId Source #
Delete a recipe from a branch
repo
- Open git repository
branch
- Branch name
recipe_name
- The recipe name to delete (not the filename)
revertFile :: Repository -> Text -> Text -> Text -> IO OId Source #
Revert a recipe file to a previous commit
repo
- Open git repository
branch
- Branch name
filename
- The recipe filename to revert
commit
- The commit hash string to revert to
Can throw NewOIdError
revertFileCommit :: Repository -> Text -> Text -> OId -> IO OId Source #
Revert a recipe file to a previous commit
repo
- Open git repository
branch
- Branch name
filename
- The recipe filename to revert
commit
- The commit object to revert to
Can throw LookupCommitError
, GetTreeError
, GetByNameError
, GetEntryIdError
, GetTreeError
,
'', OIdError
, CreateCommitError
revertRecipe :: Repository -> Text -> Text -> Text -> IO OId Source #
Revert a recipe to a previous commit
repo
- Open git repository
branch
- Branch name
recipe_name
- The recipe name to revert (not the filename)
commit
- The commit hash string to revert to
listRecipeCommits :: Repository -> Text -> Text -> IO [CommitDetails] Source #
List the commits for a recipe
repo
- Open git repository
branch
- Branch name
recipe_name
- Recipe name (not filename)
Returns a list of CommitDetails
listCommits :: Repository -> Text -> Text -> IO [CommitDetails] Source #
List the commits for a filename
repo
- Open git repository
branch
- Branch name
filename
- Recipe filename
Returns a list of CommitDetails
Can throw NewWalkerError
findCommitTag :: Repository -> Text -> Text -> OId -> IO (Maybe Text) Source #
Find the revision tag pointing to a specific commit
repo
- Open git repository
branch
- Branch name
filename
- Recipe filename
commit_id
- The commit OId
The Tag is of the form refstags<branch><filename>r<revision> There should only be one result.
getRevisionFromTag :: Maybe Text -> Maybe Int Source #
Get the revision number from a git tag
mtag
- The tag string to extract the revision from
The Tag is of the form refstags<branch><filename>r<revision>
Returns the revision from the tag, or Nothing
tagFileCommit :: Repository -> Text -> Text -> IO Bool Source #
Tag a file's most recent commit
repo
- Open git repository
branch
- Branch name
filename
- Recipe filename
This uses git tags, of the form refstags<branch><filename>r<revision> Only the most recent recipe commit can be tagged to prevent out of order tagging. Revisions start at 1 and increment for each new commit that is tagged. If the commit has already been tagged it will return False.
Can throw NewSignatureError
, NewOIdError
, LookupError
tagRecipeCommit :: Repository -> Text -> Text -> IO Bool Source #
Tag a recipe's most recent commit
repo
- Open git repository
branch
- Branch name
recipe_name
- Recipe name (not filename)
Returns True if it is successful
commitRecipeFile :: Repository -> Text -> FilePath -> IO OId Source #
Commit a Recipe TOML file
repo
- Open git repository
branch
- Branch name
filename
- Recipe filename
Returns the OId of the new commit
commitRecipe :: Repository -> Text -> Recipe -> IO OId Source #
Commit a Recipe record to a branch
repo
- Open git repository
branch
- Branch name
recipe
- Recipe record
If there is already an existing recipe this will bump or replace the
version number depending on what the new recipe contains. See the rules
in bumpVersion
commitRecipeDirectory :: Repository -> Text -> FilePath -> IO [OId] Source #
Commit recipes from a directory, if they don't already exist
repo
- Open git repository
branch
- Branch name
directory
- Directory to read the recipes from
This reads all files ending in .toml from the directory, skipping recipes that are already in the branch.
readRecipeCommit :: Repository -> Text -> Text -> Maybe Text -> IO (Either String Recipe) Source #
Read a Recipe from a commit
repo
- Open git repository
branch
- Branch name
recipe_name
- Recipe name (not filename)
commit
- The commit hash string to read
If the recipe isn't found it returns a Left
recipeDiff :: Recipe -> Recipe -> [RecipeDiffEntry] Source #
Find the differences between two recipes
oldRecipe
- The old version of the Recipe
newRecipe
- The new version of the Recipe
This calculates the differences between the recipes, returning a list of RecipeDiffEntry
.
The order is always the same, Name, Description, Version, removed Modules, added Modules,
removed Packages, added Packages, and then packages with different versions.
runGitRepoTests :: IO Bool Source #
Run the Git repository tests with a temporary directory
runWorkspaceTests :: IO Bool Source #
Run the Workspace tests with a temporary directory
data RecipeDiffEntry Source #
A difference entry
This uses RecipeDiffType to indicate the type of difference between recipe fields.
If old is set and new is None it means the entry was removed If old is None and new is set it means the entry was added If both are set then old the the old content and new is the new content
Constructors
RecipeDiffEntry | |
Fields |
data RecipeDiffType Source #
Type of Diff Entry
Used by RecipeDiffEntry's old and new fields
Errors that can be thrown by the BDCS.API.Recipes functions.
Constructors
OpenRepoError | Repo open error |
CreateRepoError | Problem creating a new repo |
CreateBlobError | New Blob error |
CreateCommitError | Error creating a commit |
CreateBranchError | New Branch error |
BranchNameError | Branch name error, eg. doesn't exist |
WriteTreeError | Tree writing error |
GetIndexError | Error getting the repository error |
GetHeadError | Error getting the repository head |
RefLookupError | Error looking up a ref. eg. doesn't exist |
TreeBuilderError | Problem creating a Tree Builder for a Tree. |
GetByNameError | Problem getting a Tree by name |
GetNameError | Problem getting a Tree Entry by name |
GetTargetError | Error getting ref. target |
GetTimeError | Problem getting the time from the Signature |
GetTimeZoneError | Problem getting the timezone from the Signature |
GetTreeError | Error getting Commit Tree |
GetTreeIdError | Error getting commit Tree Id |
GetCommitterError | Error getting the committer's Signature |
GetMessageError | Error getting commit message |
GetParentsError | Problem getting commit's parents |
LookupError | Error looking up a commit |
LookupBlobError | Error looking up a Blob OId |
LookupBranchError | Branch error, eg. doesn't exist |
LookupCommitError | Commit error, eg. commit doesn't exist |
LookupTagError | Error looking up a Tag. eg. doesn't exist |
LookupTreeError | Tree Lookup error. eg. tree id doesn't exist |
LookupReferenceError | Problem looking up a reference |
RevparseError | Problem parsing a revision spec |
BuilderWriteError | Tree Builder write error |
BuilderInsertError | Tree Builder insert error |
GetEntryIdError | Error getting a tree entry id |
GetIdError | Problem getting object's id |
GetRawBlobError | Error getting the raw Blob content |
GetTargetIdError | Error getting Tag Id from a tag object |
NewOIdError | Problem creating a new OId from a string |
NewOptionsError | Error creating a new Options object |
NewTimeValError | Error creating a new TimeVal object |
NewTreeError | Problem creating a new diff Tree |
NewSignatureError | Error creating a new Signature |
NewWalkerError | Error creating a new revision Walker object |
OIdError | Error creating a String from an OId |