Skip to content

Commit

Permalink
fresh start
Browse files Browse the repository at this point in the history
  • Loading branch information
ItamarYuran committed Sep 12, 2024
1 parent 35455b2 commit d2c2a5f
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions cmd/lakectl/cmd/log.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,19 @@ func (d *dotWriter) Write(commits []apigen.Commit) {
}
}

// filter merge commits, used for --no-merges flag
func filterMergeCommits(commits []apigen.Commit) []apigen.Commit {
var filteredCommits []apigen.Commit

// iterating through data.Commit, appending every instance with 1 or less parents.
for _, commit := range commits {
if len(commit.Parents) <= 1 {
filteredCommits = append(filteredCommits, commit)
}
}
return filteredCommits
}

// logCmd represents the log command
var logCmd = &cobra.Command{
Use: "log <branch URI>",
Expand All @@ -80,6 +93,7 @@ var logCmd = &cobra.Command{
limit := Must(cmd.Flags().GetBool("limit"))
since := Must(cmd.Flags().GetString("since"))
dot := Must(cmd.Flags().GetBool("dot"))
noMerges := Must(cmd.Flags().GetBool("no-merges"))
firstParent := Must(cmd.Flags().GetBool("first-parent"))
objects := Must(cmd.Flags().GetStringSlice("objects"))
prefixes := Must(cmd.Flags().GetStringSlice("prefixes"))
Expand Down Expand Up @@ -150,6 +164,9 @@ var logCmd = &cobra.Command{
After: pagination.NextOffset,
},
}
if noMerges {
data.Commits = filterMergeCommits(data.Commits)
}

if dot {
graph.Write(data.Commits)
Expand Down Expand Up @@ -177,6 +194,7 @@ func init() {
logCmd.Flags().String("after", "", "show results after this value (used for pagination)")
logCmd.Flags().Bool("dot", false, "return results in a dotgraph format")
logCmd.Flags().Bool("first-parent", false, "follow only the first parent commit upon seeing a merge commit")
logCmd.Flags().Bool("no-merges", false, "skip merge commits")
logCmd.Flags().Bool("show-meta-range-id", false, "also show meta range ID")
logCmd.Flags().StringSlice("objects", nil, "show results that contains changes to at least one path in that list of objects. Use comma separator to pass all objects together")
logCmd.Flags().StringSlice("prefixes", nil, "show results that contains changes to at least one path in that list of prefixes. Use comma separator to pass all prefixes together")
Expand Down

0 comments on commit d2c2a5f

Please sign in to comment.