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

feat: strip prefix #397

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

JP-Ellis
Copy link

@JP-Ellis JP-Ellis commented Sep 19, 2024

If fixups are allowed, then the remainder of the commit message ought to either be either a previous commit's subject line, or a hash:

If a commit message starts with "squash! ", "fixup! " or "amend! ", the remainder of the subject line is taken as a commit specifier, which matches a previous commit if it matches the subject line or the hash of that commit.

So we can either:

  1. Assume that previous commit's subject line was previously validated and do nothing further; or,
  2. Validate the remainder of the commit's subject line as is.

This specific implementation opts for the latter.

Resolves #392

If fixups are allowed, then the remainder of the commit message ought to
either be either a previous commit's subject line, or a hash:

> If a commit message starts with "squash! ", "fixup! " or "amend! ", the remainder of the subject line is taken as a commit specifier, which matches a previous commit if it matches the subject line or the hash of that commit.

So we can either:

1. Assume that previous commit's subject line was previously validated
and do nothing further; or,
2. Validate the remainder of the commit's subject line as is.

This specific implementation opts for the latter.

Signed-off-by: JP-Ellis <[email protected]>
@JP-Ellis JP-Ellis mentioned this pull request Sep 19, 2024
@@ -326,6 +327,14 @@ pub(crate) fn check_fixup(
}
}

pub(crate) fn strip_fixup(message: &str) -> &str {
if let Some(message) = message.strip_prefix("fixup! ") {
Copy link
Collaborator

Choose a reason for hiding this comment

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

This has a semantic conflict with #395

Copy link
Author

Choose a reason for hiding this comment

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

I'm sorry, I was targeting the main branch when creating this, and therefore ensured that semantics are consistent with the target. It would be non-atomic to have the work on this PR rely on another as-yet unmerged PR.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Posting multiple PRs that will conflict when merged in non-obvious ways is not helpful and is depending on the maintainer to catch something that was known.

In a case like this, you can always wait.

Copy link
Author

Choose a reason for hiding this comment

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

While I understand that this PR has a semantic conflict with #395, I have had no indication of whether #395 will be merged. Therefore, it seemed best to ensure this PR aligns with the current state of the master branch.

In my experience, it's not uncommon to have PRs that may need adjustments as other related PRs are merged. This ensures that each change is reviewed and integrated based on its own merits and the current state of the target branch. Furthermore, having a PR be created for visibility is, in my experience, better than relying on contributors waiting before adding further improvements.

I also split up my PRs based on your earlier feedback. The boundary between "atomic" commits and PRs can sometimes be nuanced. The functionality to strip the prefix is distinct from the changes introduced in #395, which is why they were separated.

If or when it comes to merging this PR in due time, the necessary adjustments can be made based on the state of the master branch at that time.

Copy link
Collaborator

Choose a reason for hiding this comment

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

In my experience, it's not uncommon to have PRs that may need adjustments as other related PRs are merged.

I understand that and don't have a problem with it. What I am concerned about is the lack of communication on that front. The relationship of the PRs needs to be made clear.

Furthermore, having a PR be created for visibility is, in my experience, better than relying on contributors waiting before adding further improvements.

There are multiple ways of handling that. One is splitting where you can, like you did here. The other is communicating it. You did that by talking about this in the issue and you can foreshadow that in a PR description.

@coveralls
Copy link

Pull Request Test Coverage Report for Build 10936396451

Details

  • 0 of 5 (0.0%) changed or added relevant lines in 1 file are covered.
  • 1 unchanged line in 1 file lost coverage.
  • Overall coverage decreased (-0.06%) to 5.455%

Changes Missing Coverage Covered Lines Changed/Added Lines %
crates/committed/src/checks.rs 0 5 0.0%
Files with Coverage Reduction New Missed Lines %
crates/committed/src/checks.rs 1 2.07%
Totals Coverage Status
Change from base Build 10906075176: -0.06%
Covered Lines: 24
Relevant Lines: 440

💛 - Coveralls

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.

Allow for fixup! {conventional}
3 participants