Commit 58426e44 authored by Adam Hegyi's avatar Adam Hegyi

Enable feature flag by default

This MR enables the store_first_mentioned_in_commit_on_issue_close
by default. It also makes a small change to store the `authored_date`
instead of the `committed_date`.
parent 4308790b
...@@ -52,12 +52,12 @@ module Issues ...@@ -52,12 +52,12 @@ module Issues
end end
def store_first_mentioned_in_commit_at(issue, merge_request) def store_first_mentioned_in_commit_at(issue, merge_request)
return unless Feature.enabled?(:store_first_mentioned_in_commit_on_issue_close, issue.project) return unless Feature.enabled?(:store_first_mentioned_in_commit_on_issue_close, issue.project, default_enabled: true)
metrics = issue.metrics metrics = issue.metrics
return if metrics.nil? || metrics.first_mentioned_in_commit_at return if metrics.nil? || metrics.first_mentioned_in_commit_at
first_commit_timestamp = merge_request.commits(limit: 1).first&.date first_commit_timestamp = merge_request.commits(limit: 1).first.try(:authored_date)
return unless first_commit_timestamp return unless first_commit_timestamp
metrics.update!(first_mentioned_in_commit_at: first_commit_timestamp) metrics.update!(first_mentioned_in_commit_at: first_commit_timestamp)
......
---
title: Store first commit's authored_date for value stream calculation on merge
merge_request: 26885
author:
type: changed
...@@ -103,8 +103,8 @@ describe Issues::CloseService do ...@@ -103,8 +103,8 @@ describe Issues::CloseService do
subject { described_class.new(project, user).close_issue(issue, closed_via: closing_merge_request) } subject { described_class.new(project, user).close_issue(issue, closed_via: closing_merge_request) }
context 'when `metrics.first_mentioned_in_commit_at` is not set' do context 'when `metrics.first_mentioned_in_commit_at` is not set' do
it 'uses the first commit timestamp' do it 'uses the first commit authored timestamp' do
expected = closing_merge_request.commits.first.date expected = closing_merge_request.commits.first.authored_date
subject subject
......
...@@ -118,7 +118,7 @@ describe MergeRequests::MergeService do ...@@ -118,7 +118,7 @@ describe MergeRequests::MergeService do
it 'closes GitLab issue tracker issues' do it 'closes GitLab issue tracker issues' do
issue = create :issue, project: project issue = create :issue, project: project
commit = double('commit', safe_message: "Fixes #{issue.to_reference}", date: Time.now) commit = instance_double('commit', safe_message: "Fixes #{issue.to_reference}", date: Time.now, authored_date: Time.now)
allow(merge_request).to receive(:commits).and_return([commit]) allow(merge_request).to receive(:commits).and_return([commit])
merge_request.cache_merge_request_closes_issues! merge_request.cache_merge_request_closes_issues!
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment