Skip to content

Commit

Permalink
fix exclude
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaelEischer committed Nov 6, 2023
1 parent e8700ff commit 3a63c60
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 9 deletions.
4 changes: 2 additions & 2 deletions example.sync.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,10 @@ filters:
- name: DeclinedEvents
# Events which cover the full day aren't synced
- name: AllDayEvents
# Exlude Events which match the following regular expression, syntax here: https://github.com/google/re2/wiki/Syntax
# Exclude Events which match the following regular expression, syntax here: https://github.com/google/re2/wiki/Syntax
- name: RegexTitle
config:
ExludeRegexp: ".*test"
ExcludeRegexp: ".*test"

# Perform multiple calendar updates concurrently
# Defaults to 1 if not set
Expand Down
8 changes: 4 additions & 4 deletions internal/filter/regexTitle.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
)

type RegexTitle struct {
ExludeRegexp string
ExcludeRegexp string
}

func (a RegexTitle) Name() string {
Expand All @@ -18,14 +18,14 @@ func (a RegexTitle) Name() string {

func (a RegexTitle) Filter(event models.Event) bool {

if len(a.ExludeRegexp) == 0 {
if len(a.ExcludeRegexp) == 0 {
log.Debugf("Regular Expression is empty, skipping Filter %s for event: %s", a.Name(), event.Title)
return true
}

log.Debugf("Running Regexp %s on event title: %s", a.ExludeRegexp, event.Title)
log.Debugf("Running Regexp %s on event title: %s", a.ExcludeRegexp, event.Title)

r, err := regexp.Compile(a.ExludeRegexp)
r, err := regexp.Compile(a.ExcludeRegexp)
if err != nil {
log.Fatalf("Regular expression of Filter %s is not valid, please check", a.Name())
}
Expand Down
4 changes: 2 additions & 2 deletions internal/filter/regexTitle_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ func TestRegexTitleFilter(t *testing.T) {
expectedSinkEvents := []models.Event{sourceEvents[1], sourceEvents[2]}

eventFilter := filter.RegexTitle{
ExludeRegexp: ".*test",
ExcludeRegexp: ".*test",
}
checkEventFilter(t, eventFilter, sourceEvents, expectedSinkEvents)
}
Expand All @@ -44,7 +44,7 @@ func TestRegexTitleFilterEmptyRegex(t *testing.T) {
expectedSinkEvents := sourceEvents

eventFilter := filter.RegexTitle{
ExludeRegexp: "",
ExcludeRegexp: "",
}
checkEventFilter(t, eventFilter, sourceEvents, expectedSinkEvents)
}
2 changes: 1 addition & 1 deletion internal/filter/util_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
)

// FilterEvents takes an array of events and a filter and executes the .Filter Method on each of the sourceEvents
// Not exluded events get returned in the filteredEvents
// Not excluded events get returned in the filteredEvents
func FilterEvents(sourceEvents []models.Event, filter sync.Filter) (filteredEvents []models.Event) {
for _, event := range sourceEvents {
if filter.Filter(event) {
Expand Down

0 comments on commit 3a63c60

Please sign in to comment.