Skip to content

Comments

Add --force-detach flag to bypass detached HEAD check#155

Merged
tummychow merged 5 commits intotummychow:masterfrom
blairconrad:force-detach
Mar 2, 2025
Merged

Add --force-detach flag to bypass detached HEAD check#155
tummychow merged 5 commits intotummychow:masterfrom
blairconrad:force-detach

Conversation

@blairconrad
Copy link
Contributor

Fixes #145.

Also adds forceDetach configuration option.

@blairconrad
Copy link
Contributor Author

blairconrad commented Feb 23, 2025

This branch sits on top of #154 and #153 nothing, now! As always, happy to rebase or make any other changes at all.

src/lib.rs Outdated
pub force_author: bool,
pub force_detach: bool,
// force should only be used to enable oher force_* values when unifiying the config.
// Do not access when disabling individual safety checks.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Commenting is a little weak. I figure this would be more robust if either there were a new kind of configuration-holding bag that config::unify built out of this Config and the git config (or alternatively it could build this object from main::Cli, but it seemed like kind of a large change to put in without consultation.

Copy link
Owner

Choose a reason for hiding this comment

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

i would say, remove force from Config entirely since it's just for the cli...

Copy link
Contributor Author

@blairconrad blairconrad Feb 25, 2025

Choose a reason for hiding this comment

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

Tidy. I generally like the idea, but it requires adjustments to the format of the tests, no? I'd been following along with the pattern of testing lib.rs and below.
Hmm. You've probably considered all this and are okay with the risk of not covering the new logic in main.rs. I'll make the simple change (all I have time for before going to work anyhow) and if you're not content, am happy to evolve the solution.

@tummychow
Copy link
Owner

rebase please? this is very difficult to review with the other stuff mixed into it

@blairconrad
Copy link
Contributor Author

rebase please? this is very difficult to review with the other stuff mixed into it

Rebased, but can only get rid of commits from #153.
Building on changes in #154. If I try to drop those, I get conflicts.

I swear I'm not trying to make life difficult for you. If I hadn't encountered the surprising behaviour in the middle of this fix, it'd be quite a bit smoother. In the future if something like this comes up, I can hold off sending multiple PRs at once and just say that there's a current PR that in some way is a prerequisite for a future PR, or something.

@blairconrad
Copy link
Contributor Author

blairconrad commented Feb 24, 2025

Dropping PR #154, keeping some of the tests, and rebasing. Should be ready for review now. Thanks for your patience.

src/lib.rs Outdated
pub force_author: bool,
pub force_detach: bool,
// force should only be used to enable oher force_* values when unifiying the config.
// Do not access when disabling individual safety checks.
Copy link
Owner

Choose a reason for hiding this comment

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

i would say, remove force from Config entirely since it's just for the cli...

src/main.rs Outdated
dry_run,
force_author,
force_detach,
force,
Copy link
Owner

Choose a reason for hiding this comment

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

... and then down here, set force_detach: force_detach || force, same for force_author

Avoids the possibility of misusing the flag in
lib and below, but now the unit tests do not test
the use of the --force flag.
@blairconrad
Copy link
Contributor Author

blairconrad commented Feb 25, 2025

@tummychow, removed force as you suggest. Also removes testing that we did on handling of --force, but I expect you anticipated this. I quickly read how testing of logic in main.rs is handled in Rust and it seems to me that it largely isn't. If you're comfortable with this, I think we're good to review again. Otherwise, I am not 100% sure how to proceed. I would be inclined to move Cli into a module and add a function to create Config from Cli. This function could be tested to ensure it handles force, force_author, and force_detach. Happy to try if you like. But if you think it's all a bit much, happy to leave as well.

@tummychow tummychow merged commit 504d600 into tummychow:master Mar 2, 2025
5 checks passed
@tummychow
Copy link
Owner

thanks. and yeah i basically don't care about testing the code in the cli entrypoint atm. there's not much actual logic there and i'm not a stickler for coverage

@blairconrad blairconrad deleted the force-detach branch March 2, 2025 01:43
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.

Create --force-detach flag (which would also be activated by --force)

2 participants