Commitspark is a set of tools to manage structured data with Git through a GraphQL API.
This repository holds code for a Commitspark Git adapter that provides access to Git repositories checked out in the local filesystem.
This adapter is primarily meant to be used in read-only CI/CD pipeline scenarios where a single Git revision of entries is already checked out in the filesystem.
Write support is present mostly for demonstration purposes and comes with several limitations.
The current working directory for file system access is determined by sequentially checking the following sources:
GITHUB_WORKSPACEGitHub Actions environment variableCI_PROJECT_DIRGitLab CI/CD environment variableprocess.cwd()
The currently checked out branch and commit hash are determined in the following order:
- Output of querying with the
gitbinary, if present - GitHub
GITHUB_SHAandGITHUB_REF_NAMEenvironment variables - GitLab
CI_COMMIT_SHAandCI_COMMIT_REF_NAMEenvironment variables
If none of these lead to a result, an error is thrown.
createCommit() writes entry changes to disk and commits them using the git binary. It is intended for demonstration
purposes, not production use.
- The
gitbinary must be installed and included in$PATH - When committing to a branch, the branch must already be checked out in the filesystem
- The current
HEADcommit hash must matchcommitDraft.parentSha - Concurrent writes are not supported and lead to undefined behavior
- If a commit fails while writing, the working tree is left in an undefined state
gitmust have a usableuser.name/user.emailconfiguration present
- File modifications are constrained to those within
pathEntryFolder - Only the files corresponding to mutated entries are staged and committed, unrelated changes in the filesystem are left untouched
- Commits are only created locally and not pushed to any remote
Instantiate the adapter with createAdapter() and the following options:
| Option name | Required | Default value | Description |
|---|---|---|---|
checkedOutCommitHash |
False | N/A | Deprecated; has no effect |
pathSchemaFile |
False | commitspark/schema/schema.graphql |
Path to schema file in repository |
pathEntryFolder |
False | commitspark/entries/ |
Path to folder for content entries |
The code in this repository is licensed under the permissive ISC license (see LICENSE).