Red Hat Training

A Red Hat training course is available for Red Hat JBoss Data Virtualization

10.2. Git Connector

This read-only connector exposes the branches, tags, and commits in a local Git repository as nodes within a repository. The structure is pre-defined by the connector so that the branches, tags, commits, and their files and folders are all accessible via navigation, via identifiers, or via query (if configured).
The connector classname is org.modeshape.connector.git.GitConnector, and there are several attributes that should be configured on each external source:
Attribute Name
Description
directoryPath
The path to the folder that is or contains the .git data structure is to be accessed by this connector. This is required.
includeMimeType
A boolean flag denoting whether the MIME types for the files should be determined and included as a property on the node. This is 'false' by default.
remoteName
The alias used by the local Git repository for the remote repository. The default is origin, which is common in Git repositories. If the value contains commas, the value contains an ordered list of remote aliases that should be accessed; the first one to match an existing remote will be used. The remote names are used to know which branches should be exposed: if at least one remote name is given, then only the branches in the remote(s) will be exposed; if no remotes are given, then all local branches will be exposed.
queryableBranches
An array with the names of the branches that should be queryable by the repository. By default, only the master branch is queryable. Set this to an empty array if no branches are to be queryable.
cacheTtlSeconds
Optional property that specifies the default maximum number of seconds (i.e., time to live) that a node returned by this connector should be cached in the workspace cache before being expired. By default, the connector will not set a special value, and the repository will determine how long the node is cached in the workspace cache.
Here is a sample configuration that projects the Git repository located at /home/jsmith/git/MyRepo on the local file system into the repository under the /git/MyRepo node, which will have a primary type of git:root. The master and 2.x branches will be included in the hierarchical database indexes when the content is reindexed, and MIME types will be included on all git:resource nodes (that is, the jcr:content child of the git:file nodes). The list of branches and tags will include those on the upstream and origin remotes.
{
    ...
    "externalSources" : {
        "local-git-repo" : {
            "classname" : "org.modeshape.connector.git.GitConnector",
            "directoryPath" : "/home/jsmit/git/MyRepo/",
            "remoteName" : "upstream,origin",
            "includeMimeType" : true,
            "queryableBranches" : ["master","2.x"],
            "projections" : \[ "/git/MyRepo" \]
        }
    }
    ...
}
And here is a description of the repository structure:
Path
Description
/branches/{branchName }
The list of branches.
/tags/{tagName }
The list of tags.
/commits/{branchOrTagNameOrCommit\/{objectId }
The history of commits on the branch, tag or object ID name "{ branchOrTagNameOrCommit }", where "{ objectId }" is the object ID of the commit.
/commit/{branchOrTagNameOrCommit }
The information about a particular branch, tag or commit "{ branchOrTagNameOrCommit }".
/tree/{branchOrTagOrObjectId}/{filesAndFolders}/...
The structure of the directories and files in the specified branch, tag or commit "{ branchOrTagNameOrCommit }".
The node types used by the connector are specified here . Some of the more important node types include:
Node Type
Description
git:committed
A mixin that defines the git:objectId (SHA-1 hash), git:author , git:committer , git:committed (date), and git:title properties that appear on all "committed" nodes.
git:file
The primary node type for a node representing a file in a Git repository. Extends both nt:file and git:committed .
git:folder
The primary node type for a node representing a folder in a Git repository. Extends both nt:folder and git:committed .
git:resource
The primary node type for a node representing the jcr:content child of git:file nodes, where content-related information is placed. Extends both nt:resource and git:committed .
git:branch
The primary node type for a node representing a Git branch.
git:tag
The primary node type for a node representing a Git tag.
git:commit
The primary node type for a node representing a Git commit.
git:branches
The primary node type for the node that contains the list of git:branch nodes.
git:tags
The primary node type for the node that contains the list of git:tag nodes.
git:commits
The primary node type for the node that contains a list of git:commit nodes.
git:root
The primary node type for the top-level node of the repository.