Skip to content

Commit

Permalink
Give friendly error on empty backlog repo (#1294)
Browse files Browse the repository at this point in the history
Currently you get a complicated error about a nil dereference. This
makes it clear what happened.
  • Loading branch information
illicitonion authored Jan 13, 2025
1 parent 7150b6c commit 25cece4
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 6 deletions.
2 changes: 1 addition & 1 deletion common-theme/layouts/_default/backlog.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
for each repo, grab the issues that match the filter
*/}}
{{ range $repos }}
{{ $issueBlocks := partial "block/issues-list-as-blocks.html" (dict "backlog" . "backlog_filter" $backlog_filter) }}
{{ $issueBlocks := partial "block/issues-list-as-blocks.html" (dict "backlog" . "backlog_filter" $backlog_filter "path" $currentPath) }}
{{ $repo := . }}
{{ range $issueBlocks }}
<div class="c-alert" role="alert" hidden>
Expand Down
17 changes: 15 additions & 2 deletions common-theme/layouts/_default/success.html
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,26 @@ <h2 class="e-heading__4 c-objectives__title is-invisible">
{{ $prep := .Site.GetPage (printf "%sprep/index.md"
.CurrentSection.RelPermalink)
}}
{{ $backlog := .Site.GetPage (printf "%sbacklog/index.md"
{{ $backlogPage := .Site.GetPage (printf "%sbacklog/index.md"
.CurrentSection.RelPermalink)
}}
{{ $dayplan := .Site.GetPage (printf "%sday-plan/index.md"
.CurrentSection.RelPermalink)
}}
{{ $issueBlocks := partial "block/issues-list-as-blocks.html" (dict "backlog" $backlog.Params.backlog "backlog_filter" $backlog.Params.backlog_filter) }}
{{ $issueBlocks := slice }}
{{ if $backlogPage }}
{{ $backlogs := $backlogPage.Params.backlog }}
{{ if $backlogs }}
{{ if reflect.IsSlice $backlogs }}
{{ range $backlogs }}
{{ $issueBlocks = append (partial "block/issues-list-as-blocks.html" (dict "backlog" . "backlog_filter" $backlogPage.Params.backlog_filter "path" $pageContext.Path)) $issueBlocks }}
{{ end }}
{{ else }}
{{ $backlog := $backlogs }}
{{ $issueBlocks = append (partial "block/issues-list-as-blocks.html" (dict "backlog" $backlog "backlog_filter" $backlogPage.Params.backlog_filter "path" $pageContext.Path)) $issueBlocks }}
{{ end }}
{{ end }}
{{ end }}
{{ $blocks := slice }}
{{/* append non-nil blocks */}}
{{ range $prep.Params.blocks }}
Expand Down
11 changes: 8 additions & 3 deletions common-theme/layouts/partials/block/issues-list-as-blocks.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"owner" site.Params.owner
"repo" .backlog
}}
{{ $currentPath := .path }}
{{ if .backlog_filter }}
{{ $variables = merge $variables (dict "labels" .backlog_filter) }}
{{ end }}
Expand Down Expand Up @@ -53,9 +54,13 @@
{{ $issueBlocks := slice }}
{{ with resources.GetRemote "https://api.github.com/graphql" (merge $request (partial "github-auth.html" .)) }}
{{ with .Content | unmarshal }}
{{ with .data.repository.issues.nodes }}
{{ range sort . "title" "asc" }}
{{ $issueBlocks = $issueBlocks | append (dict "name" .title "src" .url "number" .number "labels" .labels) }}
{{ if not .data.repository }}
{{ errorf "GitHub repository %s/%s referenced on %s had no issues" site.Params.owner (index $variables "repo") $currentPath }}
{{ else }}
{{ with .data.repository.issues.nodes }}
{{ range sort . "title" "asc" }}
{{ $issueBlocks = $issueBlocks | append (dict "name" .title "src" .url "number" .number "labels" .labels) }}
{{ end }}
{{ end }}
{{ end }}
{{ end }}
Expand Down

0 comments on commit 25cece4

Please sign in to comment.