Add ability to set commit messages when editing functions
This commit is contained in:
@@ -354,6 +354,7 @@ def edit(function_id):
|
||||
data = request.json
|
||||
trigger_type = data.get('trigger_type')
|
||||
runtime = data.get('runtime', 'node')
|
||||
commit_message = data.get('commit_message', '')
|
||||
|
||||
# Validate trigger type
|
||||
if trigger_type not in ('interval', 'date', 'cron'):
|
||||
@@ -415,6 +416,22 @@ def edit(function_id):
|
||||
current_user.id
|
||||
],
|
||||
commit=True)
|
||||
|
||||
# Update the commit message for the newly created version
|
||||
# Note: The database trigger creates a new version after the UPDATE,
|
||||
# so we need to get the latest version number
|
||||
if commit_message:
|
||||
latest_version = db.execute(
|
||||
"SELECT MAX(version_number) as version_number FROM timer_function_versions WHERE timer_function_id = %s",
|
||||
[function_id],
|
||||
one=True
|
||||
)
|
||||
if latest_version:
|
||||
db.execute(
|
||||
"UPDATE timer_function_versions SET commit_message = %s WHERE timer_function_id = %s AND version_number = %s",
|
||||
[commit_message, function_id, latest_version['version_number']],
|
||||
commit=True
|
||||
)
|
||||
|
||||
return jsonify({
|
||||
"status": "success",
|
||||
@@ -572,7 +589,7 @@ def history(function_id):
|
||||
|
||||
# Fetch all versions
|
||||
versions = db.execute("""
|
||||
SELECT version_number, script, versioned_at
|
||||
SELECT version_number, script, versioned_at, commit_message
|
||||
FROM timer_function_versions
|
||||
WHERE timer_function_id = %s
|
||||
ORDER BY version_number DESC
|
||||
|
||||
Reference in New Issue
Block a user