Skip to content

Commit f975f30

Browse files
authored
Merge pull request #127 from osteele/fix-github-metadata-panic
fix: handle missing git repo gracefully in github-metadata plugin
2 parents 79c6a97 + f251e1d commit f975f30

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

plugins/github_metadata.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import (
1111

1212
"github.com/google/go-github/github"
1313
"github.com/osteele/gojekyll/config"
14+
"github.com/osteele/gojekyll/logger"
1415
"github.com/osteele/liquid"
1516
"golang.org/x/oauth2"
1617
)
@@ -23,18 +24,21 @@ func init() {
2324
type jekyllGithubMetadataPlugin struct{ plugin }
2425

2526
func (p jekyllGithubMetadataPlugin) ModifySiteDrop(s Site, d map[string]interface{}) error {
27+
log := logger.Default()
2628
var (
2729
cfg = s.Config()
2830
isUserPage = false
2931
ref = "master"
3032
)
3133
nwo, err := getCurrentRepo(cfg)
3234
if err != nil {
33-
return err
35+
log.Warn("jekyll-github-metadata: can't determine current repository: %s", err)
36+
return nil
3437
}
3538
repo, err := getGitHubRepo(nwo)
3639
if err != nil {
37-
return err
40+
log.Warn("jekyll-github-metadata: can't fetch repository %q from GitHub: %s", nwo, err)
41+
return nil
3842
}
3943
if *repo.Name == fmt.Sprintf("%s.github.com", strings.ToLower(*repo.Owner.Login)) {
4044
isUserPage = true

0 commit comments

Comments
 (0)