Skip to content

Commit 2e5b5cc

Browse files
author
ChadKluck
committed
updated update.py see changelog
1 parent 6cb1d29 commit 2e5b5cc

File tree

2 files changed

+82
-11
lines changed

2 files changed

+82
-11
lines changed

cli/CHANGELOG.md

Lines changed: 52 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,61 @@ To update your local cli scripts from GitHub repository:
1212
- Refer to [TODO](../TODO.md) for upcoming BETA fixes and features.
1313
- Report any issues not covered in TODO via the [Issues page in the GitHub repository](https://github.com/63Klabs/atlantis-cfn-configuration-repo-for-serverless-deployments/issues)
1414

15-
## v0.0.7 (2025-06-xx)
15+
## v0.0.8 (2025-06-xx)
1616

1717
Upcoming
1818

19+
## v0.0.7 (2025-06-10)
20+
21+
Mostly stable. Still in Beta.
22+
23+
I'm going to go into a little more detail than usual.
24+
25+
- update.py (v0.1.5/2025-06-10): Fixed issue where the downloaded release zip file does not contain the `v` in front of the version number even if the release tag in GitHub has the `v`. This irregularity lies in GitHub and is a weird quirk that according to my conversation with GitHub Copilot is "undocumented but reproducible." This is even experienced when downloading a zip directly from the release page. The link will point to `<url>/v0.0.6.zip`, but the downloaded file will be `<repo-name>-0.0.6.zip` with files extracted to `<repo-name>-0.0.6.zip`.
26+
- For the fix, GitHub Copilot recommended that instead of constructing the path beforehand, look inside the zip file and see what the actual path is. This should hopefully fix any future issue.
27+
28+
Below is GitHub Copilot's explanation. (Note: it says "This is a GitHub quirk for repositories with a dash (`-`) in the tag name" but there isn't a dash in the tag name, so there is still some inconsistencies as to why this happens.) However, I provide this information because:
29+
30+
1. GitHub Copilot admitted I was right :)
31+
2. "This is not documented by GitHub, but is reproducible and widely observed." (so there could still be other quirks that need to be accounted for in the future)
32+
33+
### From GitHub Copilot
34+
35+
Thank you for the detailed info and the direct observation.
36+
37+
You are correct: **the downloaded file is named**
38+
39+
```
40+
atlantis-cfn-configuration-repo-for-serverless-deployments-0.0.6.zip
41+
```
42+
**even though the tag is `v0.0.6`.**
43+
44+
#### Why does this happen?
45+
46+
This is a GitHub quirk for repositories with a dash (`-`) in the tag name.
47+
48+
GitHub strips the leading `v` from the zip file and folder name **if the tag is in the format `vX.Y.Z`**.
49+
50+
- The actual tag in the repo is still `v0.0.6`.
51+
- The zip file and extracted folder are named as if the tag is `0.0.6`.
52+
53+
**This is not documented by GitHub, but is reproducible and widely observed.**
54+
55+
#### What does this mean for your code?
56+
57+
Your code currently does:
58+
59+
```python
60+
zipped_dir = f"{repo}-{tag}/"
61+
```
62+
63+
If `tag` is `v0.0.6`, but the extracted folder is `atlantis-cfn-configuration-repo-for-serverless-deployments-0.0.6/`, your code will not find the right directory.
64+
65+
#### Summary
66+
67+
- GitHub sometimes strips the leading `v` from zip/folder names for tags like `v0.0.6`.
68+
- Adjust your code to check for both possibilities.
69+
1970
## v0.0.6 (2025-06-09)
2071

2172
Mostly stable. Still in Beta.

cli/update.py

Lines changed: 30 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/usr/bin/env python3
22

3-
VERSION = "v0.1.4/2025-06-09"
3+
VERSION = "v0.1.5/2025-06-10"
44
# Created by Chad Kluck with AI assistance from Amazon Q Developer
55

66
import os
@@ -342,19 +342,39 @@ def update_from_zip(self, zip_location: str ) -> bool:
342342

343343
# If the zip file is from github, then the extracted base path will be <repo>-<tag>
344344
zipped_dir = ""
345-
if self.src_type == "github":
346-
result = self.get_github_repo_info(self.source)
347-
repo = result['repo']
348-
tag = result['tag']
345+
# if self.src_type == "github":
346+
# result = self.get_github_repo_info(self.source)
347+
# repo = result['repo']
348+
# tag = result['tag']
349+
350+
# if tag == "":
351+
# tag = "main"
349352

350-
if tag == "":
351-
tag = "main"
352-
zipped_dir = f"{repo}-{tag}/"
353+
# print(f"Repo: {repo} Tag: {tag}")
354+
# zipped_dir = f"{repo}-{tag}/"
353355

354-
ConsoleAndLog.info(f"Extracted directory: {zipped_dir}")
355-
ConsoleAndLog.info(f"Target directories: {self.target_dirs}")
356+
# print(f"Zipped dir: {zipped_dir}")
357+
358+
# ConsoleAndLog.info(f"Extracted directory: {zipped_dir}")
359+
# ConsoleAndLog.info(f"Target directories: {self.target_dirs}")
356360

357361
with zipfile.ZipFile(zip_location, 'r') as zip_ref:
362+
363+
# Dynamically detect the top-level directory in the zip
364+
top_level_dirs = set(
365+
file_info.filename.split('/')[0]
366+
for file_info in zip_ref.filelist
367+
if '/' in file_info.filename
368+
)
369+
if self.src_type == "github" and top_level_dirs:
370+
# There should be only one top-level directory in a GitHub zip
371+
zipped_dir = list(top_level_dirs)[0] + "/"
372+
373+
print(f"Zipped dir: {zipped_dir}")
374+
375+
ConsoleAndLog.info(f"Extracted directory: {zipped_dir}")
376+
ConsoleAndLog.info(f"Target directories: {self.target_dirs}")
377+
358378
# Extract only the directories we want
359379
for file_info in zip_ref.filelist:
360380
for target_dir in self.target_dirs:

0 commit comments

Comments
 (0)