Database governance built for humans and agents — controlling changes and access across every major database.
Go cicddata-governancedata-maskingdata-securitydatabase-accessdatabase-governancedevopsdevsecopsflywaygitopsliquibasemongodbmysqloraclepostgresqlschema-migrationssecuritysql-clientsqlservertidb
chore: optimize vcs base directory (#11642)
ecmadao71f0585674cf
diff --git a/backend/api/gitops/common.go b/backend/api/gitops/common.goindex c0bff5939f..2a3d533803 100644--- a/backend/api/gitops/common.go+++ b/backend/api/gitops/common.go@@ -38,7 +38,11 @@ func getChangesByFileList(files []*vcs.PullRequestFile, rootDir string) []*fileCif v.IsDeleted {continue}- if filepath.Dir(v.Path) != rootDir {+ prFilePath := v.Path+ if !strings.HasPrefix(prFilePath, "/") {+ prFilePath = fmt.Sprintf("/%s", prFilePath)+ }+ if filepath.Dir(prFilePath) != rootDir {continue}change, err := getFileChange(v.Path)diff --git a/backend/api/v1/vcs_connector_service.go b/backend/api/v1/vcs_connector_service.goindex 81752df291..07e59bd0b9 100644--- a/backend/api/v1/vcs_connector_service.go+++ b/backend/api/v1/vcs_connector_service.go@@ -104,14 +104,9 @@ func (s *VCSConnectorService) CreateVCSConnector(ctx context.Context, request *vreturn nil, err}- baseDir := request.GetVcsConnector().BaseDirectory- // Azure DevOps base directory should start with /.- if vcsProvider.Type == storepb.VCSType_AZURE_DEVOPS {- if !strings.HasPrefix(baseDir, "/") {- baseDir = "/" + request.GetVcsConnector().BaseDirectory- }- } else {- baseDir = strings.Trim(request.GetVcsConnector().BaseDirectory, "/")+ baseDirectory := request.GetVcsConnector().BaseDirectory+ if !strings.HasPrefix(baseDirectory, "/") {+ return nil, status.Errorf(codes.InvalidArgument, `base directory should start with "/"`)}workspaceID, err := s.store.GetWorkspaceID(ctx)@@ -133,7 +128,7 @@ func (s *VCSConnectorService) CreateVCSConnector(ctx context.Context, request *vFullPath: request.GetVcsConnector().FullPath,WebUrl: request.GetVcsConnector().WebUrl,Branch: request.GetVcsConnector().Branch,- BaseDirectory: baseDir,+ BaseDirectory: request.GetVcsConnector().BaseDirectory,ExternalId: request.GetVcsConnector().ExternalId,WebhookSecretToken: secretToken,DatabaseGroup: request.GetVcsConnector().DatabaseGroup,@@ -287,13 +282,8 @@ func (s *VCSConnectorService) UpdateVCSConnector(ctx context.Context, request *vupdate.Branch = &request.GetVcsConnector().Branchcase "base_directory":baseDir := request.GetVcsConnector().BaseDirectory- // Azure DevOps base directory should start with /.- if vcsProvider.Type == storepb.VCSType_AZURE_DEVOPS {- if !strings.HasPrefix(baseDir, "/") {- baseDir = "/" + request.GetVcsConnector().BaseDirectory- }- } else {- baseDir = strings.Trim(request.GetVcsConnector().BaseDirectory, "/")+ if !strings.HasPrefix(baseDir, "/") {+ return nil, status.Errorf(codes.InvalidArgument, `base directory should start with "/"`)}update.BaseDirectory = &baseDircase "database_group":diff --git a/backend/tests/tenant_test.go b/backend/tests/tenant_test.goindex 3d9070524b..35b8d00180 100644--- a/backend/tests/tenant_test.go+++ b/backend/tests/tenant_test.go@@ -22,8 +22,6 @@ var (prodInstanceName = "testInstanceProd")-const baseDirectory = "bbtest"-func TestTenant(t *testing.T) {t.Parallel()a := require.New(t)diff --git a/backend/tests/vcs_test.go b/backend/tests/vcs_test.goindex 8fb1253683..5d3e28ea48 100644--- a/backend/tests/vcs_test.go+++ b/backend/tests/vcs_test.go@@ -19,6 +19,8 @@ import (v1pb "github.com/bytebase/bytebase/proto/generated-go/v1")+const baseDirectory = "/bbtest"+func TestVCS(t *testing.T) {branchName := "feature/foo"pullRequestFiles := []*vcs.PullRequestFile{@@ -205,12 +207,7 @@ func TestVCS(t *testing.T) {UpdateMask: &fieldmaskpb.FieldMask{Paths: []string{"base_directory"}},})a.NoError(err)-- if evcs.Type == v1pb.VCSType_AZURE_DEVOPS {- a.Equal(fmt.Sprintf("/%s", baseDirectory), vcsConnector.BaseDirectory)- } else {- a.Equal(baseDirectory, vcsConnector.BaseDirectory)- }+ a.Equal(baseDirectory, vcsConnector.BaseDirectory)instanceName := "testInstance"instanceDir, err := ctl.provisionSQLiteInstance(t.TempDir(), instanceName)diff --git a/frontend/src/components/RepositoryConfigPanel.vue b/frontend/src/components/RepositoryConfigPanel.vueindex f38ce61330..8ce333f0ac 100644--- a/frontend/src/components/RepositoryConfigPanel.vue+++ b/frontend/src/components/RepositoryConfigPanel.vue@@ -10,18 +10,11 @@</template><script lang="ts" setup>-import type { PropType } from "vue";import type { Project } from "@/types/proto/v1/project_service";import type { ProjectRepositoryConfig } from "../types";-defineProps({- config: {- required: true,- type: Object as PropType<ProjectRepositoryConfig>,- },- project: {- required: true,- type: Object as PropType<Project>,- },-});+defineProps<{+ config: ProjectRepositoryConfig;+ project: Project;+}>();</script>diff --git a/frontend/src/components/RepositoryForm.vue b/frontend/src/components/RepositoryForm.vueindex af2b207db2..ac636929de 100644--- a/frontend/src/components/RepositoryForm.vue+++ b/frontend/src/components/RepositoryForm.vue@@ -2,7 +2,7 @@<template><div class="space-y-4"><div>- <div v-if="getWebhookLink !== ''" class="mb-2">+ <div v-if="!create && getWebhookLink !== ''" class="mb-2"><label class="textlabel mt-2"><i18n-t keypath="repository.our-webhook-link"><template #webhookLink>diff --git a/frontend/src/components/RepositorySetupWizard.vue b/frontend/src/components/RepositorySetupWizard.vueindex 0c54647e20..973aa4c131 100644--- a/frontend/src/components/RepositorySetupWizard.vue+++ b/frontend/src/components/RepositorySetupWizard.vue@@ -1,18 +1,20 @@<template><div>- <div class="textinfolabel">- <i18n-t keypath="repository.setup-wizard-guide">- <template #guide>- <a- href="https://bytebase.com/docs/vcs-integration/enable-gitops-workflow?source=console"- target="_blank"- class="normal-link"- >- {{ $t("common.detailed-guide") }}- </a>- </template>- </i18n-t>- </div>+ <BBAttention type="info">+ <div class="textinfolabel">+ <i18n-t keypath="repository.setup-wizard-guide">+ <template #guide>+ <a+ href="https://bytebase.com/docs/vcs-integration/add-gitops-connector?source=console"+ target="_blank"+ class="normal-link"+ >+ {{ $t("common.detailed-guide") }}+ </a>+ </template>+ </i18n-t>+ </div>+ </BBAttention><StepTabclass="mt-4 mb-8"@@ -92,7 +94,7 @@ const state = reactive<LocalState>({vcs: VCSProvider.fromPartial({}),repositoryInfo: VCSRepository.fromPartial({}),repositoryConfig: {- baseDirectory: "bytebase",+ baseDirectory: "/bytebase",branch: "main",resourceId: "",databaseGroup: "",@@ -130,6 +132,14 @@ const tryChangeStep = (nextStepIndex: number) => {state.currentStep = nextStepIndex;};+const validBaseDirectory = computed(() => {+ let directory = state.config.repositoryConfig.baseDirectory;+ if (directory.endsWith("/")) {+ directory = directory.slice(0, directory.length - 1);+ }+ return directory || "/";+});+const tryFinishSetup = async () => {if (state.processing) {return;@@ -152,8 +162,8 @@ const tryFinishSetup = async () => {title: state.config.repositoryInfo.title,externalId,vcsProvider: state.config.vcs.name,- baseDirectory: state.config.repositoryConfig.baseDirectory,- branch: state.config.repositoryConfig.branch,+ baseDirectory: validBaseDirectory.value,+ branch: state.config.repositoryConfig.branch.trim(),databaseGroup: state.config.repositoryConfig.databaseGroup,fullPath: state.config.repositoryInfo.fullPath,webUrl: state.config.repositoryInfo.webUrl,diff --git a/frontend/src/components/RepositoryVCSProviderPanel.vue b/frontend/src/components/RepositoryVCSProviderPanel.vueindex e6c2b485cc..7ea65e4bc9 100644--- a/frontend/src/components/RepositoryVCSProviderPanel.vue+++ b/frontend/src/components/RepositoryVCSProviderPanel.vue@@ -12,7 +12,7 @@</NButton></template></div>- <div class="mt-2 textinfolabel">+ <div class="mt-4 textinfolabel"><template v-if="canManageVCSProvider"><i18n-t keypath="repository.choose-git-provider-visit-workspace"><template #workspace>diff --git a/frontend/src/locales/en-US.json b/frontend/src/locales/en-US.jsonindex 09f05f1f5f..9e23f13dde 100644--- a/frontend/src/locales/en-US.json+++ b/frontend/src/locales/en-US.json@@ -1733,7 +1733,7 @@"branch-observe-file-change": "The branch where Bytebase observes the file change.","database-group-description": "By default, changes will be applied to all databases within the project. Alternatively, they can be applied to the database group.","base-directory": "Base directory",- "base-directory-description": "The root directory where Bytebase observes the file change.",+ "base-directory-description": "The root directory where Bytebase observes the file change. Use \"/\" if files stored in the repository root directory.","merge-request": "merge request","pull-request": "pull request","git-provider": "Git provider",diff --git a/frontend/src/locales/es-ES.json b/frontend/src/locales/es-ES.jsonindex 7a429e2e9e..2884745995 100644--- a/frontend/src/locales/es-ES.json+++ b/frontend/src/locales/es-ES.json@@ -1733,7 +1733,7 @@"branch-observe-file-change": "La rama donde Bytebase observa el cambio de archivo.","database-group-description": "Por defecto, los cambios se aplicarán a todas las bases de datos dentro del proyecto. Alternativamente, pueden aplicarse al grupo de bases de datos.","base-directory": "Directorio base",- "base-directory-description": "El directorio raíz donde Bytebase observa el cambio de archivo.",+ "base-directory-description": "El directorio raíz donde Bytebase observa el cambio del archivo. Utilice \"/\" si los archivos están almacenados en el directorio raíz del repositorio.","merge-request": "solicitud de extracción","pull-request": "solicitud de extracción","git-provider": "Proveedor de Git",@@ -3406,4 +3406,4 @@"head": "Cabeza","show-diff-with-branch-baseline": "Mostrar diferencia con la línea base de la rama"}-}+}\ No newline at end of filediff --git a/frontend/src/locales/ja-JP.json b/frontend/src/locales/ja-JP.jsonindex fcf596782c..43bd97af2f 100644--- a/frontend/src/locales/ja-JP.json+++ b/frontend/src/locales/ja-JP.json@@ -1733,7 +1733,7 @@"branch-observe-file-change": "Bytebaseがファイルの変更を監視するブランチ。","database-group-description": "デフォルトでは、変更はプロジェクト内のすべてのデータベースに適用されます。また、データベースグループに適用することもできます。","base-directory": "ベースディレクトリ",- "base-directory-description": "Bytebaseがファイルの変更を監視するルートディレクトリ。",+ "base-directory-description": "Bytebase がファイルの変更を監視するルート ディレクトリ。ファイルがリポジトリのルート ディレクトリに保存されている場合は、「/」を使用します。","merge-request": "マージリクエスト","pull-request": "プルリクエスト","git-provider": "Gitプロバイダ",@@ -3406,4 +3406,4 @@"head": "頭","show-diff-with-branch-baseline": "ブランチベースラインとの差分を表示"}-}+}\ No newline at end of filediff --git a/frontend/src/locales/vi-VN.json b/frontend/src/locales/vi-VN.jsonindex db262c8d34..26ae2c1376 100644--- a/frontend/src/locales/vi-VN.json+++ b/frontend/src/locales/vi-VN.json@@ -1733,7 +1733,7 @@"branch-observe-file-change": "Nhánh nơi Bytebase quan sát sự thay đổi tập tin.","database-group-description": "Mặc định, các thay đổi sẽ được áp dụng cho tất cả các cơ sở dữ liệu trong dự án. Hoặc có thể áp dụng cho nhóm cơ sở dữ liệu.","base-directory": "Thư mục cơ sở",- "base-directory-description": "Thư mục gốc nơi Bytebase quan sát sự thay đổi của tập tin.",+ "base-directory-description": "Thư mục gốc nơi Bytebase quan sát sự thay đổi của tập tin. Sử dụng \"/\" nếu các tệp được lưu trữ trong thư mục gốc của kho lưu trữ.","merge-request": "yêu cầu hợp nhất","pull-request": "yêu cầu kéo","git-provider": "Nhà cung cấp Git",@@ -3406,4 +3406,4 @@"head": "Cái đầu","show-diff-with-branch-baseline": "Hiển thị sự khác biệt với đường cơ sở của nhánh"}-}+}\ No newline at end of filediff --git a/frontend/src/locales/zh-CN.json b/frontend/src/locales/zh-CN.jsonindex 3c104308d9..e10acaffb5 100644--- a/frontend/src/locales/zh-CN.json+++ b/frontend/src/locales/zh-CN.json@@ -1733,7 +1733,7 @@"branch-observe-file-change": "Bytebase 跟踪文件变更的分支。","database-group-description": "默认情况下,更改将应用于项目中的所有数据库。或者,它们可以应用于数据库组。","base-directory": "根目录",- "base-directory-description": "Bytebase 跟踪文件变更的根目录。",+ "base-directory-description": "Bytebase 观察文件变化的根目录。如果文件存储在存储库根目录中,请使用“/”。","merge-request": "合并请求","pull-request": "拉取请求","git-provider": "Git 提供方",@@ -3406,4 +3406,4 @@"head": "当前","show-diff-with-branch-baseline": "显示与分支基线之间的差异"}-}+}\ No newline at end of filediff --git a/frontend/src/views/SettingWorkspaceVCSCreate.vue b/frontend/src/views/SettingWorkspaceVCSCreate.vueindex 337fd73beb..1c0eb923cc 100644--- a/frontend/src/views/SettingWorkspaceVCSCreate.vue+++ b/frontend/src/views/SettingWorkspaceVCSCreate.vue@@ -1,12 +1,14 @@<template><div class="space-y-4 divide-y divide-block-border">- <div class="textinfolabel">- {{ $t("gitops.setting.add-git-provider.description") }}- <LearnMoreLink- url="https://www.bytebase.com/docs/vcs-integration/add-git-provider?source=console"- class="text-sm"- />- </div>+ <BBAttention type="info">+ <div class="textinfolabel">+ {{ $t("gitops.setting.add-git-provider.description") }}+ <LearnMoreLink+ url="https://www.bytebase.com/docs/vcs-integration/add-git-provider?source=console"+ class="text-sm"+ />+ </div>+ </BBAttention><div class="pt-4"><VCSSetupWizard /></div>