Improve calculation of the `first_mentioned_in_commit_at` issue metric

Summary

  • The first_mentioned_at_commit_at metric is set on an issue the first time a commit containing a reference to the issue is pushed
  • If a second commit is pushed which also has a reference to the issue, the metric is not updated (this is expected).
  • If the second commit has a committed_date earlier than the first commit, the metric is not updated (although it should).

Steps to reproduce

  • Create an issue
  • In branch A, create a commit with a reference to the issue in the commit message. Don't push it.
  • In branch B, create a commit with a reference to the issue in the commit message. Push it.
  • Push branch A.

Expected behavior

Since the commit from branch A happened before the commit from branch B, the issue's first_mentioned_in_commit_at metric should be set to the commit from branch A's committed_date.

Actual behavior

The issue's first_mentioned_in_commit_at metric is set to the commit from branch B's committed_date.

Possible fixes

  • Relevant line where the metric is saved: https://gitlab.com/gitlab-org/gitlab-ce/blob/master/app/services/git_push_service.rb#L194
  • Set the metric if the current value of the metric is either nil or greater than the current commit's committed_date. Currently, we only perform the nil check.

/cc @pacoguzman @regisF @DouweM

Edited Nov 21, 2019 by Dan Jensen
Assignee Loading
Time tracking Loading