Skip to content

WIP: Creates A New Compare Activity That Handles Comparing Between Two Different Branches/Commits

Currently gitg doesn't yet support comparison functionality, this [my GSoC Project] helps to integrate this new functionality in gitg.

This MR creates a new Compare Activity in gitg in which users will be able to select different branches either to see the difference of commits between them, or to list the different commits of the two branches where users will be able to select any two commits to compare.

Inside the Compare Activity, three views are implemented:-

  1. MainView, in which the users will be able to select different branches
  2. BranchView, in which will be shown the difference of commits between the two selected branches in a GitgCommitListView
  3. CommitsView, in which will be shown the two branches' commits, where users will be able to select two commits to compare, each from different branch.

Here's what has been implemented on the backend side:-

  • extending libgitg with a new Popover to list the available branches, following the @felipeborges implementation of IdentifyingOSPopover. You could see his awesome implementation here
  • modifying GitgCommitModel so that we can provide a RevisionWalker for it, instead of creating a new one itself
  • extending GitgDiffView to update the diff on Idle to make the application more responsive
  • adding new GitgRefActionCompare which if selected, will set the selected branch as one of the branches to be compared automatically, then make a transition to the Compare Activity

Here's what has been implemented on the frontend side:-

  • decide what's the best way to implement it, whether to share the same RevisionWalker, or to create two models for the two branches with different RevisionWalker
  • create a MainView where user can choose which branches to compare
    • use the previously mentioned BranchesPopover to list the available branches to the user
    • detect if it's a bare repository, and show a message to the user to indicate that instead of displaying empty lists
  • create a BranchView, where comparison between branches is shown, e.g. Gitlab, and Github.
    • implement the model to only show the difference of the commits between the "Source Branch" and the "Target Branch"
  • create a CommitsView, where comparison between two different commits from different/same branch is shown
    • detect whether the two branches are the same, and use the same model if they were
    • load branches models serially to make use of the RevisionWalker commits cache
  • reload Compare Activity whenever there is a change in the repository, or new commits added

FIXES #270

Edited by Mahmoud Khalil

Merge request reports