JBoss Community Archive (Read Only)

ModeShape 5

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.

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.

cacheable

Optional property that if a node returned by this connector should be cached in the workspace cache or not. By default all nodes are cached, but you can set it to false for the connector to always read the latest version of the nodes

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 ModeShape 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,
            "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.

When configuring a Git connector in JBoss AS via CLI, you can use the following command for setting the connector attributes:
/subsystem=modeshape/repository=sample/source=git/:write-attribute(name="properties", value=[{"directoryPath" => "some_path", "remoteName" => "some_name"}])

JBoss.org Content Archive (Read Only), exported from JBoss Community Documentation Editor at 2020-03-11 12:13:00 UTC, last content change 2016-04-07 07:42:08 UTC.