Skip to content

show "force push" label after rebase which requires it - #7243

Merged
shiftkey merged 18 commits into
developmentfrom
show-force-push-label
Apr 17, 2019
Merged

shiftkey merged 18 commits into
developmentfrom
show-force-push-label

Conversation

@shiftkey

@shiftkey shiftkey commented Apr 8, 2019 •

Copy link
Copy Markdown
Member

Overview

This also pulls in the work from #6489 because I believe some changes around AppStore._selectRepository now mean we no longer have a AppStore.refreshRepository that isn't await-ed.

I also want to add the ... to the Force Push label if the user has configured their preferences to warn them before they force push.

Closes #4976
Closes #7138
Closes #7231

Current development branch:

This PR:

And the ... characters are omitted if you have disable the "Confirm..." settings in your preferences:

Description

Release notes

Notes: no-notes

@shiftkey
shiftkey force-pushed the show-force-push-label branch from 07a7071 to c5a78c4 Compare April 8, 2019 19:11
Comment thread app/src/lib/stores/app-store.ts Resolved
@shiftkey
shiftkey force-pushed the show-force-push-label branch from 780ffd8 to d0306dc Compare April 8, 2019 20:03
@shiftkey
shiftkey marked this pull request as ready for review April 8, 2019 20:30
@shiftkey shiftkey added the ready-for-review Pull Requests that are ready to be reviewed by the maintainers label Apr 8, 2019
@shiftkey shiftkey added this to the 1.7.0 milestone Apr 8, 2019
@shiftkey
shiftkey force-pushed the show-force-push-label branch from b723be1 to 639afe7 Compare April 8, 2019 20:55
Comment thread app/src/lib/rebase.ts Resolved
@shiftkey
shiftkey force-pushed the show-force-push-label branch from 12ea76d to 4611317 Compare April 9, 2019 17:16
outofambit
outofambit previously approved these changes Apr 9, 2019

@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.

yay!

@outofambit outofambit self-assigned this Apr 9, 2019
@tierninho

Copy link
Copy Markdown
Contributor

Tested the changes and here are my notes:

  • Why is dialogue different between clicking Force push origin button and selecting the Force Push... menu option? When selecting Force push... menu option I noticed there is no cancel button in the dialogue, which could lead to accidental pushing.

  • When selecting the Force push... menu option, I spotted this in the logs:

install.ts:23 `git -c credential.helper= -c protocol.version=2 push origin as:as --progress` exited with an unexpected code: 1.
To https://github.com/tierninho/PRlist.git
 ! [rejected]        as -> as (non-fast-forward)
error: failed to push some refs to 'https://github.com/tierninho/PRlist.git'
hint: Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart. Integrate the remote changes (e.g.
hint: 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.

(The error was parsed as 10: The repository has been updated since you last pulled. Try pulling before pushing.)
  • I changed the preference setting to "do not show me force push" option, and the menu item changed to just Push. Couldn't get to change to Force Push nor back to Force Push....

  • I turned off the force push preference setting, selected the Push menu option and still got the warning dialogue. I hit X and then clicked the Force push origin button and it push the code.

@shiftkey

shiftkey commented Apr 10, 2019 •

Copy link
Copy Markdown
Member Author
  • When selecting Force push... menu option I noticed there is no cancel button in the dialogue, which could lead to accidental pushing.

What dialog do you see here? I think this is related to what happens when the menu button fires - I haven't touched the underlying implementation, which just emits an event from the main process:

desktop/app/src/ui/app.tsx

Lines 293 to 294 in 6d241b0

case 'push':
return this.push()

Which is associated with this function in the renderer:

desktop/app/src/ui/app.tsx

Lines 293 to 294 in 6d241b0

case 'push':
return this.push()

That explains the second bit of feedback:

  • When selecting the Force push... menu option, I spotted this in the logs:

This error occurs because we don't pass --force-with-lease by default, which is Good and Safe™. But we need to signal that this is a force push and pass that through to the renderer.

  • I changed the preference setting to "do not show me force push" option, and the menu item changed to just Push. Couldn't get to change to Force Push nor back to Force Push....

Good find! I'll see if I can reproduce this on my end.

  • I turned off the force push preference setting, selected the Push menu option and still got the warning dialogue. I hit X and then clicked the Force push origin button and it push the code.

I think you're seeing the "Push failed" error message - let's revisit this after I've tweaked the main process to send a force-push event to the renderer.

@shiftkey

Copy link
Copy Markdown
Member Author

I've pushed two commits to this branch to address @tierninho's feedback:

  • bd69082 - the first commit which passes through the original context, which we need to know what menu to show and what action to fire. I prefer this approach rather than maintaining two sets of string checks, and I'll come in later to follow up with other cleanup.
  • 740b8fd - the menu labels should be updated immediately when the preferences change, but we weren't doing this. I wasn't happy with the internals of AppStore.updateMenuItemLabels so I took the chance here to clean this up and make it more explicit and better documented - this will close out Remove AppStore.getBranchesState #7231, apologies @iAmWillShepherd

@shiftkey
shiftkey requested a review from outofambit April 10, 2019 15:33
outofambit
outofambit previously approved these changes Apr 10, 2019

@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.

this looks good to me! @tierninho can you verify the menu item label issue you found is fixed?

@tierninho

Copy link
Copy Markdown
Contributor

All issues I found have now been resolved and verified. Nice work! 💰

The "other" dialogue is gone and now matches this, no matter which method you use: menu or button.

image

Did another round of testing, and all LGTM.

@tierninho

Copy link
Copy Markdown
Contributor

Found an instance when the branch is protected and the menu option and the main push button are not in sync.

Try to force push to a protected branch. After dismissing the warning, you should end up with this:
Screen Shot 2019-04-10 at 1 53 11 PM

If you select Force Push from the menu, you get this dialogue (this is the one I saw earlier before your fixes came in).
Screen Shot 2019-04-10 at 1 55 17 PM

Should we have any UI treatment if the branch is protected to prevent this?

@shiftkey

Copy link
Copy Markdown
Member Author

Should we have any UI treatment if the branch is protected to prevent this?

The problem here is that we don't refresh the menu items after a Git operation - this isn't a scenario we've really had to think about before. If we keep those in sync, it should revert to Push and retain the classic behaviour.

There's a bit here that's unclear to me:

If you select Force Push from the menu, you get this dialogue (this is the one I saw earlier before your fixes came in).

The menu label here seems correct if we're not updating the menu labels, but the action itself seems to be doing a push without the --force-with-lease, which is the expected behaviour.

Going to see if I can understand this mismatch this morning and wrap this up - thanks for being so methodical @tierninho!

@shiftkey

Copy link
Copy Markdown
Member Author

@tierninho I haven't been able to trip the issue you noticed here:

If you select Force Push from the menu, you get this dialogue (this is the one I saw earlier before your fixes came in).
Screen Shot 2019-04-10 at 1 55 17 PM

After force pushing to a protected branch (and seeing it fail) the menu item should be back in sync with the push/pull button state.

outofambit
outofambit previously approved these changes Apr 11, 2019
@tierninho

Copy link
Copy Markdown
Contributor

@shiftkey So I tested this again and here are the steps:

  • Make branch A a protected branch, and rebase branch A onto any other branch.
  • When you get to Force Push, click and wait for protected branch warning.
  • Dismiss warning and go to Repo menu and it should now be Push, select it
  • This warning pops up with a console error:

Screen Shot 2019-04-11 at 10 06 13 AM

Is this a normal use case, as I should be pulling instead of pushing?

@shiftkey

Copy link
Copy Markdown
Member Author

Is this a normal use case, as I should be pulling instead of pushing?

No, and yes.

This is not the typical use case because we suspect most users will click the push/pull button - which will "pull with merge" or "pull with rebase" depending on your setting.

The dialog is from #6610 which might not seem as intuitive as it could be, but having improved Protected Branches support here would make this less of an issue.

@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 little thing left but otherwise looks good to me!

Comment thread app/src/lib/stores/app-store.ts Resolved
@shiftkey shiftkey added the time-sensitive Pull Requests where reviews need to happen in a timely manner label Apr 17, 2019
@shiftkey
shiftkey merged commit 1b98ce7 into development Apr 17, 2019
@shiftkey
shiftkey deleted the show-force-push-label branch April 17, 2019 17:36
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 time-sensitive Pull Requests where reviews need to happen in a timely manner

Projects

None yet

4 participants