update git sync

This commit is contained in:
Ruben Fiszel
2026-01-16 00:07:50 +00:00
parent 3a70e70032
commit a6926cd6b0
7 changed files with 79 additions and 15 deletions
@@ -1,6 +1,6 @@
{
"db_name": "PostgreSQL",
"query": "SELECT app_id, value FROM app_version WHERE id = $1",
"query": "SELECT app_id, value, raw_app FROM app_version WHERE id = $1",
"describe": {
"columns": [
{
@@ -12,6 +12,11 @@
"ordinal": 1,
"name": "value",
"type_info": "Json"
},
{
"ordinal": 2,
"name": "raw_app",
"type_info": "Bool"
}
],
"parameters": {
@@ -20,9 +25,10 @@
]
},
"nullable": [
false,
false,
false
]
},
"hash": "ea9bbb972217bab4d7e8f4c08e331899161e80c239d56eb657d73bbf4272939b"
"hash": "19cca1d42f37e860dc54470fea8dd9a35c412d82d27ce369ccb0ba38b9791669"
}
@@ -0,0 +1,23 @@
{
"db_name": "PostgreSQL",
"query": "SELECT app_version.raw_app FROM app\n JOIN app_version ON app_version.id = app.versions[array_upper(app.versions, 1)]\n WHERE app.path = $1 AND app.workspace_id = $2",
"describe": {
"columns": [
{
"ordinal": 0,
"name": "raw_app",
"type_info": "Bool"
}
],
"parameters": {
"Left": [
"Text",
"Text"
]
},
"nullable": [
false
]
},
"hash": "fb321fba5f4508d6cff5bae5a7c5a120d12b43a2f6056c3fff1c7c099b5f248a"
}
+1 -1
View File
@@ -1 +1 @@
6262e373ede45b5b8d45505a63ff73968c04336a
da0a3751abd2b0fed46ca5c7a3aef35923403b28
+27 -5
View File
@@ -1303,6 +1303,18 @@ async fn delete_app(
));
}
// Check if it's a raw app before deletion
let is_raw_app = sqlx::query_scalar!(
"SELECT app_version.raw_app FROM app
JOIN app_version ON app_version.id = app.versions[array_upper(app.versions, 1)]
WHERE app.path = $1 AND app.workspace_id = $2",
path,
&w_id
)
.fetch_optional(&db)
.await?
.unwrap_or(false);
let mut tx = user_db.begin(&authed).await?;
sqlx::query!(
@@ -1333,16 +1345,26 @@ async fn delete_app(
.await?;
tx.commit().await?;
let deployed_object = if is_raw_app {
DeployedObject::RawApp {
path: path.to_string(),
parent_path: Some(path.to_string()),
version: 0, // dummy version as it will not get inserted in db
}
} else {
DeployedObject::App {
path: path.to_string(),
parent_path: Some(path.to_string()),
version: 0, // dummy version as it will not get inserted in db
}
};
handle_deployment_metadata(
&authed.email,
&authed.username,
&db,
&w_id,
DeployedObject::App {
path: path.to_string(),
parent_path: Some(path.to_string()),
version: 0, // dummy version as it will not get inserted in db
},
deployed_object,
Some(format!("App '{}' deleted", path)),
true,
)
+4
View File
@@ -19,6 +19,7 @@ pub enum DeployedObject {
Script { hash: ScriptHash, path: String, parent_path: Option<String> },
Flow { path: String, parent_path: Option<String>, version: i64 },
App { path: String, version: i64, parent_path: Option<String> },
RawApp { path: String, version: i64, parent_path: Option<String> },
Folder { path: String },
Resource { path: String, parent_path: Option<String> },
Variable { path: String, parent_path: Option<String> },
@@ -45,6 +46,7 @@ impl DeployedObject {
DeployedObject::Script { path, .. } => path.to_owned(),
DeployedObject::Flow { path, .. } => path.to_owned(),
DeployedObject::App { path, .. } => path.to_owned(),
DeployedObject::RawApp { path, .. } => path.to_owned(),
DeployedObject::Folder { path, .. } => path.to_owned(),
DeployedObject::Resource { path, .. } => path.to_owned(),
DeployedObject::Variable { path, .. } => path.to_owned(),
@@ -82,6 +84,7 @@ impl DeployedObject {
DeployedObject::Script { parent_path, .. } => parent_path.to_owned(),
DeployedObject::Flow { parent_path, .. } => parent_path.to_owned(),
DeployedObject::App { parent_path, .. } => parent_path.to_owned(),
DeployedObject::RawApp { parent_path, .. } => parent_path.to_owned(),
DeployedObject::Folder { .. } => None,
DeployedObject::Resource { parent_path, .. } => parent_path.to_owned(),
DeployedObject::Variable { parent_path, .. } => parent_path.to_owned(),
@@ -108,6 +111,7 @@ impl DeployedObject {
DeployedObject::Script { .. } => "script",
DeployedObject::Flow { .. } => "flow",
DeployedObject::App { .. } => "app",
DeployedObject::RawApp { .. } => "raw_app",
DeployedObject::Folder { .. } => "folder",
DeployedObject::Resource { .. } => "resource",
DeployedObject::Variable { .. } => "variable",
@@ -2178,10 +2178,13 @@ pub async fn handle_app_dependency_job(
.execute(db)
.await?;
let record = sqlx::query!("SELECT app_id, value FROM app_version WHERE id = $1", id)
.fetch_optional(db)
.await?
.map(|record| (record.app_id, record.value));
let record = sqlx::query!(
"SELECT app_id, value, raw_app FROM app_version WHERE id = $1",
id
)
.fetch_optional(db)
.await?
.map(|record| (record.app_id, record.value, record.raw_app));
let (_, parent_path) = get_deployment_msg_and_parent_path_from_args(job.args.clone());
@@ -2195,7 +2198,7 @@ pub async fn handle_app_dependency_job(
.await?;
// TODO: Use transaction for entire segment?
if let Some((app_id, value)) = record {
if let Some((app_id, value, is_raw_app)) = record {
let value = lock_modules_app(
value,
&job,
@@ -2275,12 +2278,18 @@ pub async fn handle_app_dependency_job(
let (deployment_message, parent_path) =
get_deployment_msg_and_parent_path_from_args(job.args.clone());
let deployed_object = if is_raw_app {
DeployedObject::RawApp { path: job_path, version: id, parent_path }
} else {
DeployedObject::App { path: job_path, version: id, parent_path }
};
if let Err(e) = handle_deployment_metadata(
&job.permissioned_as_email,
&job.created_by,
&db,
&job.workspace_id,
DeployedObject::App { path: job_path, version: id, parent_path },
deployed_object,
deployment_message,
false,
)
+1 -1
View File
@@ -20,7 +20,7 @@
"gitSync_18": "hub/28078/sync-script-to-git-repo-windmill",
"gitSync_19": "hub/28081/sync-script-to-git-repo-windmill",
"gitSync_20": "hub/28102/sync-script-to-git-repo-windmill",
"gitSync": "hub/28116/sync-script-to-git-repo-windmill",
"gitSync": "hub/28118/sync-script-to-git-repo-windmill",
"gitSyncTest": "hub/19799/git-repo-test-read-write-windmill",
"gitInitRepo": "hub/28109/git-sync%3A-init-repository-windmill",
"slackErrorHandler": "hub/19741/workspace-or-schedule-error-handler-slack",