Skip to content

Compare to Branch#4182

Merged
nerdneha merged 376 commits intomasterfrom
compare-branches
Apr 24, 2018
Merged

Compare to Branch#4182
nerdneha merged 376 commits intomasterfrom
compare-branches

Conversation

@iAmWillShepherd
Copy link
Contributor

@iAmWillShepherd iAmWillShepherd commented Mar 6, 2018

#So, I accidentally built all the things in #3956, my bad. I was confused because I used the image in the first issue to build out my tasks list.

Fixes #3967
Fixes #3968
Fixes #3997
Fixes #3998

I also created issues #4317, #4458, and #4318 to track additional work that needs to be done around this feature.

MVP

  • Add feature flag
  • Rename Changes tab -> Commit
  • Rename History tab -> Compare
  • Add UI to select a branch
  • Add TabBar component to allow selecting ahead or behind
  • Update commit list based on CompareType
  • If no branch is selected we should show all commits (basically do what we've always done) and hide the ahead/behind buttons
  • Update ahead/behind info when branch is switched
  • Add a button to merge commits that are ahead of the current branch

Polish

  • Switch from select input to a text input
    • Input should show a filter-list of branches on focus
    • Each branch should show the number of commits ahead and behind the current branch
      • Figure out a way to load ahead/behind for every branch (All branches currently show the same ahead/behind info of the currently selected branch).
    • Selecting a branch should populate the text input with its name
    • Text input should have an icon that, when clicked, clears the text in the input field and takes user back to normal layout (pressing escape should do the same thing)
  • Add a new CompareBranchListItem component that has all the logic to load the compare state async
  • When typing in non-existent branch names the branch list is eventually empty, which resets the filter, which then displays all branches again
  • after selecting a branch to compare, switching Compare -> Commit -> Compare remembers most of the form state except for the filter text - fixed in some more compare branches cleanup #4396
  • Blank-slate image positioning is off (see comment)
  • Change empty list message from No History -> No Commits - fixed in some more compare branches cleanup #4396
  • Improve styling so that longer branch names don't display weirdly (see comment)

QA

  • Update top-level menu to reflect new Compare and Commit tab names
    Disable return key when no matches exist (this is harder than it seems, may need to track in a new issue) (tracking in Disable return key when no matches exist #4458)
  • Auto-complete it too eager, we want to match character-by-character
  • Ahead/Behind tab bar is too sticky, when a branch is switched, default to behind tab
  • Any branch with commits beyond roughly 100, do not show when scrolling down
  • User cannot "arrow-key-down" from compare-branch filter to the search results. Nor can the user "arrow-key down" from the Behind or Ahead tab to the commits.
  • Behind/Ahead placement is not consistent. A/B or B/A?
  • when selecting a branch, the user is automatically navigated to the Behind/Ahead tabs, yet the Behind tab is not highlighted blue until the user clicks it
  • Odd behavior... select "origin/upgrade-yarn-time" as branch to compare. Behind/Ahead tabs shown with results as expected. Now place cursor back in search bar, and the "origin/upgrade-yarn-time" should show as a search result. Now hit enter, and notice there is nothing there. Behind/Ahead tabs should be shown.

Incomplete

Progress

Ahead/Behind and Commits

2018-03-22 11 03 47

Merging

2018-03-26 15 34 01

@iAmWillShepherd iAmWillShepherd modified the milestone: 1.2 Mar 6, 2018
@iAmWillShepherd
Copy link
Contributor Author

I took @shiftkey's advice and went back to using a select input because it's much easier to test switching branches. The code to do auto-completion is complete, so switching back shouldn't be too much of an issue.

@iAmWillShepherd
Copy link
Contributor Author

Currently working through issue where ahead/behind isn't updated for a selected branch until you click on one of the radio buttons.

@iAmWillShepherd
Copy link
Contributor Author

Right now, since I am relying on the BranchList component to show branches, I am not able to render the ahead/behind info. I'm considering modifying the component to accept a BranchItem render prop so that I can customize the rendering of the list. I also updated the FilterList to accept a TextBox component. This is needed because I need the TextBox to always be visible, so I cannot rely on the one that's built into the FilterList component.

@iAmWillShepherd
Copy link
Contributor Author

Most functionality is here, but this will need some CSS magic to really make it pop.
2018-03-15_21-37-55

@iAmWillShepherd
Copy link
Contributor Author

Branches List

The TextBox takes up too much vertical space, pushing the branch list down. Removing the CSS rule flex: 1; seems to make the element take up only the space it needs.

2018-03-15 16 00 04

Commit List

The commit list should be visible directly underneath the two radio buttons. @shiftkey mentioned this is because it's a React-Virtualized component and will only render things when it has space to do so. Giving it some height in Chrome dev tools works only when I set the value to a height in pixels first (I can use height: 100% afterwards)

2018-03-16 12 35 18

Copy link
Contributor

@nerdneha nerdneha left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the changes look great!!! just ⛏ on the todos


if (formState.kind === ComparisonView.None) {
// the tab control should never be shown in this case
// TODO: can we enforce this with TYPES?

This comment was marked as spam.

This comment was marked as spam.

readonly renderNoItems?: () => JSX.Element | null

/** Used to get a reference to a TextBox that will be used to control this component */
readonly filterTextBox?: TextBox //Todo: don't rely on passing textbox to component

This comment was marked as spam.

This comment was marked as spam.

@nerdneha
Copy link
Contributor

@shiftkey

@nerdneha because the ahead/behind stats work is proportional to the number of local and remote branches in a repository, the work to compute branches is queued up serially using requestIdleCallback - see #4399 for more context.

after reading the code, that made sense; in fact that wasn't the part that felt off when i was testing; it was the fact that the component was calculating the ahead/behind when i clicked on a compare-branch and then it felt like the branch list component hadn't "remembered". programmatically i get that it's queued and it'll show up soon but still felt weird as a user.

@shiftkey
Copy link
Member

it was the fact that the component was calculating the ahead/behind when i clicked on a compare-branch and then it felt like the branch list component hadn't "remembered".

Right, now I'm with you. Mind opening a new issue and indicate that selecting a branch (which computes the ahead/behind stats) should also push that into the cache (which should then refresh the list the next time you switch to it)?

@nerdneha
Copy link
Contributor

feeling really good about this feature and solid updates based on code review! 🎈

IMO given that @donokuda opened up a PR for some of the visual pieces and that we have an open PR for updating the way we use FilterList, I don't think there's anything that's blocking a merge. (although I'd like to get rid of that TODO if there's nothing that really needs it).

things i tested:

  • comparing to a branch with 0 behind and X ahead
  • comparing to a branch with X behind and 0 ahead
  • comparing to a branch with X behind and Y ahead
    • merging successfully + undoing
    • merging that resulted in merge conflicts, undoing the commit that caused conflict, discarding changes, and successfully merging
  • comparing with many branches back-to-back
  • filtering for branches in different ways
  • filtering on something not found to see "no branches" view
  • trying to merge when there's nothing to merge
  • branching from a branch + then merging back into that branch
  • merging between two branches
  • merging master into something with >2k commits

it's got a 👍 from me. ccing @niik in case there's anything he wants to comment on

nerdneha
nerdneha previously approved these changes Apr 24, 2018
nerdneha
nerdneha previously approved these changes Apr 24, 2018
@nerdneha nerdneha merged commit 2406f4b into master Apr 24, 2018
@iAmWillShepherd iAmWillShepherd deleted the compare-branches branch April 24, 2018 17:35
@saiKumarGanji
Copy link

When will the exe file will be released which will have this feature

@shiftkey
Copy link
Member

@saiKumarGanji once #4545 is merged and we publish an update to the beta channel it will be available there

@jonnyijapan
Copy link

jonnyijapan commented Apr 3, 2019

This feature shows "only" differing commits, and then the changed files in those specific diffs. It would be helpful if Github Desktop could show the summarized diff of all the files in all of the differing commits. Like the diff when using Github.com in a pull request etc. Sorry for a late "request".

@shiftkey
Copy link
Member

shiftkey commented May 1, 2019

Sorry for a late "request".

@jonnyijapan if this is something that is still of interest to you, please open a suggestion so we can track it separate to the original work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready-for-review Pull Requests that are ready to be reviewed by the maintainers

Projects

None yet

Development

Successfully merging this pull request may close these issues.