From f7bd4fead65a0c9d582408ae751490257758a647 Mon Sep 17 00:00:00 2001 From: Benny Date: Sun, 1 Dec 2024 18:00:56 +0100 Subject: [PATCH] pre-push --- README.md | 6 ------ pre-push.py | 22 ++++++++++++++++++++++ 2 files changed, 22 insertions(+), 6 deletions(-) create mode 100755 pre-push.py diff --git a/README.md b/README.md index a958fb82..3c5fbaa1 100644 --- a/README.md +++ b/README.md @@ -6,12 +6,6 @@ This Telegram bot allows you to download videos from YouTube and [other supported websites](#supported-websites). -# development -install pre-commit -```shell -cp pre-push.py .git/hooks/pre-push -chmod +x .git/hooks/pre-push -``` # Usage * EU🇪🇺: [https://t.me/benny_2ytdlbot](https://t.me/benny_2ytdlbot) diff --git a/pre-push.py b/pre-push.py new file mode 100755 index 00000000..17f6e49b --- /dev/null +++ b/pre-push.py @@ -0,0 +1,22 @@ +#!/usr/bin/env python3 +# coding: utf-8 + +# ytdlbot - pre-commit.py +# for dependabot + +import tomllib +import subprocess + + +with open("pyproject.toml", "rb") as file: + config = tomllib.load(file) + +with open("requirements.txt", "w") as file: + for item in config["project"]["dependencies"]: + if " " in item: + item = item.split()[-1] + file.write(f"{item}\n") + +# commit with amend +subprocess.run(["git", "add", "requirements.txt"]) +subprocess.run(["git", "commit", "--amend", "--no-edit"])