From 689f6eea250ec91b7189e2fe6ceb6c05ab800d09 Mon Sep 17 00:00:00 2001 From: lardieri Date: Sat, 27 Feb 2021 21:57:59 -0800 Subject: [PATCH 01/29] Git-ignore the Jekyll cache. --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 6ab77c7..d18895a 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,4 @@ pkg _site tmp *.gem +.jekyll-cache From de3d0a61e7b6d08775aa7459587002f7c2624e3e Mon Sep 17 00:00:00 2001 From: lardieri Date: Sun, 7 Mar 2021 23:44:44 -0800 Subject: [PATCH 02/29] Resolve jekyll/github-metadata#199 - Git-ignore the Jekyll cache. Jekyll 4.x generates a cache when running the test suite. Prevent accidental commits. --- .gitignore | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/.gitignore b/.gitignore index d18895a..da212db 100644 --- a/.gitignore +++ b/.gitignore @@ -1,8 +1,10 @@ -.bundle +.bundle/ +vendor/ .tags* Gemfile.lock pkg -_site -tmp +_site/ +tmp/ *.gem -.jekyll-cache +.jekyll-cache/ +.jekyll-metadata From d4b5e7117077966ee44d7655961e7e7cbf250f65 Mon Sep 17 00:00:00 2001 From: lardieri Date: Sat, 10 Jul 2021 16:21:05 -0700 Subject: [PATCH 03/29] Restore log level after running tests that modify it. (#202) Merge pull request 202 --- spec/spec_helper.rb | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 8781b9d..f6f6771 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -76,8 +76,14 @@ config.before(:each) do Jekyll::GitHubMetadata.reset! Jekyll::GitHubMetadata.logger = Logger.new(StringIO.new) unless ENV["DEBUG"] + @original_log_level = Jekyll.logger.level + ENV.delete("JEKYLL_ENV") ENV["PAGES_ENV"] = "test" ENV["PAGES_REPO_NWO"] = nil end + + config.after(:each) do + Jekyll.logger.log_level = @original_log_level + end end From 7a9ad789727f976cae540d1cb380c197e5b76b1c Mon Sep 17 00:00:00 2001 From: jekyllbot Date: Sat, 10 Jul 2021 19:21:07 -0400 Subject: [PATCH 04/29] Update history to reflect merge of #202 [ci skip] --- History.markdown | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/History.markdown b/History.markdown index 9c34e16..25c2d46 100644 --- a/History.markdown +++ b/History.markdown @@ -1,3 +1,9 @@ +## HEAD + +### Development Fixes + + * Restore log level after running tests that modify it. (#202) + ## 2.13.0 / 2020-01-15 ### Minor Enhancements From 8652d80dca24809e3e38cf5a53cdf1be81b8a2c0 Mon Sep 17 00:00:00 2001 From: Parker Moore <237985+parkr@users.noreply.github.com> Date: Sun, 11 Jul 2021 22:23:39 -0400 Subject: [PATCH 05/29] Add GitHub Actions CI (#211) Merge pull request 211 --- .github/workflows/ci.yaml | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 .github/workflows/ci.yaml diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml new file mode 100644 index 0000000..7643cbb --- /dev/null +++ b/.github/workflows/ci.yaml @@ -0,0 +1,34 @@ +--- +name: Continuous Integration + +on: + push: + branches: + - master + - /.*-stable/ + pull_request: + branches: + - master + - /.*-stable/ + +jobs: + ci: + if: "!contains(github.event.commits[0].message, '[ci skip]')" + name: 'Ruby ${{ matrix.ruby_version }} ${{ matrix.os }}' + runs-on: '${{ matrix.os }}' + strategy: + fail-fast: false + matrix: + ruby_version: + - 2.7 + - 3.0 + os: + - ubuntu-latest + - windows-latest + steps: + - uses: actions/checkout@v2 + - uses: ruby/setup-ruby@v1 + with: + ruby-version: ${{ matrix.ruby_version }} + bundler-cache: true # runs 'bundle install' and caches installed gems automatically + - run: script/cibuild From dc434d083943d09bd2e0ef253c23b3f42a0502fe Mon Sep 17 00:00:00 2001 From: jekyllbot Date: Sun, 11 Jul 2021 22:23:41 -0400 Subject: [PATCH 06/29] Update history to reflect merge of #211 [ci skip] --- History.markdown | 1 + 1 file changed, 1 insertion(+) diff --git a/History.markdown b/History.markdown index 25c2d46..4d2b37b 100644 --- a/History.markdown +++ b/History.markdown @@ -3,6 +3,7 @@ ### Development Fixes * Restore log level after running tests that modify it. (#202) + * Add GitHub Actions CI (#211) ## 2.13.0 / 2020-01-15 From 0efda2ee73b0096eefd43562c3aa84152053756b Mon Sep 17 00:00:00 2001 From: lardieri Date: Tue, 3 Aug 2021 08:54:44 -0700 Subject: [PATCH 07/29] Use owner name as site title for User and Organization sites. (#197) Merge pull request 197 --- lib/jekyll-github-metadata/metadata_drop.rb | 1 + lib/jekyll-github-metadata/repository.rb | 4 + .../site_github_munger.rb | 8 +- spec/site_github_munger_spec.rb | 58 ++++++++++ spec/spec_helpers/integration_helper.rb | 1 + .../api_get_org_without_displayname.json | 30 +++++ spec/webmock/api_get_user_site.json | 103 ++++++++++++++++++ .../api_get_user_with_displayname.json | 33 ++++++ .../api_get_user_without_displayname.json | 33 ++++++ 9 files changed, 270 insertions(+), 1 deletion(-) create mode 100644 spec/webmock/api_get_org_without_displayname.json create mode 100644 spec/webmock/api_get_user_site.json create mode 100644 spec/webmock/api_get_user_with_displayname.json create mode 100644 spec/webmock/api_get_user_without_displayname.json diff --git a/lib/jekyll-github-metadata/metadata_drop.rb b/lib/jekyll-github-metadata/metadata_drop.rb index e7be085..e1584c7 100644 --- a/lib/jekyll-github-metadata/metadata_drop.rb +++ b/lib/jekyll-github-metadata/metadata_drop.rb @@ -48,6 +48,7 @@ def keys def_delegator :repository, :tagline, :project_tagline def_delegator :repository, :owner_metadata, :owner def_delegator :repository, :owner, :owner_name + def_delegator :repository, :owner_display_name, :owner_display_name def_delegator :repository, :owner_url, :owner_url def_delegator :repository, :owner_gravatar_url, :owner_gravatar_url def_delegator :repository, :repository_url, :repository_url diff --git a/lib/jekyll-github-metadata/repository.rb b/lib/jekyll-github-metadata/repository.rb index 03cfeaf..fff4638 100644 --- a/lib/jekyll-github-metadata/repository.rb +++ b/lib/jekyll-github-metadata/repository.rb @@ -64,6 +64,10 @@ def repo_pages_info_opts end end + def owner_display_name + owner_metadata.name + end + def owner_metadata @owner_metadata ||= Jekyll::GitHubMetadata::Owner.new(owner) end diff --git a/lib/jekyll-github-metadata/site_github_munger.rb b/lib/jekyll-github-metadata/site_github_munger.rb index c24f55d..f6f07a0 100644 --- a/lib/jekyll-github-metadata/site_github_munger.rb +++ b/lib/jekyll-github-metadata/site_github_munger.rb @@ -55,7 +55,13 @@ def add_title_and_description_fallbacks! msg << "Jekyll GitHub Metadata will not set site.title to the repository's name." Jekyll::GitHubMetadata.log :warn, msg else - site.config["title"] ||= Value.new("title", proc { |_c, r| r.name }) + site.config["title"] ||= Value.new("title", proc { |_context, repository| + if repository.project_page? + repository.name + else + repository.owner_display_name || repository.owner + end + }) end site.config["description"] ||= Value.new("description", proc { |_c, r| r.tagline }) end diff --git a/spec/site_github_munger_spec.rb b/spec/site_github_munger_spec.rb index 084e68c..839542d 100644 --- a/spec/site_github_munger_spec.rb +++ b/spec/site_github_munger_spec.rb @@ -132,6 +132,64 @@ end end + context "generating repo for user with displayname" do + before(:each) do + ENV["JEKYLL_ENV"] = "production" + ENV["PAGES_REPO_NWO"] = "jekyllbot/jekyllbot.github.io" + stub_api("/repos/jekyllbot/jekyllbot.github.io", "user_site") + stub_api_404("/orgs/jekyllbot") + stub_api("/users/jekyllbot", "user_with_displayname") + subject.munge! + end + + it "sets title to user's displayname" do + expect(site.config["title"]).to eql("Jekyll Bot") + end + end + + context "generating repo for user without displayname" do + before(:each) do + ENV["JEKYLL_ENV"] = "production" + ENV["PAGES_REPO_NWO"] = "jekyllbot/jekyllbot.github.io" + stub_api("/repos/jekyllbot/jekyllbot.github.io", "user_site") + stub_api_404("/orgs/jekyllbot") + stub_api("/users/jekyllbot", "user_without_displayname") + subject.munge! + end + + it "sets title to user's login" do + expect(site.config["title"]).to eql("jekyllbot") + end + end + + context "generating repo for org with displayname" do + before(:each) do + ENV["JEKYLL_ENV"] = "production" + ENV["PAGES_REPO_NWO"] = "jekyll/jekyll.github.io" + stub_api("/repos/jekyll/jekyll.github.io", "repo") + stub_api("/orgs/jekyll", "org",) + subject.munge! + end + + it "sets title to org's displayname" do + expect(site.config["title"]).to eql("Jekyll") + end + end + + context "generating repo for org without displayname" do + before(:each) do + ENV["JEKYLL_ENV"] = "production" + ENV["PAGES_REPO_NWO"] = "jekyll/jekyll.github.io" + stub_api("/repos/jekyll/jekyll.github.io", "repo") + stub_api("/orgs/jekyll", "org_without_displayname",) + subject.munge! + end + + it "sets title to org's login" do + expect(site.config["title"]).to eql("jekyll") + end + end + context "with a client with no credentials" do before(:each) do Jekyll::GitHubMetadata.client = Jekyll::GitHubMetadata::Client.new(:access_token => "") diff --git a/spec/spec_helpers/integration_helper.rb b/spec/spec_helpers/integration_helper.rb index 10b0a11..7fd3159 100644 --- a/spec/spec_helpers/integration_helper.rb +++ b/spec/spec_helpers/integration_helper.rb @@ -17,6 +17,7 @@ def expected_values "project_tagline" => ":octocat: `site.github`", "owner" => Regexp.new('"html_url"=>"https://github.com/jekyll",\s+"id"=>3083652'), "owner_name" => "jekyll", + "owner_display_name" => "Jekyll", "owner_url" => "https://github.com/jekyll", "owner_gravatar_url" => "https://github.com/jekyll.png", "repository_url" => "https://github.com/jekyll/github-metadata", diff --git a/spec/webmock/api_get_org_without_displayname.json b/spec/webmock/api_get_org_without_displayname.json new file mode 100644 index 0000000..f6879c5 --- /dev/null +++ b/spec/webmock/api_get_org_without_displayname.json @@ -0,0 +1,30 @@ +{ + "login": "jekyll", + "id": 3083652, + "node_id": "MDEyOk9yZ2FuaXphdGlvbjMwODM2NTI=", + "url": "https://api.github.com/orgs/jekyll", + "repos_url": "https://api.github.com/orgs/jekyll/repos", + "events_url": "https://api.github.com/orgs/jekyll/events", + "hooks_url": "https://api.github.com/orgs/jekyll/hooks", + "issues_url": "https://api.github.com/orgs/jekyll/issues", + "members_url": "https://api.github.com/orgs/jekyll/members{/member}", + "public_members_url": "https://api.github.com/orgs/jekyll/public_members{/member}", + "avatar_url": "https://avatars0.githubusercontent.com/u/3083652?v=4", + "description": "Jekyll is a blog-aware, static site generator in Ruby.", + "name": null, + "company": null, + "blog": "https://jekyllrb.com", + "location": null, + "email": "", + "is_verified": true, + "has_organization_projects": true, + "has_repository_projects": true, + "public_repos": 50, + "public_gists": 0, + "followers": 0, + "following": 0, + "html_url": "https://github.com/jekyll", + "created_at": "2012-12-19T19:37:35Z", + "updated_at": "2019-01-27T15:27:32Z", + "type": "Organization" +} diff --git a/spec/webmock/api_get_user_site.json b/spec/webmock/api_get_user_site.json new file mode 100644 index 0000000..889f409 --- /dev/null +++ b/spec/webmock/api_get_user_site.json @@ -0,0 +1,103 @@ +{ + "id": 50212532, + "node_id": "MDEwOlJlcG9zaXRvcnk1MDIxMjUzMg==", + "name": "github-pages-site", + "full_name": "jekyllbot/github-pages-site", + "private": false, + "owner": { + "login": "jekyllbot", + "id": 6166343, + "node_id": "MDQ6VXNlcjYxNjYzNDM=", + "avatar_url": "https://avatars.githubusercontent.com/u/6166343?v=4", + "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 + }, + "html_url": "https://github.com/jekyllbot/github-pages-site", + "description": "Example GitHub Pages Site", + "fork": false, + "url": "https://api.github.com/repos/jekyllbot/github-pages-site", + "forks_url": "https://api.github.com/repos/jekyllbot/github-pages-site/forks", + "keys_url": "https://api.github.com/repos/jekyllbot/github-pages-site/keys{/key_id}", + "collaborators_url": "https://api.github.com/repos/jekyllbot/github-pages-site/collaborators{/collaborator}", + "teams_url": "https://api.github.com/repos/jekyllbot/github-pages-site/teams", + "hooks_url": "https://api.github.com/repos/jekyllbot/github-pages-site/hooks", + "issue_events_url": "https://api.github.com/repos/jekyllbot/github-pages-site/issues/events{/number}", + "events_url": "https://api.github.com/repos/jekyllbot/github-pages-site/events", + "assignees_url": "https://api.github.com/repos/jekyllbot/github-pages-site/assignees{/user}", + "branches_url": "https://api.github.com/repos/jekyllbot/github-pages-site/branches{/branch}", + "tags_url": "https://api.github.com/repos/jekyllbot/github-pages-site/tags", + "blobs_url": "https://api.github.com/repos/jekyllbot/github-pages-site/git/blobs{/sha}", + "git_tags_url": "https://api.github.com/repos/jekyllbot/github-pages-site/git/tags{/sha}", + "git_refs_url": "https://api.github.com/repos/jekyllbot/github-pages-site/git/refs{/sha}", + "trees_url": "https://api.github.com/repos/jekyllbot/github-pages-site/git/trees{/sha}", + "statuses_url": "https://api.github.com/repos/jekyllbot/github-pages-site/statuses/{sha}", + "languages_url": "https://api.github.com/repos/jekyllbot/github-pages-site/languages", + "stargazers_url": "https://api.github.com/repos/jekyllbot/github-pages-site/stargazers", + "contributors_url": "https://api.github.com/repos/jekyllbot/github-pages-site/contributors", + "subscribers_url": "https://api.github.com/repos/jekyllbot/github-pages-site/subscribers", + "subscription_url": "https://api.github.com/repos/jekyllbot/github-pages-site/subscription", + "commits_url": "https://api.github.com/repos/jekyllbot/github-pages-site/commits{/sha}", + "git_commits_url": "https://api.github.com/repos/jekyllbot/github-pages-site/git/commits{/sha}", + "comments_url": "https://api.github.com/repos/jekyllbot/github-pages-site/comments{/number}", + "issue_comment_url": "https://api.github.com/repos/jekyllbot/github-pages-site/issues/comments{/number}", + "contents_url": "https://api.github.com/repos/jekyllbot/github-pages-site/contents/{+path}", + "compare_url": "https://api.github.com/repos/jekyllbot/github-pages-site/compare/{base}...{head}", + "merges_url": "https://api.github.com/repos/jekyllbot/github-pages-site/merges", + "archive_url": "https://api.github.com/repos/jekyllbot/github-pages-site/{archive_format}{/ref}", + "downloads_url": "https://api.github.com/repos/jekyllbot/github-pages-site/downloads", + "issues_url": "https://api.github.com/repos/jekyllbot/github-pages-site/issues{/number}", + "pulls_url": "https://api.github.com/repos/jekyllbot/github-pages-site/pulls{/number}", + "milestones_url": "https://api.github.com/repos/jekyllbot/github-pages-site/milestones{/number}", + "notifications_url": "https://api.github.com/repos/jekyllbot/github-pages-site/notifications{?since,all,participating}", + "labels_url": "https://api.github.com/repos/jekyllbot/github-pages-site/labels{/name}", + "releases_url": "https://api.github.com/repos/jekyllbot/github-pages-site/releases{/id}", + "deployments_url": "https://api.github.com/repos/jekyllbot/github-pages-site/deployments", + "created_at": "2016-01-22T22:53:40Z", + "updated_at": "2017-07-13T20:03:10Z", + "pushed_at": "2016-11-20T00:18:58Z", + "git_url": "git://github.com/jekyllbot/github-pages-site.git", + "ssh_url": "git@github.com:jekyllbot/github-pages-site.git", + "clone_url": "https://github.com/jekyllbot/github-pages-site.git", + "svn_url": "https://github.com/jekyllbot/github-pages-site", + "homepage": "https://jekyllbot.github.io/github-pages-site/", + "size": 16, + "stargazers_count": 6, + "watchers_count": 6, + "language": "JavaScript", + "has_issues": true, + "has_projects": true, + "has_downloads": true, + "has_wiki": false, + "has_pages": true, + "forks_count": 6, + "mirror_url": null, + "archived": false, + "disabled": false, + "open_issues_count": 0, + "license": { + "key": "mit", + "name": "MIT License", + "spdx_id": "MIT", + "url": "https://api.github.com/licenses/mit", + "node_id": "MDc6TGljZW5zZTEz" + }, + "forks": 6, + "open_issues": 0, + "watchers": 6, + "default_branch": "gh-pages", + "temp_clone_token": null, + "network_count": 6, + "subscribers_count": 1 +} diff --git a/spec/webmock/api_get_user_with_displayname.json b/spec/webmock/api_get_user_with_displayname.json new file mode 100644 index 0000000..e813609 --- /dev/null +++ b/spec/webmock/api_get_user_with_displayname.json @@ -0,0 +1,33 @@ +{ + "login": "jekyllbot", + "id": 6166343, + "node_id": "MDQ6VXNlcjYxNjYzNDM=", + "avatar_url": "https://avatars0.githubusercontent.com/u/6166343?v=4", + "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, + "name": "Jekyll Bot", + "company": null, + "blog": "https://github.com/parkr/auto-reply", + "location": null, + "email": null, + "hireable": null, + "bio": "I help make working with @jekyll fun and easy.", + "public_repos": 2, + "public_gists": 0, + "followers": 68, + "following": 0, + "created_at": "2013-12-12T02:49:00Z", + "updated_at": "2017-12-05T21:23:41Z" +} diff --git a/spec/webmock/api_get_user_without_displayname.json b/spec/webmock/api_get_user_without_displayname.json new file mode 100644 index 0000000..e7439de --- /dev/null +++ b/spec/webmock/api_get_user_without_displayname.json @@ -0,0 +1,33 @@ +{ + "login": "jekyllbot", + "id": 6166343, + "node_id": "MDQ6VXNlcjYxNjYzNDM=", + "avatar_url": "https://avatars0.githubusercontent.com/u/6166343?v=4", + "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, + "name": null, + "company": null, + "blog": "https://github.com/parkr/auto-reply", + "location": null, + "email": null, + "hireable": null, + "bio": "I help make working with @jekyll fun and easy.", + "public_repos": 2, + "public_gists": 0, + "followers": 68, + "following": 0, + "created_at": "2013-12-12T02:49:00Z", + "updated_at": "2017-12-05T21:23:41Z" +} From 78ad2710adaedab421f1661dff2ab200412594ed Mon Sep 17 00:00:00 2001 From: jekyllbot Date: Tue, 3 Aug 2021 11:54:46 -0400 Subject: [PATCH 08/29] Update history to reflect merge of #197 [ci skip] --- History.markdown | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/History.markdown b/History.markdown index 4d2b37b..c45e8bb 100644 --- a/History.markdown +++ b/History.markdown @@ -5,6 +5,10 @@ * Restore log level after running tests that modify it. (#202) * Add GitHub Actions CI (#211) +### Minor Enhancements + + * Use owner name as site title for User and Organization sites. (#197) + ## 2.13.0 / 2020-01-15 ### Minor Enhancements From 3ce1a22ef8e83c7deb1632d0a87f656c3c84c036 Mon Sep 17 00:00:00 2001 From: Ashwin Maroli Date: Wed, 25 Aug 2021 23:04:43 +0530 Subject: [PATCH 09/29] AppVeyor no longer builds with Ruby 2.3 --- appveyor.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/appveyor.yml b/appveyor.yml index 06ec0e9..db392a1 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -22,7 +22,6 @@ environment: FARADAY_VERSION: "0.17" - RUBY_FOLDER_VER: "25" - RUBY_FOLDER_VER: "24" - - RUBY_FOLDER_VER: "23" install: - SET PATH=C:\Ruby%RUBY_FOLDER_VER%-x64\bin;%PATH% From 21e9a056f73aa69d06debe37b3101d25bae2bb80 Mon Sep 17 00:00:00 2001 From: Ashwin Maroli Date: Wed, 25 Aug 2021 23:18:41 +0530 Subject: [PATCH 10/29] Remove comma after last argument to method calls --- spec/site_github_munger_spec.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spec/site_github_munger_spec.rb b/spec/site_github_munger_spec.rb index 839542d..ad37737 100644 --- a/spec/site_github_munger_spec.rb +++ b/spec/site_github_munger_spec.rb @@ -167,7 +167,7 @@ ENV["JEKYLL_ENV"] = "production" ENV["PAGES_REPO_NWO"] = "jekyll/jekyll.github.io" stub_api("/repos/jekyll/jekyll.github.io", "repo") - stub_api("/orgs/jekyll", "org",) + stub_api("/orgs/jekyll", "org") subject.munge! end @@ -181,7 +181,7 @@ ENV["JEKYLL_ENV"] = "production" ENV["PAGES_REPO_NWO"] = "jekyll/jekyll.github.io" stub_api("/repos/jekyll/jekyll.github.io", "repo") - stub_api("/orgs/jekyll", "org_without_displayname",) + stub_api("/orgs/jekyll", "org_without_displayname") subject.munge! end From 1724d7f57478e6ff0b03703ca082980cdbfba036 Mon Sep 17 00:00:00 2001 From: Michael Currin <18750745+MichaelCurrin@users.noreply.github.com> Date: Thu, 27 Jan 2022 23:35:00 +0200 Subject: [PATCH 11/29] docs: Add dev docs (#212) Merge pull request 212 --- docs/README.md | 11 ++-- docs/development.md | 122 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 129 insertions(+), 4 deletions(-) create mode 100644 docs/development.md diff --git a/docs/README.md b/docs/README.md index c75d3e2..111fc71 100644 --- a/docs/README.md +++ b/docs/README.md @@ -19,22 +19,24 @@ Jekyll plugin to propagate the `site.github` namespace and set default values fo ## Usage -Usage of this gem is pretty straight-forward. Add it to your bundle like this: +Usage of this gem is pretty straight-forward. Add it to your `Gemfile` like this: ```ruby gem "jekyll-github-metadata" ``` -Now add it to your `_config.yml`: +Add it to your `_config.yml`: ```yaml plugins: - "jekyll-github-metadata" ``` -:warning: If you are using Jekyll < 3.5.0 use the `gems` key instead of `plugins`. +:warning: If you are using Jekyll < 3.5.0, use the `gems` key instead of `plugins`. -Then go ahead and run `bundle install`. Once you've done that jekyll-github-metadata will run when you run Jekyll. +Then go ahead and run `bundle install`. + +Now, whenever you build or serve with Jekyll, the `jekyll-github-metadata` plugin will run. ## Further reading @@ -43,3 +45,4 @@ Then go ahead and run `bundle install`. Once you've done that jekyll-github-meta * [Configuration](configuration.md) * [Using `site.github`](site.github.md) * [Edit on GitHub link](edit-on-github-link.md) +* [Development](development.md) diff --git a/docs/development.md b/docs/development.md new file mode 100644 index 0000000..6c00274 --- /dev/null +++ b/docs/development.md @@ -0,0 +1,122 @@ +## Development + +Guide to local development of this plugin + +### Installation + +#### Requirements + +- Ruby +- Bundler + +#### Install system dependencies + +- Install Ruby - see the [Downloads](https://www.ruby-lang.org/en/downloads/) page. +- Install Bundler - see the [Bundler](https://bundler.io/) homepage. + +#### Clone + +Clone the repo, or your fork. + +```bash +$ git clone git@github.com:jekyll/github-metadata.git +$ cd github-metadata +``` + +#### Install project dependencies + +Configure Bundler. + +```bash +$ bundle config set --local path vendor/bundle +``` + +Install gems. + +```bash +$ bundle install +``` + +Or, for a faster install. + +```bash +$ script/bootstrap +``` + +### Usage + +See the [script](/script/) directory. + +#### Format + +Check for code formatting issues - recommended before you commit. + +```bash +$ script/fmt +``` + +Fix formatting issues. + +```bash +$ script/fmt -a +``` + +#### Open interactive console + +```bash +$ script/console +``` + +#### Test + +Run all unit tests. + +```bash +$ script/test +``` + +Run a target unit test file by specifying a path. + +```bash +$ script/test spec/owner_spec.rb +``` + +See some recommended flags below. + +Run tests in the order they are written (not a random order). + +```bash +$ script/test --order defined +``` + +Run tests in the same random order as a previous run. + +```bash +$ script/test --seed 12345 +``` + +Run tests with verbose trace logs. + +```bash +$ script/test --format documentation +``` + +#### Start dev server + +Preview the plugin in Jekyll by running the repo's sample Jekyll site. + +```bash +$ script/test-site +``` + +Then open in the browser at: + +- http://127.0.0.1:4000 + +### Release + +Run tests, formatting and create a release. + +```bash +$ script/release +``` From 7868d0681bbd048897ec8959421d42f9892bf3e5 Mon Sep 17 00:00:00 2001 From: jekyllbot Date: Thu, 27 Jan 2022 16:35:02 -0500 Subject: [PATCH 12/29] Update history to reflect merge of #212 [ci skip] --- History.markdown | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/History.markdown b/History.markdown index c45e8bb..f9c57cf 100644 --- a/History.markdown +++ b/History.markdown @@ -9,6 +9,10 @@ * Use owner name as site title for User and Organization sites. (#197) +### Documentation + + * docs: Add dev docs (#212) + ## 2.13.0 / 2020-01-15 ### Minor Enhancements From f11418695224e335233e0d80a6d68e46c9c6be6e Mon Sep 17 00:00:00 2001 From: Parker Moore <237985+parkr@users.noreply.github.com> Date: Tue, 19 Apr 2022 21:43:31 -0700 Subject: [PATCH 13/29] Create dependabot.yml --- .github/dependabot.yml | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 .github/dependabot.yml diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..8bc3fc9 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,8 @@ +version: 2 +updates: +- package-ecosystem: bundler + directory: "/" + schedule: + interval: daily + time: "11:00" + open-pull-requests-limit: 99 From ff46115ae93cff8c38154f5f3d2b597ee765306f Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 20 Apr 2022 04:45:49 +0000 Subject: [PATCH 14/29] Update rubocop-jekyll requirement from ~> 0.5.0 to ~> 0.12.0 Updates the requirements on [rubocop-jekyll](https://github.com/jekyll/rubocop-jekyll) to permit the latest version. - [Release notes](https://github.com/jekyll/rubocop-jekyll/releases) - [Changelog](https://github.com/jekyll/rubocop-jekyll/blob/master/History.markdown) - [Commits](https://github.com/jekyll/rubocop-jekyll/compare/v0.5.0...v0.12.0) --- updated-dependencies: - dependency-name: rubocop-jekyll dependency-type: direct:development ... Signed-off-by: dependabot[bot] --- jekyll-github-metadata.gemspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jekyll-github-metadata.gemspec b/jekyll-github-metadata.gemspec index babaac3..16a7b14 100644 --- a/jekyll-github-metadata.gemspec +++ b/jekyll-github-metadata.gemspec @@ -24,5 +24,5 @@ Gem::Specification.new do |spec| spec.add_development_dependency "pry" spec.add_development_dependency "rake" spec.add_development_dependency "rspec", "~> 3.8.0" - spec.add_development_dependency "rubocop-jekyll", "~> 0.5.0" + spec.add_development_dependency "rubocop-jekyll", "~> 0.12.0" end From 98f603cf8f2f0860bd356663fa943cf5b0d06e01 Mon Sep 17 00:00:00 2001 From: Parker Moore <237985+parkr@users.noreply.github.com> Date: Tue, 19 Apr 2022 21:59:49 -0700 Subject: [PATCH 15/29] Bump target ruby version to 2.5 --- .rubocop.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.rubocop.yml b/.rubocop.yml index a986d78..38d7b46 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -3,7 +3,7 @@ inherit_gem: rubocop-jekyll: .rubocop.yml AllCops: - TargetRubyVersion: 2.4 + TargetRubyVersion: 2.5 Exclude: - vendor/**/* - script/* From b87c4122e253ef3a4d736a2f13fc5862d0ce3859 Mon Sep 17 00:00:00 2001 From: Parker Moore Date: Tue, 19 Apr 2022 22:49:01 -0700 Subject: [PATCH 16/29] Add rubocop todo file --- .rubocop.yml | 2 + .rubocop_todo.yml | 117 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 119 insertions(+) create mode 100644 .rubocop_todo.yml diff --git a/.rubocop.yml b/.rubocop.yml index 38d7b46..1b97e69 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -1,3 +1,5 @@ +inherit_from: .rubocop_todo.yml + require: rubocop-jekyll inherit_gem: rubocop-jekyll: .rubocop.yml diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml new file mode 100644 index 0000000..564fb55 --- /dev/null +++ b/.rubocop_todo.yml @@ -0,0 +1,117 @@ +# This configuration was generated by +# `rubocop --auto-gen-config` +# on 2022-04-20 05:48:15 UTC using RuboCop version 1.18.4. +# The point is for the user to remove these configuration records +# one by one as the offenses are removed from the code base. +# Note that changes in the inspected code, or installation of new +# versions of RuboCop, may require this file to be generated again. + +# Offense count: 1 +# Configuration parameters: Include. +# Include: **/*.gemspec +Gemspec/RequiredRubyVersion: + Exclude: + - 'jekyll-github-metadata.gemspec' + +# Offense count: 1 +# Cop supports --auto-correct. +# Configuration parameters: AllowAliasSyntax, AllowedMethods. +# AllowedMethods: alias_method, public, protected, private +Layout/EmptyLinesAroundAttributeAccessor: + Exclude: + - 'lib/jekyll-github-metadata/repository_finder.rb' + +# Offense count: 2 +# Configuration parameters: AllowedMethods. +# AllowedMethods: enums +Lint/ConstantDefinitionInBlock: + Exclude: + - 'spec/owner_spec.rb' + +# Offense count: 1 +# Configuration parameters: IgnoreLiteralBranches, IgnoreConstantBranches. +Lint/DuplicateBranch: + Exclude: + - 'lib/jekyll-github-metadata/sanitizer.rb' + +# Offense count: 1 +# Configuration parameters: AllowComments, AllowEmptyLambdas. +Lint/EmptyBlock: + Exclude: + - 'spec/edit_link_tag_spec.rb' + +# Offense count: 1 +# Cop supports --auto-correct. +Lint/RedundantCopDisableDirective: + Exclude: + - 'lib/jekyll-github-metadata/client.rb' + +# Offense count: 1 +# Cop supports --auto-correct. +# Configuration parameters: AllowedMethods. +# AllowedMethods: instance_of?, kind_of?, is_a?, eql?, respond_to?, equal? +Lint/RedundantSafeNavigation: + Exclude: + - 'lib/jekyll-github-metadata/repository_finder.rb' + +# Offense count: 1 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle. +# SupportedStyles: strict, consistent +Lint/SymbolConversion: + Exclude: + - 'spec/github_metadata_spec.rb' + +# Offense count: 1 +# Configuration parameters: IgnoredMethods, CountRepeatedAttributes. +Metrics/AbcSize: + Max: 22 + +# Offense count: 1 +# Configuration parameters: EnforcedStyle, CheckMethodNames, CheckSymbols, AllowedIdentifiers. +# SupportedStyles: snake_case, normalcase, non_integer +# AllowedIdentifiers: capture3, iso8601, rfc1123_date, rfc822, rfc2822, rfc3339 +Naming/VariableNumber: + Exclude: + - 'spec/spec_helpers/web_mock_helper.rb' + +# Offense count: 1 +Performance/ChainArrayAllocation: + Exclude: + - 'lib/jekyll-github-metadata/repository_finder.rb' + +# Offense count: 1 +# Cop supports --auto-correct. +Style/NegatedIfElseCondition: + Exclude: + - 'lib/jekyll-github-metadata/pages.rb' + +# Offense count: 1 +# Configuration parameters: AllowedMethods. +# AllowedMethods: respond_to_missing? +Style/OptionalBooleanParameter: + Exclude: + - 'lib/jekyll-github-metadata/client.rb' + +# Offense count: 3 +# Cop supports --auto-correct. +Style/RedundantBegin: + Exclude: + - 'lib/jekyll-github-metadata/metadata_drop.rb' + - 'lib/jekyll-github-metadata/owner.rb' + - 'lib/jekyll-github-metadata/repository_finder.rb' + +# Offense count: 3 +# Cop supports --auto-correct. +Style/RedundantRegexpEscape: + Exclude: + - 'lib/jekyll-github-metadata/edit-link-tag.rb' + - 'lib/jekyll-github-metadata/repository_finder.rb' + +# Offense count: 2 +# Cop supports --auto-correct. +# Configuration parameters: Mode. +Style/StringConcatenation: + Exclude: + - 'spec/edit_link_tag_spec.rb' + - 'spec/value_spec.rb' From 8f71ab308ed0bbaafb64617aece0b55b11b01a9a Mon Sep 17 00:00:00 2001 From: Parker Moore Date: Tue, 19 Apr 2022 22:54:43 -0700 Subject: [PATCH 17/29] CI: use 'main' branch instead of 'master' --- .github/workflows/ci.yaml | 4 ++-- appveyor.yml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 7643cbb..a3bda75 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -4,11 +4,11 @@ name: Continuous Integration on: push: branches: - - master + - main - /.*-stable/ pull_request: branches: - - master + - main - /.*-stable/ jobs: diff --git a/appveyor.yml b/appveyor.yml index db392a1..fb7ff71 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -2,7 +2,7 @@ version: "{build}" clone_depth: 5 branches: only: - - master + - main build: off From 69c616bad2ca57dcd8ddf341bc49bd3b27727d85 Mon Sep 17 00:00:00 2001 From: Parker Moore Date: Tue, 19 Apr 2022 22:53:01 -0700 Subject: [PATCH 18/29] Upgrade rspec to 3.11.x --- Gemfile | 5 ----- jekyll-github-metadata.gemspec | 2 +- 2 files changed, 1 insertion(+), 6 deletions(-) diff --git a/Gemfile b/Gemfile index 81d7b3c..c5423fb 100644 --- a/Gemfile +++ b/Gemfile @@ -7,10 +7,5 @@ gem "faraday", "~> #{ENV["FARADAY_VERSION"]}" if ENV["FARADAY_VERSION"] gem "jekyll", "~> #{ENV["JEKYLL_VERSION"]}" if ENV["JEKYLL_VERSION"] group :test do - # Temporarily lock rspec dependencies to last known versions with - # which tests passed successfully on CI - gem "rspec-expectations", "3.8.4" - gem "rspec-mocks", "3.8.1" - gem "webmock", "~> 2.0" end diff --git a/jekyll-github-metadata.gemspec b/jekyll-github-metadata.gemspec index 16a7b14..80c3c2f 100644 --- a/jekyll-github-metadata.gemspec +++ b/jekyll-github-metadata.gemspec @@ -23,6 +23,6 @@ Gem::Specification.new do |spec| spec.add_development_dependency "netrc" spec.add_development_dependency "pry" spec.add_development_dependency "rake" - spec.add_development_dependency "rspec", "~> 3.8.0" + spec.add_development_dependency "rspec", "~> 3.11.0" spec.add_development_dependency "rubocop-jekyll", "~> 0.12.0" end From 554f8835747debddfad098157f5ded9523df5366 Mon Sep 17 00:00:00 2001 From: Parker Moore Date: Tue, 19 Apr 2022 23:01:32 -0700 Subject: [PATCH 19/29] Use Ruby 3.0, not Ruby 3 Due to https://github.com/actions/runner/issues/849, we have to use quotes for '3.0' --- .github/workflows/ci.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index a3bda75..f9be423 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -21,7 +21,7 @@ jobs: matrix: ruby_version: - 2.7 - - 3.0 + - '3.0' os: - ubuntu-latest - windows-latest From 106e40fb747fcb4f2cd31e9e0f4ae961ff20edf5 Mon Sep 17 00:00:00 2001 From: Parker Moore Date: Tue, 19 Apr 2022 23:01:56 -0700 Subject: [PATCH 20/29] =?UTF-8?q?Stop=20passing=20procs=20to=20expect=20?= =?UTF-8?q?=E2=80=93=20rspec=20now=20prefers=20blocks?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- spec/client_spec.rb | 8 ++++---- spec/repository_finder_spec.rb | 4 ++-- spec/site_github_munger_spec.rb | 8 ++++---- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/spec/client_spec.rb b/spec/client_spec.rb index 3b6fb36..0d56158 100644 --- a/spec/client_spec.rb +++ b/spec/client_spec.rb @@ -13,9 +13,9 @@ end it "raises an error if an Octokit::Client method is called that's not whitelisted" do - expect(lambda do + expect do subject.combined_status("jekyll/github-metadata", "refs/master") - end).to raise_error(described_class::InvalidMethodError, "combined_status is not whitelisted on # @internet_connected=true>") + end.to raise_error(described_class::InvalidMethodError, "combined_status is not whitelisted on # @internet_connected=true>") end it "can check if it's authenticated" do @@ -34,8 +34,8 @@ :headers => WebMockHelper::RESPONSE_HEADERS, :body => webmock_data("bad_credentials") ) - expect(lambda do + expect do subject.contributors("jekyll/github-metadata") - end).to raise_error(described_class::BadCredentialsError) + end.to raise_error(described_class::BadCredentialsError) end end diff --git a/spec/repository_finder_spec.rb b/spec/repository_finder_spec.rb index c5b982d..c5df3d8 100644 --- a/spec/repository_finder_spec.rb +++ b/spec/repository_finder_spec.rb @@ -17,9 +17,9 @@ context "without a git nwo" do it "raises a NoRepositoryError" do allow(subject).to receive(:git_remote_url).and_return("") - expect(lambda do + expect do subject.send(:nwo) - end).to raise_error(Jekyll::GitHubMetadata::NoRepositoryError) + end.to raise_error(Jekyll::GitHubMetadata::NoRepositoryError) end end diff --git a/spec/site_github_munger_spec.rb b/spec/site_github_munger_spec.rb index ad37737..1a03bd7 100644 --- a/spec/site_github_munger_spec.rb +++ b/spec/site_github_munger_spec.rb @@ -196,9 +196,9 @@ end it "does not fail upon call to #munge" do - expect(lambda do + expect do subject.munge! - end).not_to raise_error + end.not_to raise_error end it "sets the site.github config" do @@ -223,9 +223,9 @@ it "fails loudly upon call to any drop method" do subject.munge! - expect(lambda do + expect do site.config["github"]["url"] - end).to raise_error(Jekyll::GitHubMetadata::Client::BadCredentialsError) + end.to raise_error(Jekyll::GitHubMetadata::Client::BadCredentialsError) end end end From ba07ed733d47e2cd5a6bdc2387bf3f76caf22089 Mon Sep 17 00:00:00 2001 From: Parker Moore <237985+parkr@users.noreply.github.com> Date: Tue, 19 Apr 2022 23:08:13 -0700 Subject: [PATCH 21/29] Update History to reflect recent changes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Forgot to use jekyllbot – oops! --- History.markdown | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/History.markdown b/History.markdown index f9c57cf..c1026f9 100644 --- a/History.markdown +++ b/History.markdown @@ -4,6 +4,11 @@ * Restore log level after running tests that modify it. (#202) * Add GitHub Actions CI (#211) + * Update rubocop-jekyll requirement from ~> 0.5.0 to ~> 0.12.0 (#226) + * Create dependabot.yml (#225) + * Add rubocop todo file (#230) + * Upgrade rspec to 3.11.x (#231) + * CI: use 'main' branch instead of 'master' (#232) ### Minor Enhancements From 91d9bb2919040dc0511237a2535af7a6acb32d61 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 19 Apr 2022 23:12:22 -0700 Subject: [PATCH 22/29] Update webmock requirement from ~> 2.0 to ~> 3.14 (#229) Merge pull request 229 --- Gemfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile b/Gemfile index c5423fb..586518e 100644 --- a/Gemfile +++ b/Gemfile @@ -7,5 +7,5 @@ gem "faraday", "~> #{ENV["FARADAY_VERSION"]}" if ENV["FARADAY_VERSION"] gem "jekyll", "~> #{ENV["JEKYLL_VERSION"]}" if ENV["JEKYLL_VERSION"] group :test do - gem "webmock", "~> 2.0" + gem "webmock", "~> 3.14" end From 314ffbfb78781dc9e98ce2a87d2ce68bf2559bbd Mon Sep 17 00:00:00 2001 From: Tobias Date: Wed, 20 Apr 2022 08:13:34 +0200 Subject: [PATCH 23/29] set PAGES_GITHUB_HOSTNAME to hostname without protocol (#191) Merge pull request 191 --- docs/configuration.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/configuration.md b/docs/configuration.md index 6e21cdb..a89bd20 100644 --- a/docs/configuration.md +++ b/docs/configuration.md @@ -39,7 +39,7 @@ Some `site.github` values can be overridden by environment variables. - `PAGES_ENV` – the `site.github.pages_env` (default: `development`) - `PAGES_API_URL` – the `site.github.api_url` (default: `https://api.github.com`) - `PAGES_HELP_URL` – the `site.github.help_url` (default: `https://help.github.com`) -- `PAGES_GITHUB_HOSTNAME` – the `site.github.hostname` (default: `https://github.com`) +- `PAGES_GITHUB_HOSTNAME` – the `site.github.hostname` (default: `github.com`) - `PAGES_PAGES_HOSTNAME` – the `site.github.pages_hostname` (default: `github.io`) - `NO_NETRC` – set if you don't want the fallback to `~/.netrc` From f3b27ce021158c1206cb1641f6734fe4f09f59f9 Mon Sep 17 00:00:00 2001 From: Parker Moore <237985+parkr@users.noreply.github.com> Date: Tue, 19 Apr 2022 23:15:54 -0700 Subject: [PATCH 24/29] Add site.github.public_repositories[].releases (#224) Merge pull request 224 --- lib/jekyll-github-metadata/repository.rb | 4 +++- spec/integration_spec.rb | 8 ++++++++ spec/spec_helpers/stub_helper.rb | 7 ++++++- 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/lib/jekyll-github-metadata/repository.rb b/lib/jekyll-github-metadata/repository.rb index fff4638..821d8f3 100644 --- a/lib/jekyll-github-metadata/repository.rb +++ b/lib/jekyll-github-metadata/repository.rb @@ -117,7 +117,9 @@ def owner_public_repositories :type => "public", :accept => "application/vnd.github.mercy-preview+json", } - memoize_value :@owner_public_repositories, Value.new("owner_public_repositories", proc { |c| c.list_repos(owner, options) }) + memoize_value :@owner_public_repositories, Value.new("owner_public_repositories", proc do |c| + c.list_repos(owner, options).each { |r| r[:releases] = c.releases(r[:full_name]) } + end) end def organization_public_members diff --git a/spec/integration_spec.rb b/spec/integration_spec.rb index e968c02..49cb6b5 100644 --- a/spec/integration_spec.rb +++ b/spec/integration_spec.rb @@ -34,6 +34,14 @@ end end + it "contains the correct public_repositories.releases" do + expect(subject).to have_key("public_repositories") + expect(subject["public_repositories"].first).to have_key("releases") + expect(subject["public_repositories"].first["releases"].size).to eql(3) + expect(subject["public_repositories"].first["releases"].first["name"]).to eql("v1.1.0") + expect(subject["public_repositories"].first["releases"].first["target_commitish"]).to eql("master") + end + it "calls all the stubs" do stubs.each do |stub| expect(stub).to have_been_requested diff --git a/spec/spec_helpers/stub_helper.rb b/spec/spec_helpers/stub_helper.rb index 5c1f808..04d14f3 100644 --- a/spec/spec_helpers/stub_helper.rb +++ b/spec/spec_helpers/stub_helper.rb @@ -6,7 +6,7 @@ module StubHelper # Returns all stubs created. def stub_all_api_requests reset_env_for_stubs - { + stubs = { "/users/jekyll/repos?per_page=100&type=public" => "owner_repos", "/repos/jekyll/github-metadata" => "repo", "/orgs/jekyll" => "org", @@ -20,6 +20,11 @@ def stub_all_api_requests "/repos/jekyll/jekyll.github.io/pages" => "repo_pages", "/repos/jekyll/github-metadata/releases/latest" => "latest_release", }.map { |path, file| stub_api(path, file) } + + owner_repos = JSON.parse(webmock_data("owner_repos")) + owner_repos.each { |r| stubs << stub_api("/repos/#{r["full_name"]}/releases?per_page=100", "repo_releases") } + + stubs end def reset_env_for_stubs From 421dd6ec9d2fff05e4becd7011e46f387c0f9d28 Mon Sep 17 00:00:00 2001 From: Junghwan Park Date: Thu, 5 May 2022 10:17:45 +0900 Subject: [PATCH 25/29] Add site.github.public_repositories[].contributors (#234) Merge pull request 234 --- lib/jekyll-github-metadata/repository.rb | 6 +++++- lib/jekyll-github-metadata/sanitizer.rb | 6 ++++-- spec/integration_spec.rb | 7 +++++++ spec/spec_helpers/stub_helper.rb | 5 ++++- 4 files changed, 20 insertions(+), 4 deletions(-) diff --git a/lib/jekyll-github-metadata/repository.rb b/lib/jekyll-github-metadata/repository.rb index 821d8f3..c8716f2 100644 --- a/lib/jekyll-github-metadata/repository.rb +++ b/lib/jekyll-github-metadata/repository.rb @@ -118,7 +118,11 @@ 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).each { |r| r[:releases] = c.releases(r[:full_name]) } + c.list_repos(owner, options).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 + end end) end diff --git a/lib/jekyll-github-metadata/sanitizer.rb b/lib/jekyll-github-metadata/sanitizer.rb index edaf554..0a993d3 100644 --- a/lib/jekyll-github-metadata/sanitizer.rb +++ b/lib/jekyll-github-metadata/sanitizer.rb @@ -16,7 +16,7 @@ module Sanitizer # resource - an Object # # Returns the sanitized resource. - # rubocop:disable Metrics/CyclomaticComplexity + # rubocop:disable Metrics/CyclomaticComplexity, Metrics/MethodLength def sanitize(resource) case resource when Array @@ -31,6 +31,8 @@ def sanitize(resource) nil when String resource + when Value + resource.render else if resource.respond_to?(:to_hash) sanitize_resource(resource) @@ -39,7 +41,7 @@ def sanitize(resource) end end end - # rubocop:enable Metrics/CyclomaticComplexity + # rubocop:enable Metrics/CyclomaticComplexity, Metrics/MethodLength # Sanitize the Sawyer Resource or Hash # Note: the object must respond to :to_hash for this to work. diff --git a/spec/integration_spec.rb b/spec/integration_spec.rb index 49cb6b5..c7dd85a 100644 --- a/spec/integration_spec.rb +++ b/spec/integration_spec.rb @@ -42,6 +42,13 @@ expect(subject["public_repositories"].first["releases"].first["target_commitish"]).to eql("master") end + it "contains the correct public_repositories.contributors" do + expect(subject).to have_key("public_repositories") + expect(subject["public_repositories"].first).to have_key("contributors") + expect(subject["public_repositories"].first["contributors"].size).to eql(1) + expect(subject["public_repositories"].first["contributors"].first["login"]).to eql("parkr") + end + it "calls all the stubs" do stubs.each do |stub| expect(stub).to have_been_requested diff --git a/spec/spec_helpers/stub_helper.rb b/spec/spec_helpers/stub_helper.rb index 04d14f3..c61c413 100644 --- a/spec/spec_helpers/stub_helper.rb +++ b/spec/spec_helpers/stub_helper.rb @@ -22,7 +22,10 @@ def stub_all_api_requests }.map { |path, file| stub_api(path, file) } owner_repos = JSON.parse(webmock_data("owner_repos")) - owner_repos.each { |r| stubs << stub_api("/repos/#{r["full_name"]}/releases?per_page=100", "repo_releases") } + owner_repos.each do |r| + stubs << stub_api("/repos/#{r["full_name"]}/releases?per_page=100", "repo_releases") + stubs << stub_api("/repos/#{r["full_name"]}/contributors?per_page=100", "repo_contributors") + end stubs end From 285a60b85f45b81857d290d3623776bea3b04a91 Mon Sep 17 00:00:00 2001 From: "A. Ishikawa" Date: Wed, 4 May 2022 18:19:27 -0700 Subject: [PATCH 26/29] Add JEKYLL_ENV limitation for git remote (#185) Merge pull request 185 --- docs/configuration.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/docs/configuration.md b/docs/configuration.md index a89bd20..83625fe 100644 --- a/docs/configuration.md +++ b/docs/configuration.md @@ -6,7 +6,9 @@ be able to determine the repository NWO (name with owner, e.g. `jekyll/jekyll-gi The easiest way to accomplish this is by setting an "origin" remote with a github.com URL. If you ran `git clone` from GitHub, this is almost 100% the case & no further action is needed. If you run `git remote -v` in your -repository, you should see your repo's URL. +repository, you should see your repo's URL. However, this only works if the +environment variable `JEKYLL_ENV` is either `development` or `test`. +The default value of `JEKYLL_ENV` is `development`. If you don't have a git remote available, you have two other options: From f267619b539f9bed30bac0b5fb5c21042f0ade5c Mon Sep 17 00:00:00 2001 From: Parker Moore Date: Wed, 4 May 2022 20:31:54 -0700 Subject: [PATCH 27/29] Fix indentation rubocop violation --- spec/spec_helpers/stub_helper.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spec/spec_helpers/stub_helper.rb b/spec/spec_helpers/stub_helper.rb index c61c413..c22392b 100644 --- a/spec/spec_helpers/stub_helper.rb +++ b/spec/spec_helpers/stub_helper.rb @@ -23,8 +23,8 @@ def stub_all_api_requests owner_repos = JSON.parse(webmock_data("owner_repos")) owner_repos.each do |r| - stubs << stub_api("/repos/#{r["full_name"]}/releases?per_page=100", "repo_releases") - stubs << stub_api("/repos/#{r["full_name"]}/contributors?per_page=100", "repo_contributors") + stubs << stub_api("/repos/#{r["full_name"]}/releases?per_page=100", "repo_releases") + stubs << stub_api("/repos/#{r["full_name"]}/contributors?per_page=100", "repo_contributors") end stubs From 653ecc068cd41f33e0995a08e9c2edb4c7990c0a Mon Sep 17 00:00:00 2001 From: Parker Moore <237985+parkr@users.noreply.github.com> Date: Wed, 4 May 2022 20:42:46 -0700 Subject: [PATCH 28/29] Add release workflow (#235) Merge pull request 235 --- .github/workflows/release.yml | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..a24a1be --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,33 @@ +name: Release Gem + +on: + push: + branches: + - main + paths: + - "lib/**/version.rb" + +jobs: + release: + if: "github.repository_owner == 'jekyll'" + name: "Release Gem (Ruby ${{ matrix.ruby_version }})" + runs-on: "ubuntu-latest" + strategy: + fail-fast: true + matrix: + ruby_version: + - 2.7 + steps: + - name: Checkout Repository + uses: actions/checkout@v3 + - name: "Set up Ruby ${{ matrix.ruby_version }}" + uses: ruby/setup-ruby@v1 + with: + ruby-version: ${{ matrix.ruby_version }} + bundler-cache: true + - name: Build and Publish Gem + uses: ashmaroli/release-gem@dist + with: + gemspec_name: jekyll-github-metadata + env: + GEM_HOST_API_KEY: ${{ secrets.RUBYGEMS_GEM_PUSH_API_KEY }} From 2d0136883004a1ccd1f0300c97aa5d17b29c0ae3 Mon Sep 17 00:00:00 2001 From: Parker Moore Date: Wed, 4 May 2022 20:52:08 -0700 Subject: [PATCH 29/29] Release :gem: v2.14.0 --- History.markdown | 25 +++++++++++++++---------- lib/jekyll-github-metadata/version.rb | 2 +- 2 files changed, 16 insertions(+), 11 deletions(-) diff --git a/History.markdown b/History.markdown index c1026f9..8fa2c48 100644 --- a/History.markdown +++ b/History.markdown @@ -1,22 +1,27 @@ -## HEAD +## 2.14.0 / 2022-05-04 + +### Minor Enhancements + + * Use owner name as site title for User and Organization sites. (#197) + * Add `site.github.public_repositories[].releases` (#224) + * Add `site.github.public_repositories[].contributors` (#234) + +### Documentation + + * docs: Add dev docs (#212) + * set `PAGES_GITHUB_HOSTNAME` to hostname without protocol (#191) + * Add `JEKYLL_ENV` limitation for git remote (#185) ### Development Fixes * Restore log level after running tests that modify it. (#202) * Add GitHub Actions CI (#211) - * Update rubocop-jekyll requirement from ~> 0.5.0 to ~> 0.12.0 (#226) + * Update rubocop-jekyll requirement from `~> 0.5.0` to `~> 0.12.0` (#226) * Create dependabot.yml (#225) * Add rubocop todo file (#230) * Upgrade rspec to 3.11.x (#231) * CI: use 'main' branch instead of 'master' (#232) - -### Minor Enhancements - - * Use owner name as site title for User and Organization sites. (#197) - -### Documentation - - * docs: Add dev docs (#212) + * Add release workflow (#235) ## 2.13.0 / 2020-01-15 diff --git a/lib/jekyll-github-metadata/version.rb b/lib/jekyll-github-metadata/version.rb index 4955e18..c5d3cce 100644 --- a/lib/jekyll-github-metadata/version.rb +++ b/lib/jekyll-github-metadata/version.rb @@ -2,6 +2,6 @@ module Jekyll module GitHubMetadata - VERSION = "2.13.0" + VERSION = "2.14.0" end end