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 options allowing to select how the log is extracted (cut branches) #321

Open
eburghar opened this issue Sep 28, 2023 · 4 comments · May be fixed by #324
Open

Add options allowing to select how the log is extracted (cut branches) #321

eburghar opened this issue Sep 28, 2023 · 4 comments · May be fixed by #324
Assignees
Labels
enhancement New feature or request

Comments

@eburghar
Copy link

eburghar commented Sep 28, 2023

Is your feature request related to a problem? Please describe.

If you have feature branches and don't want to squash them before merging, considering that cog for now is following the whole commit tree, you end up with some details in your history you don't want necessarily in you CHANGELOG.md.

git log has specific options for this use case (--merges, --first-parent, ...)

Describe the solution you'd like

Add a --first-parent option like git log --first-parent that only consider the active branch when looking for changes.

Describe alternatives you've considered

If you only follow conventional commit on your main branch and not in your feature branch you can achieve the same effect at the expense of phony error messages, but you loose the ability of generating a myfeature.md which is useful if you want a detailed log about a user story that is tracked by the same feature branch.

Additional context

Requirement in SAFE methodology

@eburghar eburghar added the enhancement New feature or request label Sep 28, 2023
@eburghar eburghar changed the title [FEATURE] Add options allowing to select how the log is extracted (cut branches) Sep 28, 2023
@oknozor
Copy link
Collaborator

oknozor commented Oct 5, 2023

Hey @eburghar,
That would be an interesting option indeed. Not sure if we want both --merges and --first-parent tho. Maybe --first-parent would be enough since I am also planing to add a feature to ignore non conventional commit and add them in a misc section in the generated changelog.
Thought ?

@eburghard
Copy link

Thanks @oknozor for your interest. Yes, --first-parent would be enough. I just stated --merges as another git log flag, but it was not relevant for the aforementioned use case. If you can point a rough direction to start an implementation I can even try to send you a PR.

@oknozor
Copy link
Collaborator

oknozor commented Oct 6, 2023

General guidelines

First you can get some general info about how to write test and setup the project here: https://github.com/cocogitto/cocogitto/blob/main/CONTRIBUTING.md

Implementing the feature

The current implementation uses git2::Repository::revwalk to explore the commit tree:

fn get_commit_range_from_spec(&self, spec: &str) -> Result<Vec<Commit>, Git2Error> {

You need to create an alternate method to get only the commit first parent using recursion on git2::Commit::parent. Note that it still support the RevSpecPattern used by the current implementation. Trying to reach a commit that's not in the flat (first-parent) tree should produce an error .

Once this is done a --first-parent flag needs to be added to the relevant cli subcommands (check, log, edit, changelog, bump).

I am not sure if this is needed but it might be interesting to add a cog.toml attribute to make --first-parent the default behavior

@eburghar
Copy link
Author

eburghar commented Oct 7, 2023

note that revwalk has a simplify_first_parent, so the implementation should be pretty straightforward.

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

Successfully merging a pull request may close this issue.

3 participants