diff --git a/backend/windmill-api-workspaces/src/workspaces.rs b/backend/windmill-api-workspaces/src/workspaces.rs index f479b8c719..6828c6758a 100644 --- a/backend/windmill-api-workspaces/src/workspaces.rs +++ b/backend/windmill-api-workspaces/src/workspaces.rs @@ -124,6 +124,10 @@ pub fn workspaced_service() -> Router { ) .route("/edit_datatable_config", post(edit_datatable_config)) .route("/git_sync_enabled", get(get_git_sync_enabled)) + .route( + "/git_init_repo_script_path", + get(get_git_init_repo_script_path), + ) .route("/edit_git_sync_config", post(edit_git_sync_config)) .route("/edit_git_sync_repository", post(edit_git_sync_repository)) .route( @@ -2535,6 +2539,12 @@ async fn get_git_sync_enabled( }))) } +async fn get_git_init_repo_script_path() -> JsonResult { + Ok(Json(serde_json::json!({ + "script_path": windmill_common::workspaces::LATEST_GIT_INIT_REPO_SCRIPT_PATH, + }))) +} + async fn edit_git_sync_config( authed: ApiAuthed, Extension(db): Extension, diff --git a/backend/windmill-api/openapi.yaml b/backend/windmill-api/openapi.yaml index dd3c480241..7e2eec9438 100644 --- a/backend/windmill-api/openapi.yaml +++ b/backend/windmill-api/openapi.yaml @@ -4376,6 +4376,27 @@ paths: type: integer nullable: true + /w/{workspace}/workspaces/git_init_repo_script_path: + get: + summary: Get the latest git init repository hub script path + operationId: getGitInitRepoScriptPath + tags: + - workspace + parameters: + - $ref: "#/components/parameters/WorkspaceId" + responses: + "200": + description: Latest hub script path used to initialize a git repository + content: + application/json: + schema: + type: object + properties: + script_path: + type: string + required: + - script_path + /w/{workspace}/workspaces/edit_git_sync_config: post: summary: edit workspace git sync settings diff --git a/backend/windmill-common/src/workspaces.rs b/backend/windmill-common/src/workspaces.rs index 989ae9ef34..8d9d75b3bd 100644 --- a/backend/windmill-common/src/workspaces.rs +++ b/backend/windmill-common/src/workspaces.rs @@ -159,6 +159,8 @@ pub enum ObjectType { pub const LATEST_GIT_SYNC_SCRIPT_PATH: &str = "hub/28217/sync-script-to-git-repo-windmill"; +pub const LATEST_GIT_INIT_REPO_SCRIPT_PATH: &str = "hub/28219/git-sync%3A-init-repository-windmill"; + /// Prefix used to identify fork workspaces. A workspace whose id starts with this string is a /// fork of another workspace. pub const WM_FORK_PREFIX: &str = "wm-fork-"; diff --git a/frontend/src/lib/components/git_sync/GitSyncContext.svelte.ts b/frontend/src/lib/components/git_sync/GitSyncContext.svelte.ts index f17cdd23d4..79bad3896d 100644 --- a/frontend/src/lib/components/git_sync/GitSyncContext.svelte.ts +++ b/frontend/src/lib/components/git_sync/GitSyncContext.svelte.ts @@ -301,9 +301,10 @@ export function createGitSyncContext(workspace: string) { const detectionTimestamp = Date.now() try { + const { script_path } = await WorkspaceService.getGitInitRepoScriptPath({ workspace }) const jobId = await JobService.runScriptByPath({ workspace, - path: hubPaths.gitInitRepo, + path: script_path, requestBody: { workspace_id: workspace, repo_url_resource_path: repo.git_repo_resource_path, diff --git a/frontend/src/lib/components/git_sync/PullWorkspaceModal.svelte b/frontend/src/lib/components/git_sync/PullWorkspaceModal.svelte index 37af944362..6ab67d5319 100644 --- a/frontend/src/lib/components/git_sync/PullWorkspaceModal.svelte +++ b/frontend/src/lib/components/git_sync/PullWorkspaceModal.svelte @@ -12,10 +12,9 @@ Edit3 } from 'lucide-svelte' import GitDiffPreview from '../GitDiffPreview.svelte' - import { JobService } from '$lib/gen' + import { JobService, WorkspaceService } from '$lib/gen' import { workspaceStore } from '$lib/stores' import { sendUserToast } from '$lib/toast' - import hubPaths from '$lib/hubPaths.json' import { jobManager } from '$lib/services/JobManager' import type { SyncResponse, SettingsResponse, SettingsObject } from '$lib/git-sync' @@ -158,9 +157,10 @@ currentGitSyncSettings?.repositories?.[repoIndex!]?.use_individual_branch === true } + const { script_path } = await WorkspaceService.getGitInitRepoScriptPath({ workspace }) const jobId = await JobService.runScriptByPath({ workspace, - path: hubPaths.gitInitRepo, + path: script_path, requestBody: payload, skipPreprocessor: true }) diff --git a/frontend/src/lib/components/git_sync/PushWorkspaceModal.svelte b/frontend/src/lib/components/git_sync/PushWorkspaceModal.svelte index 87c6ecb807..0f37857b6b 100644 --- a/frontend/src/lib/components/git_sync/PushWorkspaceModal.svelte +++ b/frontend/src/lib/components/git_sync/PushWorkspaceModal.svelte @@ -3,9 +3,8 @@ import { Button, Alert } from '$lib/components/common' import { Loader2, CheckCircle2, XCircle, Terminal, ChevronDown, ChevronUp } from 'lucide-svelte' import GitDiffPreview from '../GitDiffPreview.svelte' - import { JobService } from '$lib/gen' + import { JobService, WorkspaceService } from '$lib/gen' import { workspaceStore } from '$lib/stores' - import hubPaths from '$lib/hubPaths.json' import { jobManager } from '$lib/services/JobManager' import type { SyncResponse, SettingsObject } from '$lib/git-sync' @@ -89,9 +88,10 @@ settings_json: JSON.stringify(uiState) } + const { script_path } = await WorkspaceService.getGitInitRepoScriptPath({ workspace }) const jobId = await JobService.runScriptByPath({ workspace, - path: hubPaths.gitInitRepo, + path: script_path, requestBody: payload, skipPreprocessor: true }) diff --git a/frontend/src/lib/hub.ts b/frontend/src/lib/hub.ts index a038f18580..4be6dcef54 100644 --- a/frontend/src/lib/hub.ts +++ b/frontend/src/lib/hub.ts @@ -93,7 +93,6 @@ export function rawAppToHubUrl(hubBaseUrl: string, summary?: string): URL { type HubPaths = { gitSyncTest: string - gitInitRepo: string slackErrorHandler: string slackRecoveryHandler: string slackSuccessHandler: string diff --git a/frontend/src/lib/hubPaths.json b/frontend/src/lib/hubPaths.json index 0be40c0bca..d8a8d8dd96 100644 --- a/frontend/src/lib/hubPaths.json +++ b/frontend/src/lib/hubPaths.json @@ -27,7 +27,6 @@ "deprecated_gitSync_latest": "hub/28180/sync-script-to-git-repo-windmill", "deprecated_gitSync_25": "hub/28183/sync-script-to-git-repo-windmill", "gitSyncTest": "hub/28184/git-repo-test-read-write-windmill", - "gitInitRepo": "hub/28219/git-sync%3A-init-repository-windmill", "slackErrorHandler": "hub/19741/workspace-or-schedule-error-handler-slack", "slackErrorHandler_0": "hub/9079/workspace-or-schedule-error-handler-slack", "slackErrorHandler_1": "hub/9206/workspace-or-schedule-error-handler-slack",