Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Base branch: Safely handle divergence #4899

Draft
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

estib-vega
Copy link
Contributor

@estib-vega estib-vega commented Sep 12, 2024

☕️ Reasoning

The application doesn't display any kind of information related to base branch divergence.
It should detect this, raise this to the user and present alternative actions to address this.

Scenario

  1. I open a repository on GitButler.
  2. A team-mate of mine makes some changes, and mistakenly pushes a commit with sensitive information.
  3. I merge the changes into the local base branch of GitButler. I can see the mistaken commit.
  4. They decide to force-push the commit away.
  5. I reload the application, but the state is the same as in step 3.

Expected behavior would be to have some information about this and the ability to restore the application to the latest version of the target upstream.

🧢 Changes

  1. Detect whether the base-branch has diverged with its upstream.
  2. Display the information to the user in a way that makes it clear if and which changes will be lost, if any action is taken

Visuals

Local is ahead of upstream

In this state, gitbutler/workspace is ahead of the target upstream.
The information is presented to the user as a heads-up only, as they might want to push the changes,
If they want to reset their local target branch to the current state of the target upstream, they will be prompted with a confirmation modal.

Screenshot 2024-09-13 at 16 57 45

Local has changes ahead and behind upstream

Similar to the previous state, there are some local commits that are not in the remote, but also some remote changes that are not in the local branch.
The information is displayed as a warning.

The options are to hard reset to the fork-point, or force-push.
Both buttons trigger confirmation dialogues.

Screenshot 2024-09-17 at 14 20 44

Confirmation dialogue when resetting to the fork-point

Screenshot 2024-09-17 at 14 21 01

Confirmation dialogue when force-pushing the local changes to the remote

Screenshot 2024-09-13 at 16 02 10

Copy link

vercel bot commented Sep 12, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
gitbutler-web ✅ Ready (Inspect) Visit Preview 💬 Add feedback Sep 24, 2024 3:17pm

@github-actions github-actions bot added rust Pull requests that update Rust code @gitbutler/desktop labels Sep 12, 2024
@estib-vega estib-vega force-pushed the base-branch-improvements branch 2 times, most recently from ba3329e to 901e225 Compare September 13, 2024 08:10
@estib-vega estib-vega changed the title base-branch-improvements Base branch: Safely handle divergence Sep 13, 2024
@estib-vega estib-vega marked this pull request as ready for review September 13, 2024 15:32
@krlvi
Copy link
Member

krlvi commented Sep 16, 2024

Lets separate out the update of base branch (because we can in the future show exactly what is gonna happen to branches)

Determine whether the local target has diverged from the remote,
and return some information about that
If the local target has diverged from the remote target, display that to the user as a warning

Only show either the divergence warning or upstream count
BaseBranch: Use runes

BaseBranch: Display the branch graph

In order to make it a bit clearer what the divergence state of the base branch is. reuse the line graphs to display it

BaseBranch divergence: Add a confirmation modal
If needed, the base branch can be pushed or force pushed
Only display the warnings and confirmation modals when actual changes can get lost (resting to local or remote).
Otherwise, display less scary notifications and let the user push if needed

Merge remote-tracking branch 'origin/master' into base-branch-improvements
Depending on which action the user chooses, and whether they've set certain flags, act accordingly
Add a method to determine which should be the new base branch target commit ID based on what resolution approach is selected
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
@gitbutler/desktop @gitbutler/ui rust Pull requests that update Rust code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants