@@ -657,39 +657,39 @@ func (m *webhookNotifier) applyWebhookPayloadOptimizations(ctx context.Context,
657657 }
658658
659659 // Check if any webhook has payload optimization options enabled
660- hasFilesLimit := - 1
661- hasCommitsLimit := - 1
660+ hasFilesLimit := 0
661+ hasCommitsLimit := 0
662662 for _ , webhook := range webhooks {
663663 if webhook .HasEvent (webhook_module .HookEventPush ) {
664- if webhook .ExcludeFilesLimit > = 0 && (hasFilesLimit == - 1 || webhook .ExcludeFilesLimit < hasFilesLimit ) {
664+ if webhook .ExcludeFilesLimit ! = 0 && (hasFilesLimit == 0 || webhook .ExcludeFilesLimit < hasFilesLimit ) {
665665 hasFilesLimit = webhook .ExcludeFilesLimit
666666 }
667- if webhook .ExcludeCommitsLimit > = 0 && (hasCommitsLimit == - 1 || webhook .ExcludeCommitsLimit < hasCommitsLimit ) {
667+ if webhook .ExcludeCommitsLimit ! = 0 && (hasCommitsLimit == 0 || webhook .ExcludeCommitsLimit < hasCommitsLimit ) {
668668 hasCommitsLimit = webhook .ExcludeCommitsLimit
669669 }
670670 }
671671 }
672672
673673 // Apply payload optimizations based on webhook configurations
674- // -1 not trim, 0 trim all (none kept), >0 trim to N commits
675- if hasFilesLimit != - 1 {
674+ // -1 trim all (none kept), 0 do not trim , >0 trim to N commits
675+ if hasFilesLimit != 0 {
676676 for _ , commit := range apiCommits {
677677 if commit .Added != nil {
678- if hasFilesLimit == 0 {
678+ if hasFilesLimit == - 1 {
679679 commit .Added = nil
680680 } else if hasFilesLimit > 0 && len (commit .Added ) > hasFilesLimit {
681681 commit .Added = commit .Added [:hasFilesLimit ]
682682 }
683683 }
684684 if commit .Removed != nil {
685- if hasFilesLimit == 0 {
685+ if hasFilesLimit == - 1 {
686686 commit .Removed = nil
687687 } else if hasFilesLimit > 0 && len (commit .Removed ) > hasFilesLimit {
688688 commit .Removed = commit .Removed [:hasFilesLimit ]
689689 }
690690 }
691691 if commit .Modified != nil {
692- if hasFilesLimit == 0 {
692+ if hasFilesLimit == - 1 {
693693 commit .Modified = nil
694694 } else if hasFilesLimit > 0 && len (commit .Modified ) > hasFilesLimit {
695695 commit .Modified = commit .Modified [:hasFilesLimit ]
@@ -698,21 +698,21 @@ func (m *webhookNotifier) applyWebhookPayloadOptimizations(ctx context.Context,
698698 }
699699 if apiHeadCommit != nil {
700700 if apiHeadCommit .Added != nil {
701- if hasFilesLimit == 0 {
701+ if hasFilesLimit == - 1 {
702702 apiHeadCommit .Added = nil
703703 } else if hasFilesLimit > 0 && len (apiHeadCommit .Added ) > hasFilesLimit {
704704 apiHeadCommit .Added = apiHeadCommit .Added [:hasFilesLimit ]
705705 }
706706 }
707707 if apiHeadCommit .Removed != nil {
708- if hasFilesLimit == 0 {
708+ if hasFilesLimit == - 1 {
709709 apiHeadCommit .Removed = nil
710710 } else if hasFilesLimit > 0 && len (apiHeadCommit .Removed ) > hasFilesLimit {
711711 apiHeadCommit .Removed = apiHeadCommit .Removed [:hasFilesLimit ]
712712 }
713713 }
714714 if apiHeadCommit .Modified != nil {
715- if hasFilesLimit == 0 {
715+ if hasFilesLimit == - 1 {
716716 apiHeadCommit .Modified = nil
717717 } else if hasFilesLimit > 0 && len (apiHeadCommit .Modified ) > hasFilesLimit {
718718 apiHeadCommit .Modified = apiHeadCommit .Modified [:hasFilesLimit ]
@@ -721,8 +721,8 @@ func (m *webhookNotifier) applyWebhookPayloadOptimizations(ctx context.Context,
721721 }
722722 }
723723
724- if hasCommitsLimit != - 1 {
725- if hasCommitsLimit == 0 {
724+ if hasCommitsLimit != 0 {
725+ if hasCommitsLimit == - 1 {
726726 apiCommits = nil
727727 } else if hasCommitsLimit > 0 && len (apiCommits ) > hasCommitsLimit {
728728 apiCommits = apiCommits [:hasCommitsLimit ]
0 commit comments