Skip to content

Show divergence counts for a fork on project page

What does this MR do and why?

The fork may have 4 states:

  • Fork is up to date
  • Fork is behind upstream
  • Fork is ahead of upstream
  • Fork is behind and ahead of upstream

This commit fetches the fork's branch into the source repo and calculates the divergence counts

Related issue: #14491 (closed)

Test locally

Enable fork_divergence_counts feature flag:

Feature.enable(:fork_divergence_counts)
  1. Fork a project
  2. Visit the fork project page
  3. If no commits were pushed to the upstream, the Up to date with upstream repository message must be shown:

Screenshot_2022-11-21_at_16.38.59

  1. Push a commit/multiple commits to the upstream project
  2. The message will show that the project is N commits behind the upstream

Screenshot_2022-11-21_at_16.40.26

  1. Push a commit/multiple commits to the fork
  2. The message will show that the project is N commits ahead of the upstream

Screenshot_2022-11-21_at_16.41.30

  1. It is expected that a user creates a fork in order to propose changes to the upstream default branch. That's why we always compare with the default branch. Having said that, in order to test the behavior, it is sufficient to play with the ref dropdown:

Screenshot_2022-11-21_at_16.46.35

Edited by Igor Drozdov

Merge request reports

Loading