Skip to content

use getStatus to detect conflicted repository state - #6116

Merged
outofambit merged 11 commits into
masterfrom
strip-back-conflict-detection
Nov 7, 2018
Merged

outofambit merged 11 commits into
masterfrom
strip-back-conflict-detection

Conversation

@shiftkey

@shiftkey shiftkey commented Nov 7, 2018 •

Copy link
Copy Markdown
Member

Overview

It's late, I can't sleep, and I'm restless from watching the news so I figure now is a great time to open a PR that changes how we detect merge conflicts in the app 🎉

This was started in #6082 but I wanted to move it out from there for more explicit discussion as it touches the core parts of conflict resolution flow.

Description

Currently we look at the output of git status to see which files are conflicted, but if a user decides to stage files outside the app (whether they're resolved or not) the conflict status markers are forgotten by git status, so it's possible for Desktop to "forget" it's in the middle of a conflict.

This affects #6082 but also other scenarios that weren't the happy path flow, like the user addressing conflicts in the app but not completing the process by committing before switching back to Desktop.

Instead of relying on git status output, this PR switches us over to look for .git/MERGE_HEAD in the repository to identify when conflicts need to be resolved.

The flow of this information is then like this:

  • getStatus has a new field mergeHeadFound that indicates whether it found MERGE_HEAD
  • within AppStore._loadStatus we compute the new conflicted state for the repository (getConflictStatus())
  • we update the repository state with the conflict information, as well as related stats (still needs some cleanup)
  • inside AppStore._triggerMergeConflictsFlow we then check the current state of conflicts
  • we use this detail to display the merge conflicts dialog (if required)

This also removes some _mergeConflictDetected() which would set the conflicted state, but didn't use git status - this centralizes the responsibility to AppStore._loadStatus()

TODO:

  • refactor the stats flow to reflect the desired behaviour
  • a bunch more testing

Release notes

Notes: no-notes

@shiftkey shiftkey added this to the 1.5.0 milestone Nov 7, 2018
@billygriffin

Copy link
Copy Markdown
Contributor

Cool! Couple questions:

  1. Just clarifying: I assume based on the description that this is just relating to detecting when a conflict has already occurred, and therefore doesn’t help solve the mismatch between git merge and git merge-tree we’ve seen pop up occasionally in predicting conflicts.

  2. Will this impact our metrics on conflicts resolved successfully vs. abandoned at all?

@shiftkey shiftkey changed the title use status to detect conflicted repository state [WIP] use status to detect conflicted repository state Nov 7, 2018
@shiftkey

shiftkey commented Nov 7, 2018

Copy link
Copy Markdown
Member Author

@billygriffin

  1. Just clarifying: I assume based on the description that this is just relating to detecting when a conflict has already occurred, and therefore doesn’t help solve the mismatch between git merge and git merge-tree we’ve seen pop up occasionally in predicting conflicts.

Yep, this is separate to the "merge hint" feature.

  1. Will this impact our metrics on conflicts resolved successfully vs. abandoned at all?

I intend to keep that support around - based on the rules previously defined - and the code path gets hit whenever we update the status of the repository (like before) so there shouldn't be any change to that area.

@shiftkey shiftkey changed the title [WIP] use status to detect conflicted repository state use status to detect conflicted repository state Nov 7, 2018
@shiftkey shiftkey added the ready-for-review Pull Requests that are ready to be reviewed by the maintainers label Nov 7, 2018
@shiftkey

shiftkey commented Nov 7, 2018

Copy link
Copy Markdown
Member Author

I'd like to get reviewed in time for the next beta, to give it the maximum time to bake.

The PR that started this off #6082 won't be resolved without these changes, and I plan to open a fresh PR after this lands targeting the 1.5.0 release branch to ensure it gets in.

@shiftkey
shiftkey requested a review from a team November 7, 2018 13:06
@shiftkey shiftkey changed the title use status to detect conflicted repository state use getStatus to detect conflicted repository state Nov 7, 2018
Comment thread app/src/lib/stores/app-store.ts Resolved
outofambit
outofambit previously approved these changes Nov 7, 2018

@outofambit outofambit left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

one minor request, but overall this looks good. going to test out a couple flows now to be extra sure.

@outofambit outofambit self-assigned this Nov 7, 2018
@outofambit outofambit mentioned this pull request Nov 7, 2018
@outofambit

Copy link
Copy Markdown
Contributor

going to merge this in ~1hr so we can unblock #6122

@outofambit

Copy link
Copy Markdown
Contributor

@shiftkey it looks like we have some conflicts now. would you mind resolving those? i'll merge this after that.

@shiftkey

shiftkey commented Nov 7, 2018

Copy link
Copy Markdown
Member Author

@outofambit done 🍎

@outofambit
outofambit merged commit 0008e3a into master Nov 7, 2018
@outofambit
outofambit deleted the strip-back-conflict-detection branch November 7, 2018 18:56
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.

3 participants