Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 2 additions & 12 deletions apps/staged/src-tauri/src/actions/commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,6 @@ pub(crate) async fn run_branch_action_impl(
let metadata = ActionMetadata {
action_id: action.id.clone(),
action_name: action.name.clone(),
auto_commit: action.auto_commit,
};

// Clone values needed after execute() moves them.
Expand Down Expand Up @@ -309,15 +308,8 @@ pub(crate) async fn run_branch_action_impl(
shell_command,
];

// Provide auto-commit context so that after a successful action,
// git commands run on the remote workspace via `sq blox ws exec`.
// When there's no resolved path we can't determine the git working
// directory, so auto-commit is skipped (unlikely for remote branches).
let auto_commit_info = resolved_repo_path
.map(|resolved| (sq_binary.clone(), workspace_name.to_string(), resolved));

let eid = executor
.execute_remote(sq_binary, args, metadata, listener, auto_commit_info)
.execute_remote(sq_binary, args, metadata, listener)
.await
.map_err(|e| format!("Failed to execute remote action: {e}"))?;

Expand Down Expand Up @@ -653,8 +645,7 @@ pub(crate) async fn run_prerun_actions_impl(
suggestion.command,
suggestion.action_type,
next_sort_order,
)
.with_auto_commit(suggestion.auto_commit);
);
store
.create_repo_action(&action)
.map_err(|e| format!("Failed to create detected action: {e}"))?;
Expand Down Expand Up @@ -715,7 +706,6 @@ pub(crate) async fn run_prerun_actions_impl(
let metadata = ActionMetadata {
action_id: action.id.clone(),
action_name: action.name.clone(),
auto_commit: action.auto_commit,
};

let execution_id = executor
Expand Down
14 changes: 0 additions & 14 deletions apps/staged/src-tauri/src/actions/events.rs
Original file line number Diff line number Diff line change
Expand Up @@ -155,20 +155,6 @@ impl ExecutionListener for TauriExecutionListener {
},
);
}
ExecutionEvent::AutoCommit {
execution_id,
action_name,
} => {
crate::web_server::emit_to_all(
&self.app,
"action_auto_commit",
serde_json::json!({
"executionId": execution_id,
"branchId": self.branch_id,
"actionName": action_name,
}),
);
}
}
}
}
Expand Down
4 changes: 1 addition & 3 deletions apps/staged/src-tauri/src/branches.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2450,8 +2450,7 @@ pub(crate) async fn run_prerun_actions_for_branch(
suggestion.command,
suggestion.action_type,
next_sort_order,
)
.with_auto_commit(suggestion.auto_commit);
);
store
.create_repo_action(&action)
.map_err(|e| format!("Failed to create detected action: {e}"))?;
Expand Down Expand Up @@ -2516,7 +2515,6 @@ pub(crate) async fn run_prerun_actions_for_branch(
let metadata = ActionMetadata {
action_id: action.id.clone(),
action_name: action.name.clone(),
auto_commit: action.auto_commit,
};

// execute_and_wait runs the action and waits for it to finish,
Expand Down
7 changes: 1 addition & 6 deletions apps/staged/src-tauri/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1662,7 +1662,6 @@ fn update_project_action(
command: String,
action_type: String,
sort_order: i32,
auto_commit: bool,
) -> Result<(), String> {
let store = get_store(&store)?;
let action = store
Expand All @@ -1678,7 +1677,6 @@ fn update_project_action(
action_type: builderbot_actions::ActionType::parse(&action_type)
.ok_or_else(|| format!("Invalid action type: {action_type}"))?,
sort_order,
auto_commit,
run_detection_mode: action.run_detection_mode,
created_at: action.created_at,
updated_at: store::now_timestamp(),
Expand Down Expand Up @@ -1724,7 +1722,6 @@ fn list_repo_actions(
}

#[tauri::command(rename_all = "camelCase")]
#[allow(clippy::too_many_arguments)]
fn create_repo_action(
store: tauri::State<'_, Mutex<Option<Arc<Store>>>>,
github_repo: String,
Expand All @@ -1733,16 +1730,14 @@ fn create_repo_action(
command: String,
action_type: String,
sort_order: i32,
auto_commit: bool,
) -> Result<store::models::RepoAction, String> {
let store = get_store(&store)?;
let context = store
.get_or_create_action_context(&github_repo, subpath.as_deref())
.map_err(|e| e.to_string())?;
let parsed_type = builderbot_actions::ActionType::parse(&action_type)
.ok_or_else(|| format!("Invalid action type: {action_type}"))?;
let action = store::models::RepoAction::new(context.id, name, command, parsed_type, sort_order)
.with_auto_commit(auto_commit);
let action = store::models::RepoAction::new(context.id, name, command, parsed_type, sort_order);
store
.create_repo_action(&action)
.map_err(|e| e.to_string())?;
Expand Down
20 changes: 8 additions & 12 deletions apps/staged/src-tauri/src/store/actions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,16 +118,15 @@ impl Store {
.transpose()
.map_err(|e| StoreError(format!("Failed to serialize run_detection_mode: {e}")))?;
conn.execute(
"INSERT INTO repo_actions (id, context_id, name, command, action_type, sort_order, auto_commit, run_detection_mode, created_at, updated_at)
VALUES (?1, ?2, ?3, ?4, ?5, ?6, ?7, ?8, ?9, ?10)",
"INSERT INTO repo_actions (id, context_id, name, command, action_type, sort_order, run_detection_mode, created_at, updated_at)
VALUES (?1, ?2, ?3, ?4, ?5, ?6, ?7, ?8, ?9)",
params![
action.id,
action.context_id,
action.name,
action.command,
action.action_type.as_str(),
action.sort_order,
action.auto_commit as i32,
run_detection_mode_json,
action.created_at,
action.updated_at,
Expand All @@ -139,7 +138,7 @@ impl Store {
pub fn get_repo_action(&self, id: &str) -> Result<Option<RepoAction>, StoreError> {
let conn = self.conn.lock().unwrap();
conn.query_row(
"SELECT id, context_id, name, command, action_type, sort_order, auto_commit, run_detection_mode, created_at, updated_at
"SELECT id, context_id, name, command, action_type, sort_order, run_detection_mode, created_at, updated_at
FROM repo_actions WHERE id = ?1",
params![id],
Self::row_to_repo_action,
Expand All @@ -151,7 +150,7 @@ impl Store {
pub fn list_repo_actions(&self, context_id: &str) -> Result<Vec<RepoAction>, StoreError> {
let conn = self.conn.lock().unwrap();
let mut stmt = conn.prepare(
"SELECT id, context_id, name, command, action_type, sort_order, auto_commit, run_detection_mode, created_at, updated_at
"SELECT id, context_id, name, command, action_type, sort_order, run_detection_mode, created_at, updated_at
FROM repo_actions WHERE context_id = ?1 ORDER BY sort_order ASC",
)?;
let rows = stmt.query_map(params![context_id], Self::row_to_repo_action)?;
Expand All @@ -167,13 +166,12 @@ impl Store {
.transpose()
.map_err(|e| StoreError(format!("Failed to serialize run_detection_mode: {e}")))?;
conn.execute(
"UPDATE repo_actions SET name = ?1, command = ?2, action_type = ?3, sort_order = ?4, auto_commit = ?5, run_detection_mode = ?6, updated_at = ?7 WHERE id = ?8",
"UPDATE repo_actions SET name = ?1, command = ?2, action_type = ?3, sort_order = ?4, run_detection_mode = ?5, updated_at = ?6 WHERE id = ?7",
params![
action.name,
action.command,
action.action_type.as_str(),
action.sort_order,
action.auto_commit as i32,
run_detection_mode_json,
now_timestamp(),
action.id,
Expand Down Expand Up @@ -234,8 +232,7 @@ impl Store {

fn row_to_repo_action(row: &rusqlite::Row) -> rusqlite::Result<RepoAction> {
let action_type_str: String = row.get(4)?;
let auto_commit: i32 = row.get(6)?;
let run_detection_mode_str: Option<String> = row.get(7)?;
let run_detection_mode_str: Option<String> = row.get(6)?;
let run_detection_mode: Option<RunDetectionMode> = run_detection_mode_str
.as_deref()
.and_then(|s| serde_json::from_str(s).ok());
Expand All @@ -246,10 +243,9 @@ impl Store {
command: row.get(3)?,
action_type: ActionType::parse(&action_type_str).unwrap_or(ActionType::Run),
sort_order: row.get(5)?,
auto_commit: auto_commit != 0,
run_detection_mode,
created_at: row.get(8)?,
updated_at: row.get(9)?,
created_at: row.get(7)?,
updated_at: row.get(8)?,
})
}
}
14 changes: 11 additions & 3 deletions apps/staged/src-tauri/src/store/migration_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ fn test_store_bootstraps_fresh_database_with_baseline_migration() {
)
.unwrap();

assert_eq!(version, 15);
assert_eq!(version, 16);
assert_eq!(app_version, super::APP_VERSION);
assert!(table_exists(&conn, "projects"));
assert!(table_exists(&conn, "project_notes"));
Expand Down Expand Up @@ -193,6 +193,10 @@ fn test_store_repairs_github_comment_tracking_user_version() {
github_comment_type TEXT,
github_comment_stale INTEGER NOT NULL DEFAULT 0
);
CREATE TABLE repo_actions (
id TEXT PRIMARY KEY,
auto_commit INTEGER NOT NULL DEFAULT 0
);
",
)
.unwrap();
Expand All @@ -205,7 +209,7 @@ fn test_store_repairs_github_comment_tracking_user_version() {
let version: i64 = conn
.query_row("PRAGMA user_version", [], |row| row.get(0))
.unwrap();
assert_eq!(version, 15);
assert_eq!(version, 16);
assert!(column_exists(&conn, "sessions", "pipeline"));

cleanup_db(&path);
Expand Down Expand Up @@ -236,6 +240,10 @@ fn test_store_repairs_pipeline_user_version() {
PRIMARY KEY (github_repo, subpath)
);
CREATE TABLE comments (id TEXT PRIMARY KEY);
CREATE TABLE repo_actions (
id TEXT PRIMARY KEY,
auto_commit INTEGER NOT NULL DEFAULT 0
);
",
)
.unwrap();
Expand All @@ -248,7 +256,7 @@ fn test_store_repairs_pipeline_user_version() {
let version: i64 = conn
.query_row("PRAGMA user_version", [], |row| row.get(0))
.unwrap();
assert_eq!(version, 15);
assert_eq!(version, 16);
assert!(column_exists(&conn, "comments", "github_comment_id"));
assert!(column_exists(&conn, "comments", "github_comment_type"));
assert!(column_exists(&conn, "comments", "github_comment_stale"));
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
-- The auto-commit option has been removed from project actions. Actions now
-- only execute their command and never create git commits, so the column that
-- backed the per-action toggle is no longer needed.
ALTER TABLE repo_actions DROP COLUMN auto_commit;
7 changes: 0 additions & 7 deletions apps/staged/src-tauri/src/store/models.rs
Original file line number Diff line number Diff line change
Expand Up @@ -934,7 +934,6 @@ pub struct RepoAction {
pub command: String,
pub action_type: ActionType,
pub sort_order: i32,
pub auto_commit: bool,
pub run_detection_mode: Option<RunDetectionMode>,
pub created_at: i64,
pub updated_at: i64,
Expand All @@ -956,17 +955,11 @@ impl RepoAction {
command,
action_type,
sort_order,
auto_commit: false,
run_detection_mode: None,
created_at: now,
updated_at: now,
}
}

pub fn with_auto_commit(mut self, auto_commit: bool) -> Self {
self.auto_commit = auto_commit;
self
}
}

// =============================================================================
Expand Down
6 changes: 1 addition & 5 deletions apps/staged/src-tauri/src/web_server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2025,7 +2025,6 @@ async fn dispatch(command: &str, args: Value, state: &WebAppState) -> Result<Val
let command_str: String = arg(&args, "command")?;
let action_type: String = arg(&args, "actionType")?;
let sort_order: i32 = arg(&args, "sortOrder")?;
let auto_commit: bool = arg(&args, "autoCommit")?;
let action = store
.get_repo_action(&action_id)
.map_err(|e| e.to_string())?
Expand All @@ -2038,7 +2037,6 @@ async fn dispatch(command: &str, args: Value, state: &WebAppState) -> Result<Val
action_type: builderbot_actions::ActionType::parse(&action_type)
.ok_or_else(|| format!("Invalid action type: {action_type}"))?,
sort_order,
auto_commit,
run_detection_mode: action.run_detection_mode,
created_at: action.created_at,
updated_at: crate::store::now_timestamp(),
Expand Down Expand Up @@ -2081,7 +2079,6 @@ async fn dispatch(command: &str, args: Value, state: &WebAppState) -> Result<Val
let command_str: String = arg(&args, "command")?;
let action_type: String = arg(&args, "actionType")?;
let sort_order: i32 = arg(&args, "sortOrder")?;
let auto_commit: bool = arg(&args, "autoCommit")?;
let context = store
.get_or_create_action_context(&github_repo, subpath.as_deref())
.map_err(|e| e.to_string())?;
Expand All @@ -2093,8 +2090,7 @@ async fn dispatch(command: &str, args: Value, state: &WebAppState) -> Result<Val
command_str,
parsed_type,
sort_order,
)
.with_auto_commit(auto_commit);
);
store
.create_repo_action(&action)
.map_err(|e| e.to_string())?;
Expand Down
9 changes: 2 additions & 7 deletions apps/staged/src/lib/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -449,7 +449,6 @@ export interface ProjectAction {
command: string;
actionType: string;
sortOrder: number;
autoCommit: boolean;
createdAt: number;
updatedAt: number;
}
Expand All @@ -466,16 +465,14 @@ export function updateProjectAction(
name: string,
command: string,
actionType: string,
sortOrder: number,
autoCommit: boolean
sortOrder: number
): Promise<void> {
return invokeCommand('update_project_action', {
actionId,
name,
command,
actionType,
sortOrder,
autoCommit,
});
}

Expand Down Expand Up @@ -507,8 +504,7 @@ export function createRepoAction(
name: string,
command: string,
actionType: string,
sortOrder: number,
autoCommit: boolean
sortOrder: number
): Promise<ProjectAction> {
return invokeCommand('create_repo_action', {
githubRepo,
Expand All @@ -517,7 +513,6 @@ export function createRepoAction(
command,
actionType,
sortOrder,
autoCommit,
});
}

Expand Down
Loading