Skip to content

Commit

Permalink
v1.8.7 修复版本号问题
Browse files Browse the repository at this point in the history
  • Loading branch information
DoiiarX committed Dec 5, 2024
1 parent dec5f4f commit c91cc6a
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 8 deletions.
2 changes: 1 addition & 1 deletion cddagl/VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.8.6
1.8.7
1 change: 1 addition & 0 deletions cddagl/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
GITHUB_XRL_REMAINING = b'X-RateLimit-Remaining'
GITHUB_XRL_RESET = b'X-RateLimit-Reset'

CDDA_RELEASE_TAGS = '/repos/CleverRaven/Cataclysm-DDA/git/refs/tags'
CDDA_RELEASES = '/repos/CleverRaven/Cataclysm-DDA/releases'
CDDA_RELEASE_BY_TAG = lambda tag: f'/repos/CleverRaven/Cataclysm-DDA/releases/tags/{tag}'
CDDAGL_LATEST_RELEASE = '/repos/DoiiarX/CDDA-Game-Launcher/releases/latest'
Expand Down
70 changes: 63 additions & 7 deletions cddagl/ui/views/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -1547,8 +1547,8 @@ def find_build_finished(self):

target_regex = re.compile(
r'cdda-windows-' +
re.escape(asset_graphics) + r'-' +
re.escape(asset_platform) + self.selected_build_type +
r'with-graphics' + r'-' +
r'x64' +
r'b?(?P<build>[0-9\-]+)\.zip'
)

Expand Down Expand Up @@ -3015,6 +3015,30 @@ def warn_rate_limit(self, requests_remaining, reset_dt):
if selected_branch == self.experimental_radio_button:
self.find_build_warning_label.show()

def get_stable_tags(self):
url = cons.GITHUB_REST_API_URL + cons.CDDA_RELEASE_TAGS
tag_regex = re.compile(r'(refs/tags/)(cdda-|)(0\.[A-Z]-)([0-9\-]+|[a-zA-Z]+|)')


try:
tags_data = requests.get(url).json()
except:
tags_data = []
stable_refs = list(filter(lambda d: tag_regex.match(d['ref']), tags_data))
stable_tags = []
stable_letter = ""
# Reverse order to deal with the most recent first
for entry in reversed(stable_refs):
# Extract the actual tag
tag = re.sub(r'refs/tags/', '', entry['ref'])
# Get the stable version: 0.H, 0.I etc
tmp_letter = re.compile(r'0.[A-Z]').search(tag).group(0)
if tmp_letter != stable_letter: # Only get the first unique stable you find
stable_letter = tmp_letter
stable_tags.append(tag)

return stable_tags

def lb_http_finished(self):
main_window = self.get_main_window()

Expand Down Expand Up @@ -3121,8 +3145,8 @@ def lb_http_finished(self):

target_regex = re.compile(
r'cdda-windows-' +
re.escape(asset_graphics) + r'-' +
re.escape(asset_platform) + self.selected_build_type +
r'with-graphics' + r'-' +
r'x64' +
r'b?(?P<build>[0-9\-]+)\.zip'
)

Expand Down Expand Up @@ -3267,6 +3291,38 @@ def refresh_builds(self):

builds = []

tmp_changelog = ""
build_regex = re.compile(r'cdda-windows-tiles' + r'(-x64|-x32)' + r'(-msvc-|-)' + r'([0-9\-]+)\.zip')
stable_tags = self.get_stable_tags()

last_idx = len(stable_tags) - 1
for tag in stable_tags:
url = cons.GITHUB_REST_API_URL + cons.CDDA_RELEASE_BY_TAG(tag)
try:
release = requests.get(url).json()
except:
continue

stable_name = re.compile(r'0.[A-Z]').search(release['tag_name']).group(0)
# Skip hardcoded releases
if stable_name in cons.STABLE_ASSETS:
continue
if release['prerelease']:
stable_name += ' release candidate'
tmp_changelog += f'<h3>{stable_name}</h3> <p><a href="https://github.com/CleverRaven/Cataclysm-DDA/blob/master/data/changelog.txt">Changelog</a></p>'
else:
tmp_changelog += f'<h3>{stable_name} {release["name"]}</h3>' + '<p>' + release['body'] + '</p>'
stable_assets = list(filter(lambda d: build_regex.match(d['name']), release['assets']))
# We simply get the first valid build
if isinstance(stable_assets, list) and len(stable_assets) > 1:
build = {
'url': stable_assets[0]['browser_download_url'],
'name': stable_name,
'number': tag,
'date': arrow.get(stable_assets[0]['created_at']).datetime
}
builds.append(build)

for stable_version in cons.STABLE_ASSETS:
version_details = cons.STABLE_ASSETS[stable_version]

Expand Down Expand Up @@ -3310,7 +3366,7 @@ def refresh_builds(self):

# Populate stable changelog

self.changelog_content.setHtml(cons.STABLE_CHANGELOG)
self.changelog_content.setHtml(tmp_changelog + cons.STABLE_CHANGELOG)


elif selected_branch is self.experimental_radio_button:
Expand Down Expand Up @@ -3499,8 +3555,8 @@ def step(self):
self.deleting = True

progress_bar = QProgressBar()
progress_bar.setRange(0, self.total_files)
progress_bar.setValue(0)
self.scale_factor = max(0, int(self.total_copy_size.bit_length()) - 31)
progress_bar.setRange(0, self.total_copy_size >> self.scale_factor)
self.status_bar.addWidget(progress_bar)
self.progress_bar = progress_bar

Expand Down

0 comments on commit c91cc6a

Please sign in to comment.