From d6519d5133e20f453fcc2cf210c11225b6275f0a Mon Sep 17 00:00:00 2001 From: Riley Housden Date: Fri, 19 Aug 2022 02:29:57 -0400 Subject: [PATCH] add dev-env detection --- ext/system.py | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/ext/system.py b/ext/system.py index 45093e3..8cb4f99 100644 --- a/ext/system.py +++ b/ext/system.py @@ -17,12 +17,22 @@ async def get_git_status() -> dict: stdout=asyncio.subprocess.PIPE, stderr=asyncio.subprocess.PIPE ) + dv_proc = await asyncio.create_subprocess_exec("git", "diff", "HEAD", + stdout=asyncio.subprocess.PIPE, + stderr=asyncio.subprocess.PIPE + ) stdout, _ = await id_proc.communicate() output["commit_id"] = stdout.decode("utf-8") stdout, _ = await br_proc.communicate() output["branch"] = stdout.decode("utf-8") + + stdout, _ = await dv_proc.communicate() + if stdout.decode("utf-8") == "": + output["dev"] = False + else: + output["dev"] = True except subprocess.SubprocessError as err: print(err) return output @@ -43,8 +53,9 @@ async def info(ctx: lightbulb.Context) -> None: git_status = await get_git_status() embed = hikari.Embed(title="About Me!") embed.add_field("GitHub", "https://gitdab.com/InValidFire/radical-bot") - embed.add_field("Version", git_status['commit_id']) - embed.add_field("Branch", git_status['branch']) + embed.add_field("Version", git_status['commit_id'], inline=True) + embed.add_field("Branch", git_status['branch'], inline=True) + embed.add_field("In Dev-Env?", git_status['dev']) await ctx.respond(embed) def load(bot: lightbulb.BotApp):