Skip to content

Commit ebad750

Browse files
Merge pull request #1729 from ehuss/fix-github_releases-octocrab
Fix github_releases with invalid URIs
2 parents f7a3336 + c2e5cfb commit ebad750

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

src/handlers/github_releases.rs

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ pub(super) async fn handle(
4040
log::debug!("loading the git tags");
4141
let tags = load_paginated(
4242
ctx,
43-
&format!("repos/{}/git/matching-refs/tags", event.repo().full_name),
43+
&format!("/repos/{}/git/matching-refs/tags", event.repo().full_name),
4444
|git_ref: &GitRef| {
4545
git_ref
4646
.name
@@ -54,7 +54,7 @@ pub(super) async fn handle(
5454
log::debug!("loading the existing releases");
5555
let releases = load_paginated(
5656
ctx,
57-
&format!("repos/{}/releases", event.repo().full_name),
57+
&format!("/repos/{}/releases", event.repo().full_name),
5858
|release: &Release| release.tag_name.clone(),
5959
)
6060
.await?;
@@ -85,7 +85,7 @@ pub(super) async fn handle(
8585
let e: octocrab::Result<serde_json::Value> = ctx
8686
.octocrab
8787
.post(
88-
format!("repos/{}/releases", event.repo().full_name),
88+
format!("/repos/{}/releases", event.repo().full_name),
8989
Some(&serde_json::json!({
9090
"tag_name": tag,
9191
"name": expected_name,
@@ -141,15 +141,24 @@ where
141141
R: Eq + PartialEq + std::hash::Hash,
142142
F: Fn(&T) -> R,
143143
{
144-
let mut current_page: Page<T> = ctx.octocrab.get::<Page<T>, _, ()>(url, None).await?;
144+
let mut current_page: Page<T> = ctx
145+
.octocrab
146+
.get::<Page<T>, _, ()>(url, None)
147+
.await
148+
.with_context(|| format!("failed to load {url}"))?;
145149

146150
let mut items = current_page
147151
.take_items()
148152
.into_iter()
149153
.map(|val| (key(&val), val))
150154
.collect::<HashMap<R, T>>();
151155

152-
while let Some(mut new_page) = ctx.octocrab.get_page::<T>(&current_page.next).await? {
156+
while let Some(mut new_page) = ctx
157+
.octocrab
158+
.get_page::<T>(&current_page.next)
159+
.await
160+
.with_context(|| format!("failed to load next page {:?}", current_page.next))?
161+
{
153162
items.extend(
154163
new_page
155164
.take_items()

0 commit comments

Comments
 (0)