-
-
Notifications
You must be signed in to change notification settings - Fork 86
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
feat: implement git reword
command (#179)
#304
Conversation
Sorry for the churn. I think I've fixed all of the formatting and clippy issues. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is really exciting!
One note: before we merge this, squash together the non-functional changes like formatting and linting into the appropriate original commits. You can use git rebase -i
to do this, or something like git co <commit> && cargo fmt && cargo clippy --fix && git amend -m
.
35385a3
to
ac65d51
Compare
I just pushed a bunch of changes, but FYI they're not complete. I've taken care of all of the "easy" suggestions, now I'll start working on the juicier bits. I squashed all of the changes that you looked at yesterday into a single commit (noted as such) to maybe make it clearer what's been added when. Thanks again! |
Do you think this should have a basic "status report" after the reword, similar to what
(This format is totally up for discussion, but currently it's I ask b/c the most obvious implementation is to propagate On one hand, I think displaying a list of what's happened is desirable, but I want to confirm that w/ you before I solidify it and push it. For reference, here's the output w/ this while doing a rewording of 3 commits that results in rewriting a tree of 5 commits:
|
Whatever you think is best is fine here 🙂. I think it's not necessary to show the smartlog, though, since it shouldn't have changed as part of the reword.
That's perfectly fine. We'll probably use this data for something else in the future too. |
Also, see this regarding the failing Windows CI runs: #306 (comment) |
OK, I'm leaving it in, and I've disabled the smartlog. The format that I settled on is
I think I've taken care of all of the outstanding review items with my latest push. I would still like to do another full read through before I call it ready, but that is mostly to look for odd or non-idiomatic constructs, things I could simplify, etc. I believe that all of the features are in place and working. There are a few outstanding To confirm, are you OK if we leave the bulk edit feature out of this and add it later, after this has been merged? Or would you prefer to go for broke and add bulk editing now? On one hand, I think it would be nice to get this merged into master so folks could try it out as is; on the other hand, I don't think that bulk editing will be too difficult. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I haven't done anything to look at @epage request that it #179 (comment). At this time, I don't even know where to start w/ that, so any pointers would be most welcome.
I think git reword
should actually work as-is without git branchless init
(although it will lazily construct the repository commit graph so that it knows how to rebase descendant commits). However, I think there's a bug and it'll only work if the main branch happens to be named master
. If that's the case, it should be fixed by changing get_main_branch_name
to delegate to get_default_branch_name
, rather than the hardcoded master
value.
To test this, try just running git branchless reword
in a repository where you haven't run git branchless init
and see what happens.
The bulk editing feature is not implemented; I am voting ✋ for us to review this as is and add that later, though I'm also fine to push on to work on bulk editing now if you'd prefer.
Certainly, let's defer that.
During my latest read through, I decided that we should probably a "footer" message to the $EDITOR akin to the default commit message from git. I'll work on this soon.
We can also ship what you have now and you can follow up in future PRs if you like. Besides a few minor points above, I think this is good to ship when you're ready.
Yup, good call. I confirmed this and fixed it. I also confirmed that |
* much simpler rebase plan * remove confirmation * report reworded commits after rebase * simplify find_subtree_roots * update `rebase_in_memory` to support replacing commits * `plan::reword_commits` -> `plan::replace_commit` * improve success message reporting; show correct commits * don't show smartlog @ reword * use `git2::message_prettify` to clean up the reworded message * misc cleanup and improved messages Co-Authored-By: Waleed Khan <me@waleedkhan.name>
- fix incorrect `"###` usage for multiline strings - commits are already a slice, no need to convert
OK, I think I taken care of the latest round of review comments. Note that I have squashed all of the last round of reviewed work into 25346b9, and all new work is built on that. I gave everything a read through and think that this is good to go. I don't know what else to add or (more importantly) what else to remove. 😄 I'll leave a comment to draw your attention to one detail in particular, but I think we can call this done. |
🚀 HYPE 🚀 |
Updated PR description:
This supports all of the use-cases that I mentioned on #179, except for the fancy bulk editing case. That is to say:
$EDITOR
is opened w/ either the message of the commit being reworded (if just rewording a single commit) or a stub message when rewording multiple commits.A few things to make special note of:
?
or.unwrap()
, etcFinally, there a few things left to do:
branchless init
. At this time, I don't even know where to start w/ that, so any pointers would be most welcome.$EDITOR
akin to the defaultcommit
message fromgit
. I'll work on this soon.I think that covers most of it, but I'm sure I'm missing something! 😄
Original PR description below:
Still very draft, but it's working for all of the use-cases that I mentioned on #179, except for the fancy bulk editing case. That is to say:
$EDITOR
is opened w/ either the message of the commit being reworded (if just rewording a single commit) or a stub message when rewording multiple commits.--force
flag skips confirmation.)So, lots to love there already, but still lots to do:
For expediency, I implemented this by alteringEdit: I've removed the coupling w/r#move::r#move
(rewording is kind of just a special case of moving, at least, it seems so to me) but I just did that so that I could focus on the fun parts and not get bogged down trying to figure out the plumbing. (It's just a 4 line change inr#move
.) I intend to break this entanglement and move the actual rebase planning intoreword
, but it's still in place at this time. Because of this, though, it's doing a restack/smartlog for every subtree that's being reworded, instead of just doing a single restack and smartlog at the end.r#move
and rewritten the rebase planning and execution based onsync
.RebaseCommand
,. egRebaseCommand::Reword
. Instead I just updatedRebaseCommand::Pick
to support an optional message since a reword is just a pick but with a different message and the change was trivial. I'm inclined to leave this in place unless you feel otherwise.move
, I wanted to reuse all of the normalMoveOptions
, but I wanted to reserve the shorthand-m
flag for--messages
, not formerge
as inMoveOptions
... so I just duplicatedMoveOptions
intoRebaseOption
except w/o the-m
flag. This is still TBD, but I'd like a way to just reuseMoveOptions
while overriding the binding of-m
, but I haven't delved into how/if this can be done in clap.branchless init
. At this time, I don't even know where to start w/ that, so any pointers would be most welcome.I'm going to park this here for a bit while I go away and read more about borrowing, Boxes, memory mgmt, error handling etc in Rust. 😄 I hesitate to even ask for input yet, but I think it would be good to know if I'm heading in the right direction or not. (And of course even if I'm way off base and this is just totally not viable, it was still a fun learning exercise!)
Oh, and I totally used this to squash all of my ugly working commits. This is a slightly edited version:
Thanks for your consideration!