Skip to content

Commit

Permalink
Merge branch 'main' into dependabot/bundler/rubocop-1.42.0
Browse files Browse the repository at this point in the history
  • Loading branch information
oleander authored Dec 6, 2024
2 parents 8c60dd5 + 51e77d0 commit 4307d61
Show file tree
Hide file tree
Showing 13 changed files with 85 additions and 39 deletions.
2 changes: 1 addition & 1 deletion .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ RUN apt-get update && \
rm -rf /var/lib/apt/lists/*

RUN git config --global --add safe.directory *
RUN gem install solargraph bundler:2.3.3
RUN gem install solargraph bundler:2.5.22 gem-release

COPY Gemfile Gemfile.lock git_fame.gemspec ./
COPY lib/git_fame/version.rb ./lib/git_fame/version.rb
Expand Down
69 changes: 54 additions & 15 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

permissions:
contents: write
pull-requests: write

jobs:
rubocop:
runs-on: ubuntu-latest
Expand All @@ -17,17 +21,16 @@ jobs:
uses: ruby/setup-ruby@v1
with:
bundler-cache: true
ruby-version: 2.7.5
ruby-version: 3.3.0

- name: Run Rubocop
run: bundle exec rubocop

rspec:
runs-on: ${{ matrix.os }}
needs: [rubocop]
strategy:
matrix:
ruby: ["2.7.5", "3.0.3", "3.1.0", "3.2.0", "3.3.0"]
ruby: ["3.1", "3.2", "3.3"]
os: [ubuntu-latest, macos-latest]
steps:
- name: Check out repository
Expand All @@ -41,9 +44,6 @@ jobs:
bundler-cache: true
ruby-version: ${{ matrix.ruby }}

- name: Run RSpec
run: bundle exec rspec --format RSpec::Github::Formatter --format progress --color --tty

- name: Install gem locally
run: bundle exec rake install:local

Expand All @@ -58,7 +58,11 @@ jobs:
CI: true
with:
coverageLocations: ${{ github.workspace }}/coverage/coverage.xml:cobertura
coverageCommand: bundle exec rspec
coverageCommand: bundle exec rspec --format RSpec::Github::Formatter

- name: Run RSpec
if: runner.os == 'macos'
run: bundle exec rspec --format RSpec::Github::Formatter

devcontainer:
runs-on: ubuntu-latest
Expand All @@ -76,14 +80,8 @@ jobs:
- name: Set up DevContainer CLI
run: npm install -g @devcontainers/cli

- name: Build and start DevContainer
run: |
devcontainer build --workspace-folder .
devcontainer up --workspace-folder .
- name: Run tests inside DevContainer
run: devcontainer exec --workspace-folder . bundle exec rspec

- name: Build DevContainer
run: devcontainer build --workspace-folder .
dockerfile:
runs-on: ubuntu-latest
steps:
Expand All @@ -97,3 +95,44 @@ jobs:

- name: Run tests in Docker container
run: docker run --rm -v $(pwd):/workspace git-fame bundle exec rspec

release:
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/main'
needs: [rspec, rubocop, devcontainer, dockerfile]
steps:
- name: Check out repository
uses: actions/checkout@v4

- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
bundler-cache: true
ruby-version: 3.3.0

- name: Setup git
run: |
git config --global user.email "[email protected]"
git config --global user.name "GitHub Actions"
- name: Install gem-release
run: gem install gem-release

- name: Install dependencies
run: bundle install

- name: Increment version
run: gem bump --version patch --tag --skip-ci --release --file lib/git_fame/version.rb
env:
GEM_HOST_API_KEY: ${{ secrets.GEM_HOST_API_KEY }}

- name: Install dependencies
run: bundle install
env:
BUNDLE_FROZEN: "false"

- name: Add and commit version bump
run: git commit -a --amend --no-edit

- name: Push changes
run: git push --tags
2 changes: 1 addition & 1 deletion .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ require:
- rubocop-md

AllCops:
TargetRubyVersion: 2.7
TargetRubyVersion: 3.1
NewCops: enable
Exclude: ['vendor/**/*']

Expand Down
2 changes: 2 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,5 @@ group :test do
gem "simplecov"
gem "simplecov-cobertura"
end

gem "racc", "~> 1.8"
8 changes: 6 additions & 2 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PATH
remote: .
specs:
git_fame (3.1.1)
git_fame (3.2.14)
activesupport (~> 7.0)
dry-initializer (~> 3.0)
dry-struct (~> 1.0)
Expand Down Expand Up @@ -70,6 +70,7 @@ GEM
pry (0.14.2)
coderay (~> 1.1)
method_source (~> 1.0)
racc (1.8.1)
rainbow (3.1.1)
rake (13.0.6)
regexp_parser (2.7.0)
Expand Down Expand Up @@ -154,6 +155,8 @@ GEM
PLATFORMS
aarch64-linux
arm64-darwin-22
arm64-darwin-23
arm64-darwin-24
x86_64-darwin-19
x86_64-darwin-20
x86_64-darwin-21
Expand All @@ -165,6 +168,7 @@ DEPENDENCIES
faker
git_fame!
pry
racc (~> 1.8)
rake
rspec
rspec-github
Expand All @@ -178,4 +182,4 @@ DEPENDENCIES
simplecov-cobertura

BUNDLED WITH
2.3.3
2.5.22
2 changes: 1 addition & 1 deletion git_fame.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ Gem::Specification.new do |gem|
SUMMARY

gem.homepage = "https://github.com/oleander/git-fame-rb"
gem.required_ruby_version = ">= 2.7.0"
gem.required_ruby_version = ">= 3.1"
gem.files = Dir["lib/**/*", "exe/*"]
gem.executables << "git-fame"
gem.bindir = "exe"
Expand Down
1 change: 1 addition & 0 deletions lib/git_fame.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
require "active_support/core_ext/module/delegation"
require "active_support/isolated_execution_state"
require "active_support/core_ext/numeric/time"
require "active_support/core_ext/object/blank"
require "dry/core/memoizable"
require "dry/initializer"
require "dry/struct"
Expand Down
4 changes: 2 additions & 2 deletions lib/git_fame/collector.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class Collector

# @return [Collector]
def call
Result.new(contributions: contributions)
Result.new(contributions:)
end

private
Expand All @@ -36,7 +36,7 @@ def contributions
files: files[email],
author: {
name: names[email],
email: email
email:
}
})
end
Expand Down
6 changes: 3 additions & 3 deletions lib/git_fame/command.rb
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ def run
end

thread = spinner.run do
Render.new(result: result, **options(:branch))
Render.new(result:, **options(:branch))
end

thread.value.call
Expand All @@ -150,11 +150,11 @@ def repo
end

def collector
Collector.new(filter: filter, diff: diff, **options)
Collector.new(filter:, diff:, **options)
end

def diff
Diff.new(commit: commit, **options)
Diff.new(commit:, **options)
end

def options(*args)
Expand Down
4 changes: 2 additions & 2 deletions lib/git_fame/diff.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ class Diff < Base
# @yield [Hash]
#
# @return [void]
def each(&block)
def each(&)
tree.walk(:preorder).each do |root, entry|
case entry
in { type: :blob, name: file, oid: }
Rugged::Blame.new(repo, root + file, newest_commit: commit).each(&block)
Rugged::Blame.new(repo, root + file, newest_commit: commit).each(&)
in { type: type, name: file }
say("Ignore type [%s] in for %s", type, root + file)
end
Expand Down
2 changes: 1 addition & 1 deletion lib/git_fame/render.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def call
table << [c.name, c.email, c.lines.f, c.commits.count.f, c.files.count.f, c.dist(self)]
end

print table.render(:unicode, width: width, resize: true, alignment: [:center])
print table.render(:unicode, width:, resize: true, alignment: [:center])
end

private
Expand Down
2 changes: 1 addition & 1 deletion lib/git_fame/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# frozen_string_literal: true

module GitFame
VERSION = "3.1.1"
VERSION = "3.2.14"
end
20 changes: 10 additions & 10 deletions spec/filter_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@
include: Set["test*{.rb, .js, .ts}"],
extensions: Set[".rb", ".js"],
exclude: Set["*_spec.rb"],
before: before,
after: after
before:,
after:
})
end

let(:now) { DateTime.now }
let(:changes) { super().deep_merge(orig_path: file_path, final_signature: { time: time }) }
let(:changes) { super().deep_merge(orig_path: file_path, final_signature: { time: }) }
let(:file_path) { "test.rb" }
let(:time) { Time.now }
let(:before) { now + 1_000 }
Expand All @@ -39,9 +39,9 @@
end

context "when the before filter is set to today" do
subject(:filter) { build(:filter, before: before) }
subject(:filter) { build(:filter, before:) }

let(:changes) { super().deep_merge(final_signature: { time: time }) }
let(:changes) { super().deep_merge(final_signature: { time: }) }
let(:before) { DateTime.now }

context "when the change is set BEFORE the [before] filter" do
Expand All @@ -62,7 +62,7 @@
end

context "when the [exclude] filter is set to ignore [LI*ENCE]" do
subject(:filter) { build(:filter, exclude: exclude) }
subject(:filter) { build(:filter, exclude:) }

let(:changes) { super().deep_merge(orig_path: file_path) }
let(:exclude) { Set["LI*ENCE"] }
Expand All @@ -85,7 +85,7 @@
end

context "when the [include] filter is set to include [*_spec.rb]" do
subject(:filter) { build(:filter, include: include) }
subject(:filter) { build(:filter, include:) }

let(:changes) { super().deep_merge(orig_path: file_path) }
let(:include) { Set["*_spec.rb"] }
Expand All @@ -108,7 +108,7 @@
end

context "when the [extensions] filter is set to ignore [.rb]" do
subject(:filter) { build(:filter, extensions: extensions) }
subject(:filter) { build(:filter, extensions:) }

let(:changes) { super().deep_merge(orig_path: file_path) }
let(:extensions) { Set[".rb"] }
Expand All @@ -131,9 +131,9 @@
end

context "when the after filter is set to today" do
subject(:filter) { build(:filter, after: after) }
subject(:filter) { build(:filter, after:) }

let(:changes) { super().deep_merge(final_signature: { time: time }) }
let(:changes) { super().deep_merge(final_signature: { time: }) }
let(:after) { DateTime.now }

context "when the change is set BEFORE the after filter" do
Expand Down

0 comments on commit 4307d61

Please sign in to comment.