Skip to content

Commit 25cece4

Browse files
authored
Give friendly error on empty backlog repo (#1294)
Currently you get a complicated error about a nil dereference. This makes it clear what happened.
1 parent 7150b6c commit 25cece4

File tree

3 files changed

+24
-6
lines changed

3 files changed

+24
-6
lines changed

common-theme/layouts/_default/backlog.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
for each repo, grab the issues that match the filter
1515
*/}}
1616
{{ range $repos }}
17-
{{ $issueBlocks := partial "block/issues-list-as-blocks.html" (dict "backlog" . "backlog_filter" $backlog_filter) }}
17+
{{ $issueBlocks := partial "block/issues-list-as-blocks.html" (dict "backlog" . "backlog_filter" $backlog_filter "path" $currentPath) }}
1818
{{ $repo := . }}
1919
{{ range $issueBlocks }}
2020
<div class="c-alert" role="alert" hidden>

common-theme/layouts/_default/success.html

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,26 @@ <h2 class="e-heading__4 c-objectives__title is-invisible">
2828
{{ $prep := .Site.GetPage (printf "%sprep/index.md"
2929
.CurrentSection.RelPermalink)
3030
}}
31-
{{ $backlog := .Site.GetPage (printf "%sbacklog/index.md"
31+
{{ $backlogPage := .Site.GetPage (printf "%sbacklog/index.md"
3232
.CurrentSection.RelPermalink)
3333
}}
3434
{{ $dayplan := .Site.GetPage (printf "%sday-plan/index.md"
3535
.CurrentSection.RelPermalink)
3636
}}
37-
{{ $issueBlocks := partial "block/issues-list-as-blocks.html" (dict "backlog" $backlog.Params.backlog "backlog_filter" $backlog.Params.backlog_filter) }}
37+
{{ $issueBlocks := slice }}
38+
{{ if $backlogPage }}
39+
{{ $backlogs := $backlogPage.Params.backlog }}
40+
{{ if $backlogs }}
41+
{{ if reflect.IsSlice $backlogs }}
42+
{{ range $backlogs }}
43+
{{ $issueBlocks = append (partial "block/issues-list-as-blocks.html" (dict "backlog" . "backlog_filter" $backlogPage.Params.backlog_filter "path" $pageContext.Path)) $issueBlocks }}
44+
{{ end }}
45+
{{ else }}
46+
{{ $backlog := $backlogs }}
47+
{{ $issueBlocks = append (partial "block/issues-list-as-blocks.html" (dict "backlog" $backlog "backlog_filter" $backlogPage.Params.backlog_filter "path" $pageContext.Path)) $issueBlocks }}
48+
{{ end }}
49+
{{ end }}
50+
{{ end }}
3851
{{ $blocks := slice }}
3952
{{/* append non-nil blocks */}}
4053
{{ range $prep.Params.blocks }}

common-theme/layouts/partials/block/issues-list-as-blocks.html

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
"owner" site.Params.owner
1212
"repo" .backlog
1313
}}
14+
{{ $currentPath := .path }}
1415
{{ if .backlog_filter }}
1516
{{ $variables = merge $variables (dict "labels" .backlog_filter) }}
1617
{{ end }}
@@ -53,9 +54,13 @@
5354
{{ $issueBlocks := slice }}
5455
{{ with resources.GetRemote "https://api.github.com/graphql" (merge $request (partial "github-auth.html" .)) }}
5556
{{ with .Content | unmarshal }}
56-
{{ with .data.repository.issues.nodes }}
57-
{{ range sort . "title" "asc" }}
58-
{{ $issueBlocks = $issueBlocks | append (dict "name" .title "src" .url "number" .number "labels" .labels) }}
57+
{{ if not .data.repository }}
58+
{{ errorf "GitHub repository %s/%s referenced on %s had no issues" site.Params.owner (index $variables "repo") $currentPath }}
59+
{{ else }}
60+
{{ with .data.repository.issues.nodes }}
61+
{{ range sort . "title" "asc" }}
62+
{{ $issueBlocks = $issueBlocks | append (dict "name" .title "src" .url "number" .number "labels" .labels) }}
63+
{{ end }}
5964
{{ end }}
6065
{{ end }}
6166
{{ end }}

0 commit comments

Comments
 (0)