Class: Datadog::CI::Git::BaseBranchShaDetection::BranchMetric
- Inherits:
-
Object
- Object
- Datadog::CI::Git::BaseBranchShaDetection::BranchMetric
- Defined in:
- lib/datadog/ci/git/base_branch_sha_detection/branch_metric.rb
Overview
Represents metrics for a git branch comparison including how far behind/ahead it is from a source branch and the common base commit SHA
Instance Attribute Summary collapse
-
#ahead ⇒ Object
readonly
Returns the value of attribute ahead.
-
#base_sha ⇒ Object
readonly
Returns the value of attribute base_sha.
-
#behind ⇒ Object
readonly
Returns the value of attribute behind.
-
#branch_name ⇒ Object
readonly
Returns the value of attribute branch_name.
Instance Method Summary collapse
-
#divergence_score ⇒ Object
Used for comparison when finding the best branch Lower divergence score is better.
-
#initialize(branch_name:, behind:, ahead:, base_sha:) ⇒ BranchMetric
constructor
A new instance of BranchMetric.
-
#up_to_date? ⇒ Boolean
Checks if the branch is up to date with the source branch.
Constructor Details
#initialize(branch_name:, behind:, ahead:, base_sha:) ⇒ BranchMetric
Returns a new instance of BranchMetric.
13 14 15 16 17 18 |
# File 'lib/datadog/ci/git/base_branch_sha_detection/branch_metric.rb', line 13 def initialize(branch_name:, behind:, ahead:, base_sha:) @branch_name = branch_name @behind = behind @ahead = ahead @base_sha = base_sha end |
Instance Attribute Details
#ahead ⇒ Object (readonly)
Returns the value of attribute ahead.
11 12 13 |
# File 'lib/datadog/ci/git/base_branch_sha_detection/branch_metric.rb', line 11 def ahead @ahead end |
#base_sha ⇒ Object (readonly)
Returns the value of attribute base_sha.
11 12 13 |
# File 'lib/datadog/ci/git/base_branch_sha_detection/branch_metric.rb', line 11 def base_sha @base_sha end |
#behind ⇒ Object (readonly)
Returns the value of attribute behind.
11 12 13 |
# File 'lib/datadog/ci/git/base_branch_sha_detection/branch_metric.rb', line 11 def behind @behind end |
#branch_name ⇒ Object (readonly)
Returns the value of attribute branch_name.
11 12 13 |
# File 'lib/datadog/ci/git/base_branch_sha_detection/branch_metric.rb', line 11 def branch_name @branch_name end |
Instance Method Details
#divergence_score ⇒ Object
Used for comparison when finding the best branch Lower divergence score is better
27 28 29 |
# File 'lib/datadog/ci/git/base_branch_sha_detection/branch_metric.rb', line 27 def divergence_score @ahead end |
#up_to_date? ⇒ Boolean
Checks if the branch is up to date with the source branch
21 22 23 |
# File 'lib/datadog/ci/git/base_branch_sha_detection/branch_metric.rb', line 21 def up_to_date? @behind == 0 && @ahead == 0 end |