Skip to content

Commit

Permalink
feat: remove non first parent on revwalk based on settings
Browse files Browse the repository at this point in the history
  • Loading branch information
Éric BURGHARD committed Oct 7, 2023
1 parent 5b34ee4 commit 606d831
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/git/revspec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,9 @@ impl Repository {
pub fn all_commits(&self) -> Result<CommitRange, Git2Error> {
let mut revwalk = self.0.revwalk()?;
revwalk.push_head()?;
if SETTINGS.only_first_parent {
revwalk.simplify_first_parent()?;
}
let mut commits = vec![];

for oid in revwalk {
Expand Down Expand Up @@ -331,6 +334,9 @@ impl Repository {
let mut revwalk = self.0.revwalk()?;

revwalk.push_range(spec)?;
if SETTINGS.only_first_parent {
revwalk.simplify_first_parent()?;
}

let mut commits: Vec<Commit> = vec![];

Expand Down
2 changes: 2 additions & 0 deletions src/settings/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ pub struct Settings {
pub from_latest_tag: bool,
pub ignore_merge_commits: bool,
pub generate_mono_repository_global_tag: bool,
pub only_first_parent: bool,
pub monorepo_version_separator: Option<String>,
pub branch_whitelist: Vec<String>,
pub tag_prefix: Option<String>,
Expand All @@ -55,6 +56,7 @@ impl Default for Settings {
from_latest_tag: false,
ignore_merge_commits: false,
generate_mono_repository_global_tag: true,
only_first_parent: false,
monorepo_version_separator: None,
branch_whitelist: vec![],
tag_prefix: None,
Expand Down

0 comments on commit 606d831

Please sign in to comment.