- 
          
- 
                Notifications
    You must be signed in to change notification settings 
- Fork 256
feat(changelog): implement commit processing order as set of steps #1201
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
base: main
Are you sure you want to change the base?
Conversation
| Thanks for opening this pull request! Please check out our contributing guidelines! ⛰️ | 
| Codecov Report❌ Patch coverage is  
 Additional details and impacted files@@            Coverage Diff             @@
##             main    #1201      +/-   ##
==========================================
+ Coverage   43.65%   44.40%   +0.76%     
==========================================
  Files          22       22              
  Lines        1982     2025      +43     
==========================================
+ Hits          865      899      +34     
- Misses       1117     1126       +9     
 Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
 | 
| Yeah actually it seems to me that the initial behaviour and order is what I would expect to have. As I said, right now the commits are treated as one during preprocessing even if the  | 
| Thanks for checking. I'd lean towards making this configurable instead of changing the behavior again. We could maybe add a new  [git]
processing_order = ["preprocess", "split", "proces", "postprocess", "etc"]So that you can configure the behavior. What do you think? | 
| I like it! | 
| How many processing steps do we have?. I see  | 
| I assume the current step names like  | 
| I agree. I would suggest we use similar (if not same) names as they are defined in the cliff.toml (e.g.  | 
| 
 Yes, very good point. I'd like that 👍🏼 
 Great, thank you! Let me know if you need any help/guidance in the meantime. I think we should also update the title of this PR accordingly :D | 
| Ok I found some time today I came up with this. Maybe there is still some cleanup to do as this makes git-cliff/git-cliff-core/src/commit.rs Line 208 in c156fc5 
 | 
41e3e8a    to
    98fc267      
    Compare
  
    | @orhun Any follow up on this?. I would like to have this functionality merged | 
| fn process_commit_list(commits: &mut Vec<Commit<'a>>, git_config: &GitConfig) -> Result<()> { | ||
| for step in &git_config.processing_order.order { | ||
| match step { | ||
| ProcessingStep::CommitParsers => { | ||
| debug!("Applying commit parsers..."); | ||
| *commits = Self::apply_commit_parsers(commits, git_config); | ||
| } | ||
| ProcessingStep::CommitPreprocessors => { | ||
| debug!("Applying commit preprocessors..."); | ||
| *commits = Self::apply_commit_preprocessors(commits, git_config); | ||
| } | ||
| ProcessingStep::IntoConventional => { | ||
| debug!("Converting commits to conventional format..."); | ||
| *commits = Self::apply_into_conventional(commits, git_config); | ||
| } | ||
| ProcessingStep::LinkParsers => { | ||
| debug!("Applying link parsers..."); | ||
| *commits = Self::apply_link_parsers(commits, git_config); | ||
| } | ||
| ProcessingStep::SplitCommits => { | ||
| debug!("Splitting commits..."); | ||
| if git_config.split_commits { | ||
| *commits = Self::apply_split_commits(commits); | ||
| } else { | ||
| debug!("Split commits is disabled, skipping..."); | ||
| } | ||
| } | ||
| } | ||
| } | 
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.
A thing to keep in mind is that if all the steps are not listed in the config they will be skipped. So maybe we need to check that the list always contains all the steps (no matter the order)
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.
Another important point: since there are already issues arising from the interactions of repository and directory-related configs, I think we should be very careful about introducing new functionality into the config. Both the necessity and the exact specification should be carefully evaluated before adding more to this area.
| /// Processing steps for the commits | ||
| #[derive(Debug, Clone, Serialize, Deserialize)] | ||
| #[serde(rename_all = "snake_case")] | ||
| pub enum ProcessingStep { | 
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.
Suggestions:
- Make the enum variant names and config keys consistent and explicit about what the slot does. Prefer either explicit Verb + Object action names or neutral stage names so the intent is clear. Example mappings:
- CommitParsers->- ParseCommits
- CommitPreprocessors->- ModifyCommits
- IntoConventional->- ConventionalizeCommitsor- NormalizeCommits
- LinkParsers->- ParseLinks
- SplitCommits->- SplitCommits
- Rename CommitPreprocessorsto a name that reflects it being an ordering slot rather than implying it always runs "before" something. Options:
- If message transformations/modification are the main behavior: TransformCommitsorModifyCommits.
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.
Thx for the suggestions, I think it is indeed nice to have consistent naming. However I think the naming is more a fundamental change as I am using the current naming definitions from the configuration (see https://git-cliff.org/docs/configuration/git). I can indeed modify the names with the caveat of using multiple names for the same (e.g. ModifyCommits in place of CommitPreprocessors for this step https://git-cliff.org/docs/configuration/git#commit_preprocessors).
It seems that @orhun agreed on using the same names as in the config.toml (#1201 (comment)).
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.
Yup, I think it makes more sense to use the names that we are already familiar.
| 
 I tend to agree, but in this case the idea is to keep feature parity and backwards comparability in case the  | 
| Sorry for the delay on this... but most things look good already. Just need to find some time to do proper review. Pretty excited for this one Btw can you fix the conflicts with  | 
Description
Currently each commit in the commit list is processed before splitting. This causes an issue when
split_commitis set to true. Commits in the description are not being processed if the commit message contains a skipped type set in thecommit_parsers. For instance if the output of a squash and merge start with achore:and thechore:is set to skip in thecommit_parsersthe description won't be parsed even if it containsfeat:orfix:or any other non skipped field.Motivation and Context
When working with squash and merge it is useful to have the message of the commit as the overview of the changes and the description as the details of the changes. However it should be possible to skip parsing the message as the description of the commit contains all the info, so trying to avoid repetitions.
How Has This Been Tested?
I have adjusted the current unit test to reflect the scenario that I am describing
Types of Changes
Checklist: