Skip to content

Commit

Permalink
Use date as release title in webhook
Browse files Browse the repository at this point in the history
  • Loading branch information
rubenwardy committed Mar 5, 2024
1 parent a94c398 commit a736499
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
4 changes: 3 additions & 1 deletion app/blueprints/github/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.

import datetime

from flask import Blueprint, abort
from flask_babel import gettext

Expand Down Expand Up @@ -147,7 +149,7 @@ def webhook():
event = request.headers.get("X-GitHub-Event")
if event == "push":
ref = json["after"]
title = json["head_commit"]["message"].partition("\n")[0]
title = datetime.datetime.utcnow().strftime("%Y-%m-%d") + " " + ref[:5]
branch = json["ref"].replace("refs/heads/", "")
if branch not in [ "master", "main" ]:
return jsonify({ "success": False, "message": "Webhook ignored, as it's not on the master/main branch" })
Expand Down
4 changes: 2 additions & 2 deletions app/blueprints/gitlab/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
import datetime

from flask import Blueprint, request, jsonify

Expand Down Expand Up @@ -53,8 +54,7 @@ def webhook_impl():
event = json["event_name"]
if event == "push":
ref = json["after"]
title = ref[:5]

title = datetime.datetime.utcnow().strftime("%Y-%m-%d") + " " + ref[:5]
branch = json["ref"].replace("refs/heads/", "")
if branch not in ["master", "main"]:
return jsonify({"success": False,
Expand Down

0 comments on commit a736499

Please sign in to comment.