Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: jekyll/github-metadata
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v2.14.0
Choose a base ref
...
head repository: jekyll/github-metadata
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v2.15.0
Choose a head ref
  • 9 commits
  • 8 files changed
  • 3 contributors

Commits on May 5, 2022

  1. Add GitHub Actions badge and remove Travis one (#236)

    Merge pull request 236
    parkr authored May 5, 2022
    Copy the full SHA
    c285fce View commit details
  2. Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    2818fa5 View commit details
  3. yml -> yaml :)

    parkr authored May 5, 2022

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    578bf50 View commit details

Commits on May 18, 2022

  1. Add webrick when using Ruby 3

    parkr committed May 18, 2022

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    90ec807 View commit details
  2. Copy the full SHA
    f714706 View commit details
  3. Remove appveyor Ruby 2.4 test

    parkr committed May 18, 2022
    Copy the full SHA
    c1ec41e View commit details

Commits on May 20, 2022

  1. Inject site.github via :pre_render step rather than :after_init (

    …#238)
    
    Merge pull request 238
    parkr authored May 20, 2022
    Copy the full SHA
    a771d0d View commit details
  2. Copy the full SHA
    e596203 View commit details
  3. Release 💎 v2.15.0

    parkr committed May 20, 2022
    1
    Copy the full SHA
    2c1b559 View commit details
Showing with 44 additions and 20 deletions.
  1. +2 −0 Gemfile
  2. +10 −0 History.markdown
  3. +0 −1 appveyor.yml
  4. +1 −1 docs/README.md
  5. +17 −7 lib/jekyll-github-metadata/site_github_munger.rb
  6. +1 −1 lib/jekyll-github-metadata/version.rb
  7. +1 −1 script/test-site
  8. +12 −9 spec/site_github_munger_spec.rb
2 changes: 2 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -9,3 +9,5 @@ gem "jekyll", "~> #{ENV["JEKYLL_VERSION"]}" if ENV["JEKYLL_VERSION"]
group :test do
gem "webmock", "~> 3.14"
end

gem "webrick" if RUBY_VERSION.to_i >= 3
10 changes: 10 additions & 0 deletions History.markdown
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
## 2.15.0 / 2022-05-20

### Bug Fixes

* Inject `site.github` via `:pre_render` step rather than `:after_init` (#238)

### Documentation

* Add GitHub Actions badge and remove Travis one (#236)

## 2.14.0 / 2022-05-04

### Minor Enhancements
1 change: 0 additions & 1 deletion appveyor.yml
Original file line number Diff line number Diff line change
@@ -21,7 +21,6 @@ environment:
JEKYLL_VERSION: "3.7"
FARADAY_VERSION: "0.17"
- RUBY_FOLDER_VER: "25"
- RUBY_FOLDER_VER: "24"

install:
- SET PATH=C:\Ruby%RUBY_FOLDER_VER%-x64\bin;%PATH%
2 changes: 1 addition & 1 deletion docs/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# GitHub Metadata, a.k.a. `site.github`

[![Linux Build Status](https://img.shields.io/travis/jekyll/github-metadata/master.svg?label=Linux%20build)][travis]
[![Actions CI](https://github.com/jekyll/github-metadata/actions/workflows/ci.yaml/badge.svg)](https://github.com/jekyll/github-metadata/actions/workflows/ci.yaml)
[![Windows Build status](https://img.shields.io/appveyor/ci/jekyll/github-metadata/master.svg?label=Windows%20build)][appveyor]

[travis]: https://travis-ci.org/jekyll/github-metadata
24 changes: 17 additions & 7 deletions lib/jekyll-github-metadata/site_github_munger.rb
Original file line number Diff line number Diff line change
@@ -6,6 +6,10 @@ module GitHubMetadata
class SiteGitHubMunger
extend Forwardable

class << self
attr_accessor :global_munger
end

def_delegators Jekyll::GitHubMetadata, :site, :repository
private :repository

@@ -16,13 +20,14 @@ def initialize(site)
def munge!
Jekyll::GitHubMetadata.log :debug, "Initializing..."

# This is the good stuff.
site.config["github"] = github_namespace

add_title_and_description_fallbacks!
add_url_and_baseurl_fallbacks! if should_add_url_fallbacks?
end

def inject_metadata!(payload)
payload.site["github"] = github_namespace
end

private

def github_namespace
@@ -80,9 +85,14 @@ def should_warn_about_site_name?
site.config["name"] && !site.config["title"]
end
end
end
end

Jekyll::Hooks.register :site, :after_init do |site|
Jekyll::GitHubMetadata::SiteGitHubMunger.new(site).munge!
Jekyll::Hooks.register :site, :after_init do |site|
SiteGitHubMunger.global_munger = SiteGitHubMunger.new(site)
SiteGitHubMunger.global_munger.munge!
end

Jekyll::Hooks.register :site, :pre_render do |_site, payload|
SiteGitHubMunger.global_munger.inject_metadata!(payload)
end
end
end
2 changes: 1 addition & 1 deletion lib/jekyll-github-metadata/version.rb
Original file line number Diff line number Diff line change
@@ -2,6 +2,6 @@

module Jekyll
module GitHubMetadata
VERSION = "2.14.0"
VERSION = "2.15.0"
end
end
2 changes: 1 addition & 1 deletion script/test-site
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
#!/bin/bash
bundle exec jekyll serve -s spec/test-site
bundle exec jekyll serve -s spec/test-site $@
21 changes: 12 additions & 9 deletions spec/site_github_munger_spec.rb
Original file line number Diff line number Diff line change
@@ -10,44 +10,46 @@
let(:site) { Jekyll::Site.new(Jekyll::Configuration.from(user_config)) }
subject { described_class.new(site) }
let!(:stubs) { stub_all_api_requests }
let(:unified_payload) { site.site_payload }

context "generating" do
before(:each) do
ENV["JEKYLL_ENV"] = "production"
subject.munge!
subject.inject_metadata!(unified_payload)
end

context "with site.github as nil" do
it "replaces site.github with the drop" do
expect(site.config["github"]).to be_a(Liquid::Drop)
it "sets site.github to the drop" do
expect(unified_payload.site["github"]).to be_a(Liquid::Drop)
end
end

context "without site.github" do
let(:user_config) { {} }

it "replaces site.github with the drop" do
expect(site.config["github"]).to be_a(Liquid::Drop)
expect(unified_payload.site["github"]).to be_a(Liquid::Drop)
end
end

context "with site.github as a non-hash" do
let(:github_namespace) { "foo" }

it "doesn't munge" do
expect(site.config["github"]).to eql("foo")
expect(unified_payload.site["github"]).to eql("foo")
end
end

context "with site.github as a hash" do
let(:github_namespace) { { "source" => { "branch" => "foo" } } }

it "lets user-specified values override the drop" do
expect(site.config["github"].invoke_drop("source")["branch"]).to eql("foo")
expect(unified_payload.site["github"].invoke_drop("source")["branch"]).to eql("foo")
end

it "still sets other values" do
expect(site.config["github"].invoke_drop("source")["path"]).to eql("/")
expect(unified_payload.site["github"].invoke_drop("source")["path"]).to eql("/")
end
end

@@ -202,8 +204,8 @@
end

it "sets the site.github config" do
subject.munge!
expect(site.config["github"]).to be_instance_of(Jekyll::GitHubMetadata::MetadataDrop)
subject.inject_metadata!(unified_payload)
expect(unified_payload.site["github"]).to be_instance_of(Jekyll::GitHubMetadata::MetadataDrop)
end
end

@@ -223,8 +225,9 @@

it "fails loudly upon call to any drop method" do
subject.munge!
subject.inject_metadata!(unified_payload)
expect do
site.config["github"]["url"]
unified_payload.site["github"]["url"]
end.to raise_error(Jekyll::GitHubMetadata::Client::BadCredentialsError)
end
end