-
Notifications
You must be signed in to change notification settings - Fork 206
Fix repos get/update/delete for Git-CLI-enabled folders #6122
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
GrantIsEaton
wants to merge
3
commits into
databricks:main
Choose a base branch
from
GrantIsEaton:fix-repos-git-cli-folders
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| Fixed `databricks repos get/update/delete` failing with `object at path "..." is not a repo` for Git-CLI-enabled folders, which the workspace API reports as directories rather than repos. Git CLI is a preview feature; as an alternative mitigation it can be turned off in the workspace admin previews settings. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,3 @@ | ||
|
|
||
| >>> [CLI] repos get /Repos/me@databricks.com/doesnotexist -o json | ||
| Error: failed to look up repo by path: Path (/Repos/me@databricks.com/doesnotexist) doesn't exist. | ||
|
|
||
| >>> [CLI] repos get /not-a-repo -o json | ||
| Error: object at path "/not-a-repo" is not a repo |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1 @@ | ||
| musterr trace $CLI repos get /Repos/me@databricks.com/doesnotexist -o json | ||
|
|
||
| $CLI workspace mkdirs /not-a-repo | ||
| musterr trace $CLI repos get /not-a-repo -o json |
49 changes: 49 additions & 0 deletions
49
acceptance/workspace/repos/git_cli_folder/out.requests.txt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,49 @@ | ||
| { | ||
| "method": "GET", | ||
| "path": "/.well-known/databricks-config" | ||
| } | ||
| { | ||
| "method": "POST", | ||
| "path": "/api/2.0/repos", | ||
| "body": { | ||
| "path": "/Workspace/Users/me@databricks.com/test-repo", | ||
| "provider": "gitHub", | ||
| "url": "https://github.com/databricks/databricks-empty-ide-project.git" | ||
| } | ||
| } | ||
| { | ||
| "method": "GET", | ||
| "path": "/api/2.0/workspace/get-status", | ||
| "q": { | ||
| "path": "/Workspace/Users/me@databricks.com/test-repo" | ||
| } | ||
| } | ||
| { | ||
| "method": "GET", | ||
| "path": "/api/2.0/repos/[NUMID]" | ||
| } | ||
| { | ||
| "method": "GET", | ||
| "path": "/api/2.0/workspace/get-status", | ||
| "q": { | ||
| "path": "/Workspace/Users/me@databricks.com/test-repo" | ||
| } | ||
| } | ||
| { | ||
| "method": "PATCH", | ||
| "path": "/api/2.0/repos/[NUMID]", | ||
| "body": { | ||
| "branch": "update-by-path" | ||
| } | ||
| } | ||
| { | ||
| "method": "GET", | ||
| "path": "/api/2.0/workspace/get-status", | ||
| "q": { | ||
| "path": "/Workspace/Users/me@databricks.com/test-repo" | ||
| } | ||
| } | ||
| { | ||
| "method": "DELETE", | ||
| "path": "/api/2.0/repos/[NUMID]" | ||
| } | ||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
|
|
||
| >>> [CLI] repos create https://github.com/databricks/databricks-empty-ide-project.git gitHub --path /Workspace/Users/me@databricks.com/test-repo | ||
| [NUMID] | ||
|
|
||
| === Get by path resolves a Git CLI folder | ||
| >>> [CLI] repos get /Workspace/Users/me@databricks.com/test-repo -o json | ||
| { | ||
| "branch": "main", | ||
| "id": [NUMID], | ||
| "path": "/Workspace/Users/me@databricks.com/test-repo", | ||
| "provider": "gitHub", | ||
| "url": "https://github.com/databricks/databricks-empty-ide-project.git" | ||
| } | ||
|
|
||
| === Update by path resolves a Git CLI folder | ||
| >>> [CLI] repos update /Workspace/Users/me@databricks.com/test-repo --branch update-by-path | ||
|
|
||
| === Delete by path resolves a Git CLI folder | ||
| >>> [CLI] repos delete /Workspace/Users/me@databricks.com/test-repo |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| url=https://github.com/databricks/databricks-empty-ide-project.git | ||
| provider=gitHub | ||
| # A Git-CLI-enabled folder lives outside /Repos and get-status reports it as a | ||
| # DIRECTORY, not a REPO. Path-based commands must still resolve it to a repo ID. | ||
| path=/Workspace/Users/me@databricks.com/test-repo | ||
|
|
||
| trace $CLI repos create $url $provider --path $path | jq .id -r | ||
|
|
||
| title "Get by path resolves a Git CLI folder" | ||
| trace $CLI repos get $path -o json | ||
|
|
||
| title "Update by path resolves a Git CLI folder" | ||
| trace $CLI repos update $path --branch update-by-path | ||
|
|
||
| title "Delete by path resolves a Git CLI folder" | ||
| trace $CLI repos delete $path |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -418,7 +418,14 @@ func (s *FakeWorkspace) WorkspaceGetStatus(requestPath string) Response { | |
| } else if entry, ok := s.files[cleaned]; ok { | ||
| info = entry.Info | ||
| } else if repoId, ok := s.repoIdByPath[cleaned]; ok { | ||
| info = workspace.ObjectInfo{ObjectType: "REPO", Path: cleaned, ObjectId: repoId} | ||
| // Control-plane repos (under /Repos) report the REPO object type, while | ||
| // Git-CLI-enabled folders elsewhere are materialized as plain DIRECTORY | ||
| // nodes. Both resolve to a valid repo ID via the repos API. | ||
| objectType := workspace.ObjectTypeRepo | ||
| if !strings.HasPrefix(cleaned, "/Repos/") { | ||
| objectType = workspace.ObjectTypeDirectory | ||
| } | ||
|
Comment on lines
+421
to
+427
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is a weird fake. |
||
| info = workspace.ObjectInfo{ObjectType: objectType, Path: cleaned, ObjectId: repoId} | ||
| } else { | ||
| // Match the real Workspace API wording, which echoes the requested path. | ||
| return Response{ | ||
|
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need this request?