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.15.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.16.0
Choose a head ref
  • 18 commits
  • 20 files changed
  • 5 contributors

Commits on Jan 21, 2023

  1. 1
    Copy the full SHA
    0786c01 View commit details
  2. Bump actions/checkout from 2 to 3

    Bumps [actions/checkout](https://github.com/actions/checkout) from 2 to 3.
    - [Release notes](https://github.com/actions/checkout/releases)
    - [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
    - [Commits](actions/checkout@v2...v3)
    
    ---
    updated-dependencies:
    - dependency-name: actions/checkout
      dependency-type: direct:production
      update-type: version-update:semver-major
    ...
    
    Signed-off-by: dependabot[bot] <support@github.com>
    dependabot[bot] authored Jan 21, 2023
    Copy the full SHA
    4129f7c View commit details
  3. 1
    Copy the full SHA
    29190a2 View commit details
  4. Merge pull request #247 from jekyll/dependabot/github_actions/actions…

    …/checkout-3
    
    Bump actions/checkout from 2 to 3
    parkr authored Jan 21, 2023
    1

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    b3ddb02 View commit details
  5. Update rspec requirement from ~> 3.11.0 to ~> 3.12.0 (#244)

    Merge pull request 244
    dependabot[bot] authored Jan 21, 2023
    1
    Copy the full SHA
    4b20d47 View commit details
  6. 1
    Copy the full SHA
    068c1c8 View commit details
  7. 1
    Copy the full SHA
    1cee786 View commit details
  8. 1
    Copy the full SHA
    44459c0 View commit details

Commits on Feb 17, 2023

  1. Prevent loading all GH data on reset (#245)

    Merge pull request 245
    dunkmann00 authored Feb 17, 2023
    1
    Copy the full SHA
    2c4f37f View commit details
  2. 1
    Copy the full SHA
    388a7fe View commit details

Commits on Mar 1, 2023

  1. 1
    Copy the full SHA
    76924a5 View commit details
  2. Bump Ruby versions in AppVeyor jobs (#253)

    Merge pull request 253
    ashmaroli authored Mar 1, 2023
    1
    Copy the full SHA
    6e82678 View commit details
  3. 1
    Copy the full SHA
    a6e9e59 View commit details

Commits on Mar 2, 2023

  1. Bump rubocop-jekyll to 0.13.0 and fix rubocop issues (#252)

    Merge pull request 252
    dunkmann00 authored Mar 2, 2023
    1
    Copy the full SHA
    e8abde0 View commit details
  2. 1
    Copy the full SHA
    f0635ef View commit details

Commits on Apr 4, 2023

  1. Deprecate unnecessary constant in GitHubMetadata::Client (#239)

    Merge pull request 239
    ashmaroli authored Apr 4, 2023
    1
    Copy the full SHA
    a540088 View commit details
  2. 1
    Copy the full SHA
    f23ee97 View commit details

Commits on Apr 5, 2023

  1. Release 💎 v2.16.0 (#255)

    parkr authored Apr 5, 2023
    1
    Copy the full SHA
    9326093 View commit details
6 changes: 6 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -6,3 +6,9 @@ updates:
interval: daily
time: "11:00"
open-pull-requests-limit: 99
- package-ecosystem: github-actions
directory: "/"
schedule:
interval: daily
time: "11:00"
open-pull-requests-limit: 99
20 changes: 11 additions & 9 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -1,32 +1,34 @@
---
name: Continuous Integration

on:
push:
branches:
- main
- /.*-stable/
pull_request:
branches:
- main
- /.*-stable/

jobs:
ci:
if: "!contains(github.event.commits[0].message, '[ci skip]')"
name: 'Ruby ${{ matrix.ruby_version }} ${{ matrix.os }}'
runs-on: '${{ matrix.os }}'
name: 'Ruby: ${{ matrix.ruby_version }} • Faraday: ~> ${{ matrix.faraday_version }}'
runs-on: ${{ matrix.os }}
env:
FARADAY_VERSION: ${{ matrix.faraday_version }}
strategy:
fail-fast: false
matrix:
ruby_version:
- 2.7
- '2.7'
- '3.0'
- '3.1'
- '3.2'
faraday_version:
- '1.0'
- '2.0'
os:
- ubuntu-latest
- windows-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby_version }}
5 changes: 4 additions & 1 deletion .rubocop.yml
Original file line number Diff line number Diff line change
@@ -10,7 +10,7 @@ AllCops:
- vendor/**/*
- script/*

Metrics/LineLength:
Layout/LineLength:
Enabled: false

Metrics/BlockLength:
@@ -24,6 +24,9 @@ Metrics/MethodLength:
Style/AccessModifierDeclarations:
Enabled: false

Style/FetchEnvVar:
Enabled: false

Style/FrozenStringLiteralComment:
Exclude:
- lib/jekyll-github-metadata/site_github_munger.rb
14 changes: 14 additions & 0 deletions History.markdown
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
## 2.16.0 / 2023-04-05

### Minor Enhancements

* Update octokit requirement from ~&gt; 4.0, != 4.4.0 to &gt;= 4, != 4.4.0, &lt; 7 (#243)
* Prevent loading all GH data on reset (#245)
* Deprecate unnecessary constant in `GitHubMetadata::Client` (#239)

### Development Fixes

* Update rspec requirement from ~&gt; 3.11.0 to ~&gt; 3.12.0 (#244)
* Bump Ruby versions in AppVeyor jobs (#253)
* Bump rubocop-jekyll to 0.13.0 and fix rubocop issues (#252)

## 2.15.0 / 2022-05-20

### Bug Fixes
31 changes: 16 additions & 15 deletions appveyor.yml
Original file line number Diff line number Diff line change
@@ -1,30 +1,31 @@
version: "{build}"
image: Visual Studio 2019
build: off

clone_depth: 5

branches:
only:
- main

build: off

environment:
matrix:
- RUBY_FOLDER_VER: "26"
JEKYLL_VERSION: "4.0"
- RUBY_FOLDER_VER: "27"
JEKYLL_VERSION: "4.3"
FARADAY_VERSION: "1.0"
- RUBY_FOLDER_VER: "27"
JEKYLL_VERSION: "3.9.0"
FARADAY_VERSION: "1.0"
- RUBY_FOLDER_VER: "26"
JEKYLL_VERSION: "4.0"
FARADAY_VERSION: "0.17"
- RUBY_FOLDER_VER: "26"
JEKYLL_VERSION: "3.7"
- RUBY_FOLDER_VER: "30"
JEKYLL_VERSION: "4.3"
FARADAY_VERSION: "1.0"
- RUBY_FOLDER_VER: "26"
JEKYLL_VERSION: "3.7"
FARADAY_VERSION: "0.17"
- RUBY_FOLDER_VER: "25"

install:
- SET PATH=C:\Ruby%RUBY_FOLDER_VER%-x64\bin;%PATH%
- bundle install --retry 5 --jobs=%NUMBER_OF_PROCESSORS% --clean --path vendor\bundle
- bundle config set --local clean 'true'
- bundle config set --local path 'vendor\bundle'
- bundle install --retry 5 --jobs=%NUMBER_OF_PROCESSORS%

test_script:
- ruby --version
@@ -33,5 +34,5 @@ test_script:
- bash ./script/test

cache:
# If one of the files after the right arrow changes, cache will be invalidated
- 'vendor\bundle -> appveyor.yml,Gemfile,jekyll-github-metadata.gemspec'
# Cache will be invalidated if 'appveyor.yml' changes.
- 'vendor\bundle -> appveyor.yml'
6 changes: 3 additions & 3 deletions jekyll-github-metadata.gemspec
Original file line number Diff line number Diff line change
@@ -17,12 +17,12 @@ Gem::Specification.new do |spec|
spec.require_paths = ["lib"]

spec.add_runtime_dependency "jekyll", ">= 3.4", "< 5.0"
spec.add_runtime_dependency "octokit", "~> 4.0", "!= 4.4.0"
spec.add_runtime_dependency "octokit", ">= 4", "!= 4.4.0", "< 7"

spec.add_development_dependency "bundler"
spec.add_development_dependency "netrc"
spec.add_development_dependency "pry"
spec.add_development_dependency "rake"
spec.add_development_dependency "rspec", "~> 3.11.0"
spec.add_development_dependency "rubocop-jekyll", "~> 0.12.0"
spec.add_development_dependency "rspec", "~> 3.12.0"
spec.add_development_dependency "rubocop-jekyll", "~> 0.13.0"
end
18 changes: 12 additions & 6 deletions lib/jekyll-github-metadata/client.rb
Original file line number Diff line number Diff line change
@@ -68,14 +68,20 @@ def method_missing(method_name, *args, &block)
end
end

# NOTE: Faraday's error classes has been promoted to under Faraday module from v1.0.0.
# This patch aims to prevent on locking specific version of Faraday.
# NOTE: Faraday's error classes have been simplified from v1.0.0.
#
# In older versions, both `Faraday::Error::ConnectionFailed` and `Faraday::ConnectionFailed`
# were valid and equivalent to each other.
# From v1.0.0 onwards, `Faraday::Error::ConnectionFailed` no longer exists.
#
# TODO: Remove in v2.0 of this plugin.
FARADAY_FAILED_CONNECTION =
begin
Faraday::Error::ConnectionFailed
rescue NameError
Faraday::ConnectionFailed
end
deprecate_constant :FARADAY_FAILED_CONNECTION

def save_from_errors(default = false)
unless internet_connected?
@@ -86,7 +92,7 @@ def save_from_errors(default = false)
yield @client
rescue Octokit::Unauthorized
raise BadCredentialsError, "The GitHub API credentials you provided aren't valid."
rescue FARADAY_FAILED_CONNECTION, Octokit::TooManyRequests => e
rescue Faraday::ConnectionFailed, Octokit::TooManyRequests => e
GitHubMetadata.log :warn, e.message
default
rescue Octokit::NotFound
@@ -130,11 +136,11 @@ def client_inspect
def pluck_auth_method
if ENV["JEKYLL_GITHUB_TOKEN"] || Octokit.access_token
{ :access_token => ENV["JEKYLL_GITHUB_TOKEN"] || Octokit.access_token }
elsif !ENV["NO_NETRC"] && File.exist?(File.join(ENV["HOME"], ".netrc")) && safe_require("netrc")
elsif !ENV["NO_NETRC"] && File.exist?(File.join(Dir.home, ".netrc")) && safe_require("netrc")
{ :netrc => true }
else
GitHubMetadata.log :warn, "No GitHub API authentication could be found." \
" Some fields may be missing or have incorrect data."
GitHubMetadata.log :warn, "No GitHub API authentication could be found. " \
"Some fields may be missing or have incorrect data."
{}.freeze
end
end
3 changes: 2 additions & 1 deletion lib/jekyll-github-metadata/repository.rb
Original file line number Diff line number Diff line change
@@ -118,7 +118,8 @@ def owner_public_repositories
:accept => "application/vnd.github.mercy-preview+json",
}
memoize_value :@owner_public_repositories, Value.new("owner_public_repositories", proc do |c|
c.list_repos(owner, options).map do |r|
repos = c.list_repos(owner, options) || []
repos.map do |r|
r[:releases] = Value.new("owner_public_repositories_releases", proc { c.releases(r[:full_name]) })
r[:contributors] = Value.new("owner_public_repositories_contributors", proc { c.contributors(r[:full_name]) })
r
6 changes: 3 additions & 3 deletions lib/jekyll-github-metadata/repository_finder.rb
Original file line number Diff line number Diff line change
@@ -27,9 +27,9 @@ def nwo
nwo_from_git_origin_remote || \
proc do
raise NoRepositoryError, "No repo name found. " \
"Specify using PAGES_REPO_NWO environment variables, " \
"'repository' in your configuration, or set up an 'origin' " \
"git remote pointing to your github.com repository."
"Specify using PAGES_REPO_NWO environment variables, " \
"'repository' in your configuration, or set up an 'origin' " \
"git remote pointing to your github.com repository."
end.call
end
end
15 changes: 12 additions & 3 deletions lib/jekyll-github-metadata/site_github_munger.rb
Original file line number Diff line number Diff line change
@@ -15,6 +15,7 @@ class << self

def initialize(site)
Jekyll::GitHubMetadata.site = site
@original_config = site.config["github"]
end

def munge!
@@ -28,16 +29,20 @@ def inject_metadata!(payload)
payload.site["github"] = github_namespace
end

def uninject_metadata!(payload)
payload.site["github"] = @original_config
end

private

def github_namespace
case site.config["github"]
case @original_config
when nil
drop
when Hash
Jekyll::Utils.deep_merge_hashes(drop, site.config["github"])
drop.merge(@original_config)
else
site.config["github"]
@original_config
end
end

@@ -94,5 +99,9 @@ def should_warn_about_site_name?
Jekyll::Hooks.register :site, :pre_render do |_site, payload|
SiteGitHubMunger.global_munger.inject_metadata!(payload)
end

Jekyll::Hooks.register :site, :post_render do |_site, payload|
SiteGitHubMunger.global_munger.uninject_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.15.0"
VERSION = "2.16.0"
end
end
2 changes: 1 addition & 1 deletion spec/edit_link_tag_spec.rb
Original file line number Diff line number Diff line change
@@ -26,7 +26,7 @@

subject do
tag = described_class.parse(tag_name, markup, tokenizer, parse_context)
tag.instance_variable_set("@context", render_context)
tag.instance_variable_set(:@context, render_context)
tag
end

2 changes: 1 addition & 1 deletion spec/metadata_drop_spec.rb
Original file line number Diff line number Diff line change
@@ -86,7 +86,7 @@

context "with fallback data" do
let(:fallback_data) { { "foo" => "bar" } }
before { subject.instance_variable_set("@fallback_data", fallback_data) }
before { subject.instance_variable_set(:@fallback_data, fallback_data) }

it "returns the mutated value via #[]" do
expect(subject["foo"]).to eql("bar")
39 changes: 39 additions & 0 deletions spec/site_github_munger_spec.rb
Original file line number Diff line number Diff line change
@@ -231,4 +231,43 @@
end.to raise_error(Jekyll::GitHubMetadata::Client::BadCredentialsError)
end
end

context "render the 'uninject' fixture test site" do
let(:source) { File.expand_path("test-site-uninject", __dir__) }
let(:dest) { File.expand_path("../tmp/test-site-uninject-build", __dir__) }
let(:config) { Jekyll::Configuration.from({ "source" => source, "destination" => dest }) }
let(:fixture_rendered) { File.expand_path("test-site-uninject-rendered", __dir__) }

it "process site twice (simulate reset), check API calls & rendered site" do
site = Jekyll::Site.new(config)
site.process
# These API calls are expected because we use the attributes in the
# fixture site.
expect_api_call "/repos/jekyll/github-metadata"
expect_api_call "/repos/jekyll/github-metadata/releases/latest"
expect_api_call "/orgs/jekyll"
site.process
# After processing the site again, we expect that these API calls were
# still only made once. We cache the results so we shouldn't be making the
# same API call more than once.
expect_api_call "/repos/jekyll/github-metadata"
expect_api_call "/repos/jekyll/github-metadata/releases/latest"
expect_api_call "/orgs/jekyll"

# We do not expect these API calls to have been made since we do not use
# these attributes in the fixture site.
not_expect_api_call "/repos/jekyll/github-metadata/pages"
not_expect_api_call "/repos/jekyll/github-metadata/contributors?per_page=100"
not_expect_api_call "/orgs/jekyll/public_members?per_page=100"
not_expect_api_call "/users/jekyll/repos?per_page=100&type=public"

# Check to make sure the fixture site is rendered with the correct
# site.github values.
Dir.children(dest).each do |file|
rendered_file = File.join(dest, file)
fixture_file = File.join(fixture_rendered, file)
expect(File.read(rendered_file)).to eql(File.read(fixture_file))
end
end
end
end
5 changes: 5 additions & 0 deletions spec/spec_helpers/web_mock_helper.rb
Original file line number Diff line number Diff line change
@@ -41,6 +41,11 @@ def expect_api_call(path)
.with(:headers => request_headers).once
end

def not_expect_api_call(path)
expect(WebMock).to have_requested(:get, url(path))
.with(:headers => request_headers).times(0)
end

def request_headers
REQUEST_HEADERS.merge(
"Authorization" => "token #{ENV.fetch("JEKYLL_GITHUB_TOKEN", "1234abc")}"
13 changes: 13 additions & 0 deletions spec/test-site-uninject-rendered/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Page Title</title>
</head>
<body>
<h1>github-metadata</h1>
<h2>:octocat: `site.github`</h2>
<h2>Owner: jekyll</h2>
<h3>Latest Release: {"url"=>"https://api.github.com/repos/jekyll/github-metadata/releases/5198319", "assets_url"=>"https://api.github.com/repos/jekyll/github-metadata/releases/5198319/assets", "upload_url"=>"https://uploads.github.com/repos/jekyll/github-metadata/releases/5198319/assets{?name,label}", "html_url"=>"https://github.com/jekyll/github-metadata/releases/tag/v2.3.1", "id"=>5198319, "tag_name"=>"v2.3.1", "target_commitish"=>"master", "name"=>"v2.3.1", "draft"=>false, "author"=>{"login"=>"jekyllbot", "id"=>6166343, "avatar_url"=>"https://avatars.githubusercontent.com/u/6166343?v=3", "gravatar_id"=>"", "url"=>"https://api.github.com/users/jekyllbot", "html_url"=>"https://github.com/jekyllbot", "followers_url"=>"https://api.github.com/users/jekyllbot/followers", "following_url"=>"https://api.github.com/users/jekyllbot/following{/other_user}", "gists_url"=>"https://api.github.com/users/jekyllbot/gists{/gist_id}", "starred_url"=>"https://api.github.com/users/jekyllbot/starred{/owner}{/repo}", "subscriptions_url"=>"https://api.github.com/users/jekyllbot/subscriptions", "organizations_url"=>"https://api.github.com/users/jekyllbot/orgs", "repos_url"=>"https://api.github.com/users/jekyllbot/repos", "events_url"=>"https://api.github.com/users/jekyllbot/events{/privacy}", "received_events_url"=>"https://api.github.com/users/jekyllbot/received_events", "type"=>"User", "site_admin"=>false}, "prerelease"=>false, "created_at"=>2017-01-18 20:10:29 UTC, "published_at"=>2017-01-18 20:10:33 UTC, "assets"=>[], "tarball_url"=>"https://api.github.com/repos/jekyll/github-metadata/tarball/v2.3.1", "zipball_url"=>"https://api.github.com/repos/jekyll/github-metadata/zipball/v2.3.1", "body"=>"- Remove log on Octokit::NotFound (#86)\n"}</h3>
</body>
</html>
1 change: 1 addition & 0 deletions spec/test-site-uninject-rendered/subvalues.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
owner: {"avatar_url"=>"https://avatars0.githubusercontent.com/u/3083652?v=4", "bio"=>nil, "blog"=>"https://jekyllrb.com", "collaborators"=>nil, "company"=>nil, "created_at"=>2012-12-19 19:37:35 UTC, "description"=>"Jekyll is a blog-aware, static site generator in Ruby.", "email"=>"", "followers"=>0, "following"=>0, "has_organization_projects"=>true, "has_repository_projects"=>true, "hireable"=>nil, "html_url"=>"https://github.com/jekyll", "id"=>3083652, "is_verified"=>true, "location"=>nil, "login"=>"jekyll", "name"=>"Jekyll", "node_id"=>"MDEyOk9yZ2FuaXphdGlvbjMwODM2NTI=", "public_gists"=>0, "public_repos"=>50, "type"=>"Organization", "updated_at"=>2019-01-27 15:27:32 UTC}
9 changes: 9 additions & 0 deletions spec/test-site-uninject/_config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
repository: jekyll/github-metadata
github:
in_your_config:
setting_your: keyz
plugins:
- jekyll-github-metadata
# remove this once we drop support for Jekyll v3.4 and below
gems:
- jekyll-github-metadata
16 changes: 16 additions & 0 deletions spec/test-site-uninject/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
---
---

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Page Title</title>
</head>
<body>
<h1>{{ site.github.project_title }}</h1>
<h2>{{ site.github.project_tagline }}</h2>
<h2>Owner: {{ site.github.owner_name }}</h2>
<h3>Latest Release: {{ site.github.latest_release }}</h3>
</body>
</html>
Loading