Template Git Remotes

Scaraplate assumes that the template dir is a git repo.

Strategies receive a scaraplate.template.TemplateMeta instance which contains URLs to the template’s project and the HEAD git commit on a git remote’s web interface (such as GitHub). These URLs might be rendered in the target files by the strategies.

Scaraplate has built-in support for some popular git remotes. The remote is attempted to be detected automatically, but if that fails, it should be specified manually.

Sample scaraplate.yaml excerpt:

git_remote_type: scaraplate.gitremotes.GitHub
class scaraplate.template.TemplateMeta

Bases: tuple

Metadata of the template’s git repo status.

commit_hash

Alias for field number 1

commit_url

Alias for field number 2

git_project_url

Alias for field number 0

head_ref

Alias for field number 4

is_git_dirty

Alias for field number 3

class scaraplate.gitremotes.GitRemote(remote: str)

Bases: abc.ABC

Base class for a git remote implementation, which generates http URLs from a git remote (either ssh of http) and a commit hash.

__init__(remote: str) → None

Init the git remote.

Parameters:remote – A git remote, either ssh or http(s).
commit_url(commit_hash: str) → str

Return a commit URL at the given git remote.

Parameters:commit_hash – Git commit hash.
project_url() → str

Return a project URL at the given git remote.

Built-in Git Remotes

class scaraplate.gitremotes.GitLab(remote: str)

Bases: scaraplate.gitremotes.GitRemote

GitLab git remote implementation.

class scaraplate.gitremotes.GitHub(remote: str)

Bases: scaraplate.gitremotes.GitRemote

GitHub git remote implementation.

class scaraplate.gitremotes.BitBucket(remote: str)

Bases: scaraplate.gitremotes.GitRemote

BitBucket git remote implementation.