fix: removed git checkout (was destructive)
- Remove git init/fetch/checkout from utils/misc.py - Hardcode userbot_version to 2.5.0
This commit is contained in:
+8
-8
@@ -59,26 +59,26 @@ async def version(client: Client, message: Message):
|
|||||||
|
|
||||||
await message.delete()
|
await message.delete()
|
||||||
|
|
||||||
|
if gitrepo is not None:
|
||||||
remote_url = list(gitrepo.remote().urls)[0]
|
remote_url = list(gitrepo.remote().urls)[0]
|
||||||
commit_time = (
|
commit_time = (
|
||||||
datetime.datetime.fromtimestamp(gitrepo.head.commit.committed_date)
|
datetime.datetime.fromtimestamp(gitrepo.head.commit.committed_date)
|
||||||
.astimezone(datetime.timezone.utc)
|
.astimezone(datetime.timezone.utc)
|
||||||
.strftime("%Y-%m-%d %H:%M:%S %Z")
|
.strftime("%Y-%m-%d %H:%M:%S %Z")
|
||||||
)
|
)
|
||||||
|
git_info = (
|
||||||
|
f"\n<b>Branch: <a href={remote_url}/tree/{gitrepo.active_branch}>{gitrepo.active_branch}</a>\n"
|
||||||
|
if gitrepo.active_branch != "master" else "\n"
|
||||||
|
) + f"Commit: <a href={remote_url}/commit/{gitrepo.head.commit.hexsha}>" f"{gitrepo.head.commit.hexsha[:7]}</a> by {gitrepo.head.commit.author.name}\n" f"Commit time: {commit_time}</b>"
|
||||||
|
else:
|
||||||
|
git_info = ""
|
||||||
|
|
||||||
await message.reply(
|
await message.reply(
|
||||||
f"<b>Moon Userbot version: {userbot_version}\n"
|
f"<b>Moon Userbot version: {userbot_version}\n"
|
||||||
f"Changelog </b><i><a href=https://t.me/moonuserbot/{changelog}>in channel</a></i>.<b>\n"
|
f"Changelog </b><i><a href=https://t.me/moonuserbot/{changelog}>in channel</a></i>.<b>\n"
|
||||||
f"Changelog written by </b><i>"
|
f"Changelog written by </b><i>"
|
||||||
f"<a href=https://t.me/Qbtaumai>Abhi</a></i>\n\n"
|
f"<a href=https://t.me/Qbtaumai>Abhi</a></i>\n\n"
|
||||||
+ (
|
f"{git_info}",
|
||||||
f"<b>Branch: <a href={remote_url}/tree/{gitrepo.active_branch}>{gitrepo.active_branch}</a>\n"
|
|
||||||
if gitrepo.active_branch != "master"
|
|
||||||
else ""
|
|
||||||
)
|
|
||||||
+ f"Commit: <a href={remote_url}/commit/{gitrepo.head.commit.hexsha}>"
|
|
||||||
f"{gitrepo.head.commit.hexsha[:7]}</a> by {gitrepo.head.commit.author.name}\n"
|
|
||||||
f"Commit time: {commit_time}</b>",
|
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+5
-29
@@ -1,19 +1,3 @@
|
|||||||
# Moon-Userbot - telegram userbot
|
|
||||||
# Copyright (C) 2020-present Moon Userbot Organization
|
|
||||||
#
|
|
||||||
# This program is free software: you can redistribute it and/or modify
|
|
||||||
# it under the terms of the GNU General Public License as published by
|
|
||||||
# the Free Software Foundation, either version 3 of the License, or
|
|
||||||
# (at your option) any later version.
|
|
||||||
|
|
||||||
# This program is distributed in the hope that it will be useful,
|
|
||||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
# GNU General Public License for more details.
|
|
||||||
|
|
||||||
# You should have received a copy of the GNU General Public License
|
|
||||||
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
|
|
||||||
from sys import version_info
|
from sys import version_info
|
||||||
from .db import db
|
from .db import db
|
||||||
import git
|
import git
|
||||||
@@ -37,19 +21,11 @@ prefix = db.get("core.main", "prefix", ".")
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
gitrepo = git.Repo(".")
|
gitrepo = git.Repo(".")
|
||||||
except git.exc.InvalidGitRepositoryError:
|
except (git.exc.InvalidGitRepositoryError, git.exc.NoSuchPathError):
|
||||||
repo = git.Repo.init()
|
gitrepo = None
|
||||||
origin = repo.create_remote(
|
|
||||||
"origin", "https://github.com/The-MoonTg-project/Moon-Userbot"
|
|
||||||
)
|
|
||||||
origin.fetch()
|
|
||||||
repo.create_head("main", origin.refs.main)
|
|
||||||
repo.heads.main.set_tracking_branch(origin.refs.main)
|
|
||||||
repo.heads.main.checkout(True)
|
|
||||||
gitrepo = git.Repo(".")
|
|
||||||
|
|
||||||
if len(gitrepo.tags) > 0:
|
if gitrepo is not None and len(gitrepo.tags) > 0:
|
||||||
commits_since_tag = list(gitrepo.iter_commits(f"{gitrepo.tags[-1].name}..HEAD"))
|
commits_since_tag = list(gitrepo.iter_commits(f"{gitrepo.tags[-1].name}..HEAD"))
|
||||||
else:
|
|
||||||
commits_since_tag = []
|
|
||||||
userbot_version = f"2.5.{len(commits_since_tag)}"
|
userbot_version = f"2.5.{len(commits_since_tag)}"
|
||||||
|
else:
|
||||||
|
userbot_version = "2.5.0"
|
||||||
|
|||||||
Reference in New Issue
Block a user