kin: KIN-048 Post-pipeline hook: автокоммит после успешного завершения задачи. git add -A && git commit -m 'kin: TASK_ID TITLE'. Срабатывает автоматически как rebuild-frontend.
This commit is contained in:
parent
8a6f280cbd
commit
ae21e48b65
13 changed files with 1554 additions and 65 deletions
49
core/db.py
49
core/db.py
|
|
@ -216,12 +216,61 @@ def _migrate(conn: sqlite3.Connection):
|
|||
conn.execute("ALTER TABLE tasks ADD COLUMN blocked_reason TEXT")
|
||||
conn.commit()
|
||||
|
||||
if "autocommit_enabled" not in proj_cols:
|
||||
conn.execute("ALTER TABLE projects ADD COLUMN autocommit_enabled INTEGER DEFAULT 0")
|
||||
conn.commit()
|
||||
|
||||
# Rename legacy 'auto' → 'auto_complete' (KIN-063)
|
||||
conn.execute(
|
||||
"UPDATE projects SET execution_mode = 'auto_complete' WHERE execution_mode = 'auto'"
|
||||
)
|
||||
conn.execute(
|
||||
"UPDATE tasks SET execution_mode = 'auto_complete' WHERE execution_mode = 'auto'"
|
||||
)
|
||||
conn.commit()
|
||||
|
||||
|
||||
def _seed_default_hooks(conn: sqlite3.Connection):
|
||||
"""Seed default hooks for the kin project (idempotent).
|
||||
|
||||
Creates rebuild-frontend hook only when:
|
||||
- project 'kin' exists in the projects table
|
||||
- the hook doesn't already exist (no duplicate)
|
||||
"""
|
||||
kin_exists = conn.execute(
|
||||
"SELECT 1 FROM projects WHERE id = 'kin'"
|
||||
).fetchone()
|
||||
if not kin_exists:
|
||||
return
|
||||
|
||||
exists = conn.execute(
|
||||
"SELECT 1 FROM hooks"
|
||||
" WHERE project_id = 'kin'"
|
||||
" AND name = 'rebuild-frontend'"
|
||||
" AND event = 'pipeline_completed'"
|
||||
).fetchone()
|
||||
if not exists:
|
||||
conn.execute(
|
||||
"""INSERT INTO hooks (project_id, name, event, command, enabled)
|
||||
VALUES ('kin', 'rebuild-frontend', 'pipeline_completed',
|
||||
'cd /Users/grosfrumos/projects/kin/web/frontend && npm run build',
|
||||
1)"""
|
||||
)
|
||||
conn.commit()
|
||||
|
||||
# Enable autocommit for kin project (opt-in, idempotent)
|
||||
conn.execute(
|
||||
"UPDATE projects SET autocommit_enabled=1 WHERE id='kin' AND autocommit_enabled=0"
|
||||
)
|
||||
conn.commit()
|
||||
|
||||
|
||||
def init_db(db_path: Path = DB_PATH) -> sqlite3.Connection:
|
||||
conn = get_connection(db_path)
|
||||
conn.executescript(SCHEMA)
|
||||
conn.commit()
|
||||
_migrate(conn)
|
||||
_seed_default_hooks(conn)
|
||||
return conn
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue