Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

[Feature request] Support upstream/pushRemote workflow #58

Closed
rynoV opened this issue Mar 12, 2024 · 10 comments
Closed

[Feature request] Support upstream/pushRemote workflow #58

rynoV opened this issue Mar 12, 2024 · 10 comments

Comments

@rynoV
Copy link
Contributor

rynoV commented Mar 12, 2024

Thanks for making this! I really like it, especially for when I need to work on Windows.

One of the features I like about Magit is its support for easily differentiating a branch's upstream/merge and pushRemote. I first saw the feature+workflow described here, and now I find other git UIs without this feature like vscode's to be lacking. It's very convenient to be able to quickly see both the difference between the upstream merge target (e.g. master) and the remote branch being tracked (usually a "feature" branch with the same name as the local branch). For example, with Magit when I run a fetch:

  • I can immediately see if some other feature has been merged to master and my feature branch has fallen behind
  • I can immediately see if someone else, working on the same feature as me, has pushed to my feature branch and it has fallen behind
  • I can quickly pull either master or the remote tracked branch into my local branch

The main features from Magit that I'd like to see in this project:

  • Support for the separate push/fetch/pull keybinds described here for pushRemote vs upstream/merge
  • Support for the two sections in the main status screen showing the diff between the local branch and pushRemote, and the local branch and upstream/merge
  • Support for automatically setting branch.<name>.pushRemote (if it's not already set) when using the "push to pushRemote" keybind, in the same way as Magit

I'm not sure how big of an ask this is, I haven't looked at the codebase yet, but I like the project and I like rust so I might try implementing this at some point.

@altsem
Copy link
Owner

altsem commented Mar 12, 2024

Sounds great! In case you want to start on this, I'm happy to help!

Places I'd start at are:

  • For the status page, you'll find everything in src/screen/status.rs
    It produces a Vec<Item>, each Item being a visual line seen in Gitu, as well as some metadata.
  • push/pull/fetch are incredibly simple at the moment. Been trying to modularize these to make them easier to read, found e.g. here: src/ops/push.rs.
    Register the new actions. e.g. PullUpstream(push::PullUpstream) at this place:
    Pull(pull::Pull),

    Then a keybind can be added in here, like:
    Keybind::nomod(SubmenuOp::Pull, Char('p'), Op::Pull(Pull)),

Could focus on one of these to start! :)

@rynoV
Copy link
Contributor Author

rynoV commented Mar 14, 2024

I started looking into this today, I'm currently trying to figure out a good way to start experimenting with git2, planning to start setting up some tests using the tests/helpers.rs file. Glad to see there's already some good testing infrastructure set up!

@rynoV
Copy link
Contributor Author

rynoV commented Mar 22, 2024

@altsem What do you think about moving some of the test helper code into the src folder? In particular the parts of the helpers that set up a temporary repo. It seems you've stuck with end-to-end UI tests so far, but I wanted to set up some tests for my git helper functions (stuff like changing repo config), but the src/git module isn't exposed for the tests folder to use. Exposing it also seems okay to me, lmk what you think

@altsem
Copy link
Owner

altsem commented Mar 22, 2024

@rynoV I'm thinking all tests could be moved back. They used to be in src/

Especially now that I moved things into modules (ops::*)

Perhaps if you want to start small, just move the helpers 👍

rynoV added a commit to rynoV/gitu that referenced this issue Mar 24, 2024
@rynoV
Copy link
Contributor Author

rynoV commented Mar 24, 2024

@altsem I ended up moving them all into src because I ran into the issue of how to import the test utils from src into tests while still excluding them via cfg(test), so this seemed easier

The commit here for cherrypicking: rynoV@ab4ccb4

@altsem
Copy link
Owner

altsem commented Mar 24, 2024

@rynoV looks good. It is now in master!

@altsem altsem added enhancement New feature or request and removed enhancement New feature or request labels Mar 28, 2024
@altsem
Copy link
Owner

altsem commented Jul 17, 2024

I had a peek at just trying to understand all the bits and pieces we'd need to do in order to support this. Here's what a summary of it:

Currently Push/Pull will just equate to git push and git pull.
These two commands depend on the user's configuration of git: push.default.

The remotes are configured in a repo's .git/config, in it, entries are stored like:

[branch "deleteme"]
	remote = origin
	merge = refs/heads/master
	pushRemote = other

and can be read via git/(libgit2):

❯ git config branch.deleteme.pushRemote
origin
...

How Magit looks like:

image
image
image
image

TODO

  • Send upstream/pushRemote as arg to:
    • Rebase:
      • upstream -> git rebase origin/master
      • pushRemote -> git rebase other/deleteme
    • Push:
      • upstream -> git … push origin deleteme\:refs/heads/master
      • pushRemote -> git … push other refs/heads/deleteme\:refs/heads/deleteme
    • Pull:
      • upstream -> git … pull origin refs/heads/master
      • pushRemote -> git … pull other deleteme
    • Fetch:
      • upstream -> git fetch origin
      • pushRemote -> git fetch other
  • Branch configuration menu (You can reach this in various ways in Magit: PC, bC, FC and more?)
  • Prompt to set upstream/pushRemote if attempting to use one that is not set.
    How does this work in detail in Magit? Is it based on a user's push.default?

Future work

  • Display upstream + rebase/merge commits on status page:
    image

@rynoV
Copy link
Contributor Author

rynoV commented Jul 22, 2024

Thanks for looking into this that's helpful!

I merged my branch with the latest changes today. Currently I have code to set the upstream of a branch like magit does it, next will be to set the push remote and expose these functions from the branch config menu

@altsem
Copy link
Owner

altsem commented Oct 17, 2024

I think we might have something that works 🦀! And I feel it's usable and clear enough.
A bit hesitant to release this without extensive testing, so I'll flag it here in case anyone is eager to try.

After some time I'll drop it in master, and yet after some more I'll make a new release.
Code's found here: https://github.com/altsem/gitu/tree/wip/altsem-remotes

Good work with this and thanks @rynoV! :)

edit: It's now in master

@altsem altsem pinned this issue Oct 17, 2024
@altsem
Copy link
Owner

altsem commented Oct 24, 2024

This is now released as of version 0.26.0! 🎉

@altsem altsem closed this as completed Oct 24, 2024
@altsem altsem unpinned this issue Oct 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants