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

Add flag and configuration to generate fixup commits for commits written by another author #143

Merged
merged 3 commits into from
Feb 4, 2025

Conversation

blairconrad
Copy link
Contributor

Fixes #140.

Copy link
Contributor Author

@blairconrad blairconrad left a comment

Choose a reason for hiding this comment

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

Thanks for considering the PR. As I mentioned before, this is my first time seeing rust. I've tried to conform to the existing styles and conventions where possible, but may have still done something unrustic or just silly.

I'm happy to make any changes at all, to the code, docs, commit comments, you name it.

run_with_repo(config, &repo)
}

fn run_with_repo(config: &mut Config, repo: &git2::Repository) -> Result<()> {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Possibly controversial change?

It was much easier to write tests to assess the effects of the flag and new configuration option after pulling the config-altering code into this method.

Copy link
Owner

@tummychow tummychow Feb 4, 2025

Choose a reason for hiding this comment

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

i have a weak dislike for it, but that's not enough to block a functionally complete pr. refactors are a matter of taste after all. if i was going to spend time cleaning it up, i would probably make a function in config.rs that takes a Config and returns a new Config with flags unified and repo defaults applied (then run_with_repo can go back to taking an immutable Config). maybe dedup the config fetching code too, but that might require a macro.

@@ -7,6 +7,7 @@ use crate::config;
pub fn working_stack<'repo>(
repo: &'repo git2::Repository,
user_provided_base: Option<&str>,
force_author: bool,
force: bool,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think force looks funny here. I'd had a commit that would rename this to force_branch, but

  1. wasn't sure if it was overstepping the bounds of this PR, and
  2. hadn't approval for the name (even though it would only be internal)

Longer term, I'd consider adding a --force-branch (or similar) flag to the CLI (and possibly a configuration option if desired). If this PR is eventually acceptable, and there's interest, I would be open to doing that work as well.

Copy link
Owner

Choose a reason for hiding this comment

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

yes, we should have a separate --force-detach for absorbing on a detached head, then --force would apply both --force-author and --force-detach, and the two flags can be separated internally. feel free to submit that pr if you like

@blairconrad
Copy link
Contributor Author

... and I see there's a test failure. 🤦🏻 This could be exciting, as the tests pass on my (windows) machine. Starting to investigate, but I'm not set up for *nix development, so it may be slow.

@blairconrad
Copy link
Contributor Author

... and now I have cargo set up in ubuntu on WSL and all the tests pass

@tummychow tummychow merged commit acfde39 into tummychow:master Feb 4, 2025
3 checks passed
@tummychow
Copy link
Owner

this is good enough for me. there's more stuff that needs to be cleaned up here but it shouldn't block this pr.

@@ -476,6 +487,12 @@ fn nothing_left_in_index(repo: &git2::Repository) -> Result<bool> {
Ok(nothing)
}

fn something_left_in_index(repo: &git2::Repository) -> Result<bool> {
Copy link
Owner

Choose a reason for hiding this comment

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

if you're in the mood to do more refactoring: i didn't notice we had so many test-only helpers in this module. we should wrap them in a module behind a cfg(test) so the helpers can't accidentally be used in library code

@blairconrad
Copy link
Contributor Author

blairconrad commented Feb 4, 2025

Thanks for the review and merge, @tummychow. I am happy to do more work. How about I make issues out of your comments and I (or others!) can see if they can handle them. I wouldn't mind working on any or all, but it'd be greedy to grab them all at once!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Configuration flag to allow fixuping commits authored not by me
2 participants