Skip to content

Commit 4d77f38

Browse files
committed
fix: existing checksum now warns instead of providing a stacktrace
1 parent dfef9a2 commit 4d77f38

3 files changed

Lines changed: 18 additions & 11 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
- Adds `custom_tarball` parameter, allowing you to bundle your distributable assets however you'd like (closes #63)
66
- Adds `branch` parameter, allowing you to push the formula file to any branch you'd like (closes #62)
77
- Homebrew Releaser now warns instead of raising an exception and exiting with a failure if the `git commit` operation is unsuccessful due to "nothing to commit". This is useful if you want to test back to back releases or need to recreate a release but the underlying assets have not changed (closes #69)
8+
- Existing `checksum.txt` files on the latest release now warn if they exist instead of exiting with a stacktrace
89
- Optimizes how asset URL selection occurs when downloading assets to generate checksums for
910
- Makes `formula_folder` optional as we always had a default of `Formula`, now allows users to omit its inclusion in their yaml
1011
- Bumps Homebrew to v5.0.9

homebrew_releaser/checksum.py

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ def calculate_checksum(tar_filepath: str) -> str:
2626
return checksum
2727

2828

29-
def upload_checksum_file(latest_release: dict[str, Any]):
29+
def upload_checksum_file(latest_release: dict[str, Any]) -> None:
3030
"""Uploads a `checksum.txt` file to the latest release of the repo."""
3131
logger = woodchips.get(LOGGER_NAME)
3232

@@ -39,11 +39,17 @@ def upload_checksum_file(latest_release: dict[str, Any]):
3939
headers = GITHUB_HEADERS.copy()
4040
headers["Content-Type"] = "text/plain"
4141

42-
response = requests.post(
43-
upload_url,
44-
headers=headers,
45-
data=checksum_file_content,
46-
timeout=TIMEOUT,
47-
)
48-
response.raise_for_status()
49-
logger.info(f"checksum.txt uploaded successfully to {GITHUB_REPO}.")
42+
try:
43+
response = requests.post(
44+
upload_url,
45+
headers=headers,
46+
data=checksum_file_content,
47+
timeout=TIMEOUT,
48+
)
49+
response.raise_for_status()
50+
logger.info(f"checksum.txt uploaded successfully to {GITHUB_REPO}.")
51+
except requests.HTTPError:
52+
if response.status_code == 422 and "already_exists" in response.text:
53+
logger.warning("checksum.txt already exists in the latest release.")
54+
return None
55+
raise

homebrew_releaser/readme_updater.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,9 +141,9 @@ def _retrieve_old_table(homebrew_tap: str) -> Tuple[str, bool]:
141141
if old_table_found is False:
142142
# If we can't find both start/end tags, reset the table so we don't blow away unassociated README data
143143
old_table = ""
144-
logger.error("Could not find both start and end tags for project table in README.")
144+
logger.warning("Could not find both start and end tags for project table in README.")
145145
else:
146-
logger.error("Could not find a valid README in this project to update.")
146+
logger.warning("Could not find a valid README in this project to update.")
147147

148148
return old_table, old_table_found
149149

0 commit comments

Comments
 (0)