Skip to content

Commit ccde7b0

Browse files
committed
Make use of git branch --show-current to retrieve branch
1 parent a97119d commit ccde7b0

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@ however, insignificant breaking changes do not guarantee a major version bump, s
2020

2121
- Mentioned `competing` as an activity type. ([PR #2902](https://github.com/kyb3r/modmail/pull/2902))
2222

23+
### Internal
24+
25+
- Make use of `git branch --show-current` to retrieve branch insteasd of using prerelease version check.
26+
2327
# v3.7.13
2428

2529
### Fixed

core/changelog.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1+
import asyncio
12
import re
3+
from subprocess import PIPE
24
from typing import List
35

46
from discord import Embed
@@ -167,7 +169,17 @@ async def from_url(cls, bot, url: str = "") -> "Changelog":
167169
Changelog
168170
The newly created `Changelog` parsed from the `url`.
169171
"""
170-
branch = "master" if not bot.version.is_prerelease else "development"
172+
# get branch via git cli if available
173+
proc = await asyncio.create_subprocess_shell(
174+
"git branch --show-current", stderr=PIPE, stdout=PIPE,
175+
)
176+
err = await proc.stderr.read()
177+
err = err.decode("utf-8").rstrip()
178+
res = await proc.stdout.read()
179+
branch = res.decode("utf-8").rstrip()
180+
if not branch or err:
181+
branch = "master" if not bot.version.is_prerelease else "development"
182+
171183
url = url or f"https://raw.githubusercontent.com/kyb3r/modmail/{branch}/CHANGELOG.md"
172184

173185
async with await bot.session.get(url) as resp:

0 commit comments

Comments
 (0)