-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Resolve sha in delta output for HEAD
- Loading branch information
1 parent
52eda92
commit bce75e2
Showing
12 changed files
with
83 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
PATH | ||
remote: . | ||
specs: | ||
churn_vs_complexity (1.5.1) | ||
churn_vs_complexity (1.5.2) | ||
flog (~> 4.8) | ||
git (~> 2.1) | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# frozen_string_literal: true | ||
|
||
module ChurnVsComplexity | ||
module Delta | ||
class CommitHydrator | ||
def initialize(git_strategy:, serializer:) | ||
@git_strategy = git_strategy | ||
@serializer = serializer | ||
end | ||
|
||
def hydrate(commit_sha) | ||
commit = @git_strategy.object(commit_sha) | ||
summary = { commit: commit.sha } | ||
if @serializer.respond_to?(:has_commit_summary?) && @serializer.has_commit_summary? | ||
parent, next_commit = @git_strategy.surrounding(commit:) | ||
summary.merge!(parent:, next_commit:) | ||
end | ||
summary | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
# frozen_string_literal: true | ||
|
||
module ChurnVsComplexity | ||
VERSION = '1.5.1' | ||
VERSION = '1.5.2' | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'test_helper' | ||
|
||
module ChurnVsComplexity | ||
module Delta | ||
class CommitHydratorTest < TLDR | ||
def test_resolves_sha_of_head_commit | ||
expected_sha = '123abcde' | ||
git_strategy = GitStrategyStub.new(object_sha: expected_sha) | ||
hydrator = CommitHydrator.new(git_strategy:, serializer: nil) | ||
|
||
result = hydrator.hydrate('HEAD') | ||
|
||
assert_equal expected_sha, result[:commit] | ||
end | ||
|
||
GitCommitStub = Data.define(:sha) | ||
|
||
class GitStrategyStub | ||
def initialize(object_sha: nil) | ||
@object_sha = object_sha | ||
end | ||
|
||
def object(commit) | ||
GitCommitStub.new(sha: @object_sha || commit) | ||
end | ||
end | ||
end | ||
end | ||
end |