databricks-cli/libs/git
Denis Bilenko 0ad790e468
Properly read Git metadata when running inside workspace (#1945)
## Changes

Since there is no .git directory in Workspace file system, we need to
make an API call to api/2.0/workspace/get-status?return_git_info=true to
fetch git the root of the repo, current branch, commit and origin.

Added new function FetchRepositoryInfo that either looks up and parses
.git or calls remote API depending on env.

Refactor Repository/View/FileSet to accept repository root rather than
calculate it. This helps because:
- Repository is currently created in multiple places and finding the
repository root is becoming relatively expensive (API call needed).
- Repository/FileSet/View do not have access to current Bundle which is
where WorkplaceClient is stored.

## Tests

- Tested manually by running "bundle validate --json" inside web
terminal within Databricks env.
- Added integration tests for the new API.

---------

Co-authored-by: Andrew Nester <andrew.nester@databricks.com>
Co-authored-by: Pieter Noordhuis <pieter.noordhuis@databricks.com>
2024-12-05 10:13:13 +00:00
..
testdata Never ignore root directory when enumerating files in a repository (#683) 2023-08-21 07:35:02 +00:00
testdata_view_ignore Hardcode `.databricks` ignore pattern to ensure we never sync the cache directory (#295) 2023-04-04 15:44:57 +02:00
clone.go Remove resolution of repo names against the Databricks Github account (#940) 2023-11-01 13:02:06 +00:00
clone_test.go Fall back to full Git clone if shallow clone is not supported (#775) 2023-09-15 09:14:51 +00:00
config.go Update error checks that use the `os` package to use `errors.Is` (#1461) 2024-06-03 12:39:36 +00:00
config_test.go Locate and use global excludes file (#191) 2023-02-02 12:25:53 +01:00
fileset.go Properly read Git metadata when running inside workspace (#1945) 2024-12-05 10:13:13 +00:00
fileset_test.go Properly read Git metadata when running inside workspace (#1945) 2024-12-05 10:13:13 +00:00
ignore.go Update error checks that use the `os` package to use `errors.Is` (#1461) 2024-06-03 12:39:36 +00:00
ignore_test.go Abstract over filesystem interaction with libs/vfs (#1452) 2024-05-30 07:41:50 +00:00
info.go Properly read Git metadata when running inside workspace (#1945) 2024-12-05 10:13:13 +00:00
reference.go Update error checks that use the `os` package to use `errors.Is` (#1461) 2024-06-03 12:39:36 +00:00
reference_test.go Abstract over filesystem interaction with libs/vfs (#1452) 2024-05-30 07:41:50 +00:00
repository.go Properly read Git metadata when running inside workspace (#1945) 2024-12-05 10:13:13 +00:00
repository_test.go Assert tokens are redacted in origin URL when username is not specified (#1785) 2024-09-23 12:42:30 +00:00
view.go Properly read Git metadata when running inside workspace (#1945) 2024-12-05 10:13:13 +00:00
view_test.go Properly read Git metadata when running inside workspace (#1945) 2024-12-05 10:13:13 +00:00
worktree.go Support Git worktrees for `sync` (#1831) 2024-10-21 18:27:07 +00:00
worktree_test.go Support Git worktrees for `sync` (#1831) 2024-10-21 18:27:07 +00:00