Skip to content

[rebase] enable --force-with-lease after rebasing - #6981

Merged
iAmWillShepherd merged 15 commits into
developmentfrom
shiftkey/rebase/force-push-sometimes
Mar 18, 2019
Merged

iAmWillShepherd merged 15 commits into
developmentfrom
shiftkey/rebase/force-push-sometimes

Conversation

@shiftkey

@shiftkey shiftkey commented Feb 28, 2019 •

Copy link
Copy Markdown
Member

Overview

Closes #6913

Description

This PR touches a few areas to enable --force-with-lease after a rebased is completed in the app:

  • when a rebase is complete, add the updated branch to a list of valid branches that can be force pushed later
  • updated the push/pull button to show when the current branch can be force pushed
  • a new dialog to confirm the force push, controlled by a new preference
  • push now has the ability to set --force-with-lease
  • do the thing (right up until branch protections block me from doing it)

TODO:

Release notes

Notes: [Improved] users are able to force push branches that were rebased within Desktop

@shiftkey shiftkey added this to the 1.7.0 milestone Feb 28, 2019
@shiftkey
shiftkey force-pushed the shiftkey/rebase/menu-item-and-dialog branch from f113389 to 29b5d2e Compare March 5, 2019 21:54
@shiftkey
shiftkey force-pushed the shiftkey/rebase/force-push-sometimes branch from 97e2cfe to 02e1a74 Compare March 5, 2019 22:07
@shiftkey
shiftkey force-pushed the shiftkey/rebase/menu-item-and-dialog branch from 25bdc88 to 09628d1 Compare March 7, 2019 13:36
@shiftkey
shiftkey force-pushed the shiftkey/rebase/force-push-sometimes branch 2 times, most recently from 1e170de to 0cbf103 Compare March 8, 2019 13:31
@shiftkey
shiftkey force-pushed the shiftkey/rebase/force-push-sometimes branch 2 times, most recently from 826ba76 to 8ea1c17 Compare March 8, 2019 17:32
@shiftkey

shiftkey commented Mar 8, 2019

Copy link
Copy Markdown
Member Author

Updated the PR description with the latest GIF of the flow with the shiny new icon - shout out to @ampinsk and @niik for the SVG assist!

@shiftkey
shiftkey force-pushed the shiftkey/rebase/force-push-sometimes branch from 8ea1c17 to 03b5fdb Compare March 11, 2019 12:25
@shiftkey
shiftkey changed the base branch from shiftkey/rebase/menu-item-and-dialog to development March 11, 2019 12:30
@shiftkey
shiftkey force-pushed the shiftkey/rebase/force-push-sometimes branch 2 times, most recently from 116a7c4 to 35f72e0 Compare March 11, 2019 14:41
@shiftkey
shiftkey marked this pull request as ready for review March 11, 2019 15:18
@shiftkey shiftkey added the ready-for-review Pull Requests that are ready to be reviewed by the maintainers label Mar 11, 2019
@shiftkey
shiftkey requested a review from a team March 11, 2019 15:19
@shiftkey
shiftkey force-pushed the shiftkey/rebase/force-push-sometimes branch from 35f72e0 to 8f8b05b Compare March 12, 2019 16:52
@shiftkey
shiftkey force-pushed the shiftkey/rebase/force-push-sometimes branch from 8f8b05b to 67bcaf3 Compare March 14, 2019 13:41
@shiftkey shiftkey added the time-sensitive Pull Requests where reviews need to happen in a timely manner label Mar 14, 2019
@shiftkey

Copy link
Copy Markdown
Member Author

Moving this to time-sensitive because I have work that builds upon this to tackle #6962 and be able to support a more complex flow (confirmation process, moving back and forth between stages).

@iAmWillShepherd iAmWillShepherd self-assigned this Mar 14, 2019
Comment thread app/src/lib/git/push.ts Resolved
Comment thread app/src/ui/dispatcher/dispatcher.ts Resolved
return
}

// TODO: transition to a rebase progress dialog

@iAmWillShepherd iAmWillShepherd Mar 15, 2019 •

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.

Non-blocking
Is there a PR for this piece or is this todo for a later date?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

This isn't found in a PR currently, but #6962 is the related issue and this requires reworking the flow between components

@shiftkey

Copy link
Copy Markdown
Member Author

🍎

@shiftkey shiftkey removed the time-sensitive Pull Requests where reviews need to happen in a timely manner label Mar 18, 2019
@iAmWillShepherd

iAmWillShepherd commented Mar 18, 2019 •

Copy link
Copy Markdown
Contributor

From a conversation @shiftkey and I had around not specifying the refname to protect and the expected SHA.


iamwillshepherd

I’m a bit curious about using the--force-with-lease flag without specifying, explicitly, the name of the ref we’d like to protect and the SHA that we expect the remote branch to be at. The documentation on this option gives me pause:

Note that all forms other than --force-with-lease=: that specifies the expected current value of the ref explicitly are still experimental and their semantics may change as we gain experience with this feature.

A general note on safety: supplying this option without an expected value, i.e. as --force-with-lease or --force-with-lease= interacts very badly with anything that implicitly runs git fetch on the remote

Desktop implicitly runs fetch on a schedule and it would seem doing that can get us into deep trouble as it seems git will overwrite any refs that you’ve seen (it’s the heuristic currently in use)

shiftkey

so we've had this manifest before with background fetching, but i believe #6141 has closed out the majority of these (edited)
and i've been using --force-with-lease on the command line (without an = value) a bunch and not having any issues with it. when i've seen it failed, it's been correct to fail because the remote ref has changed. i'm not sure of the value of making this explicit in our usage, but I think we've got all the data in place to do this.
i'd be 👍 on seeing a comment and context on the PR if you're worried about merging as-is and I can dig into what it'd take to add the =<refname>:<expect> value
...
this is some extra context if you want to understand more of the "under the hood" behaviour that the docs don't cover (link)
...
this is the failure case that I think you're worried about, right?

$ git push --force-with-lease
To /tmp/repo
 ! [rejected]        dev -> dev (stale info)
error: failed to push some refs to '/tmp/repo'

iamwillshepherd

Naw, I don’t think it’s the error that’s bad, I think it’s the overwriting of refs that’s bad
The protection it offers over --force is ensuring that subsequent changes your work wasn’t based on aren’t clobbered, but this is trivially defeated if some background process is updating refs in the background. We don’t have anything except the remote tracking info to go by as a heuristic for refs you’re expected to have seen & are willing to clobber.

shiftkey

aha, right, external processes
...
it shouldn't be since #6141 is merged - that now goes through the same concurrency restriction

@iAmWillShepherd
iAmWillShepherd merged commit 5ef3f7c into development Mar 18, 2019
@iAmWillShepherd
iAmWillShepherd deleted the shiftkey/rebase/force-push-sometimes branch March 18, 2019 15:30
@tierninho

tierninho commented Mar 22, 2019 •

Copy link
Copy Markdown
Contributor

@shiftkey Saw you added a custom forcePushIcon however following the completion of a rebase conflict, I noticed the icon was present without the word "force". Should this be possible or is a scenario not accounted for? I did nothing out of the ordinary to get here:

Screen Shot 2019-03-22 at 11 32 47 AM

and here:
Screen Shot 2019-03-22 at 2 34 17 PM

24c697c, mac

@shiftkey

Copy link
Copy Markdown
Member Author

@tierninho I think this was a side-effect of how the PushPullButton was organized (with different code paths to get the icon and the label) that I didn't get quite right at the time (slightly different checks for the icon and label, most likely).

I was nervous about making changes in here, and wrote up #6985 to call this out. I'm about to get #7042 ready for review which should make this state impossible to achieve:

function forcePushButton(
remoteName: string,
aheadBehind: IAheadBehind,
lastFetched: Date | null,
onClick: () => void
) {
return (
<ToolbarButton
{...defaultProps}
title={`Force push ${remoteName}`}
description={renderLastFetched(lastFetched)}
icon={forcePushIcon}
onClick={onClick}
>
{renderAheadBehind(aheadBehind)}
</ToolbarButton>
)
}

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