Skip to main content

repos

Creates, updates, deletes, gets or lists a repos resource.

Overview

Namerepos
TypeResource
Iddatabricks_workspace.workspace.repos

Fields

The following fields are returned by SELECT queries:

NameDatatypeDescription
idintegerID of the Git folder (repo) object in the workspace.
head_commit_idstringSHA-1 hash representing the commit ID of the current HEAD of the repo.
branchstring
git_cli_enabledbooleanWhether the Git CLI is enabled for this Git folder (repo). When true, Git commands can be run directly against this Git folder using the Git CLI.
pathstringPath of the Git folder (repo) in the workspace.
providerstringGit provider of the linked Git repository, e.g. ``gitHub``, ``azureDevOpsServices``, ``bitbucketServer`` (Bitbucket Data Center), ``gitLabEnterpriseEdition`` (GitLab Self-Managed), or ``awsCodeCommit`` (deprecated).
sparse_checkoutobjectSparse checkout settings for the Git folder (repo).
urlstringURL of the linked Git repository.

Methods

The following methods are available for this resource:

NameAccessible byRequired ParamsOptional ParamsDescription
getselectrepo_id, deployment_nameReturns the repo with the given repo ID.
listselectdeployment_namenext_page_token, path_prefixReturns repos that the calling user has Manage permissions on. Use next_page_token to iterate
createinsertdeployment_name, url, providerCreates a repo in the workspace and links it to the remote Git repo specified. Note that repos created
updateupdaterepo_id, deployment_nameUpdates the repo to a different branch or tag, or updates the repo to the latest commit on the same
deletedeleterepo_id, deployment_nameDeletes the specified repo.

Parameters

Parameters can be passed in the WHERE clause of a query. Check the Methods section to see which parameters are required or optional for each operation.

NameDatatypeDescription
deployment_namestringThe Databricks Workspace Deployment Name (default: dbc-abcd0123-a1bc)
repo_idintegerThe ID for the corresponding repo to delete.
next_page_tokenstringToken used to get the next page of results. If not specified, returns the first page of results as well as a next page token if there are more results.
path_prefixstringFilters repos that have paths starting with the given path prefix. If not provided or when provided an effectively empty prefix (/ or /Workspace) Git folders (repos) from /Workspace/Repos will be served.

SELECT examples

Returns the repo with the given repo ID.

SELECT
id,
head_commit_id,
branch,
git_cli_enabled,
path,
provider,
sparse_checkout,
url
FROM databricks_workspace.workspace.repos
WHERE repo_id = '{{ repo_id }}' -- required
AND deployment_name = '{{ deployment_name }}' -- required
;

INSERT examples

Creates a repo in the workspace and links it to the remote Git repo specified. Note that repos created

INSERT INTO databricks_workspace.workspace.repos (
url,
provider,
git_credential_id,
path,
sparse_checkout,
deployment_name
)
SELECT
'{{ url }}' /* required */,
'{{ provider }}' /* required */,
{{ git_credential_id }},
'{{ path }}',
'{{ sparse_checkout }}',
'{{ deployment_name }}'
RETURNING
id,
head_commit_id,
branch,
path,
provider,
sparse_checkout,
url
;

UPDATE examples

Updates the repo to a different branch or tag, or updates the repo to the latest commit on the same

UPDATE databricks_workspace.workspace.repos
SET
branch = '{{ branch }}',
dangerously_force_discard_all = {{ dangerously_force_discard_all }},
git_credential_id = {{ git_credential_id }},
sparse_checkout = '{{ sparse_checkout }}',
tag = '{{ tag }}'
WHERE
repo_id = '{{ repo_id }}' --required
AND deployment_name = '{{ deployment_name }}' --required;

DELETE examples

Deletes the specified repo.

DELETE FROM databricks_workspace.workspace.repos
WHERE repo_id = '{{ repo_id }}' --required
AND deployment_name = '{{ deployment_name }}' --required
;