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

feat: adding a delete_event #340

Merged
merged 18 commits into from
Jan 11, 2024

fixing tests

55b5ef3
Select commit
Loading
Failed to load commit list.
Sign in for the full log view
Merged

feat: adding a delete_event #340

fixing tests
55b5ef3
Select commit
Loading
Failed to load commit list.
GitHub Actions / golangci failed Dec 29, 2023 in 0s

reviewdog [golangci] report

reported by reviewdog 🐶

Findings (4)

library/actions/delete.go|3| 3-83 lines are duplicate of library/actions/push.go:4-84 (dupl)
library/actions/delete_test.go|103 col 2| redefines-builtin-id: redefinition of the built-in function delete (revive)
library/events_test.go|158 col 2| redefines-builtin-id: redefinition of the built-in function delete (revive)
library/repo.go|827 col 2| naked return in func EventAllowed with 31 lines of code (nakedret)

Filtered Findings (0)

Annotations

Check failure on line 3 in library/actions/delete.go

See this annotation in the file changed.

@github-actions github-actions / golangci

[golangci] library/actions/delete.go#L3

3-83 lines are duplicate of `library/actions/push.go:4-84` (dupl)
Raw output
library/actions/delete.go:3: 3-83 lines are duplicate of `library/actions/push.go:4-84` (dupl)
package actions

import "github.com/go-vela/types/constants"

// Delete is the library representation of the various actions associated
// with the delete event webhook from the SCM.
type Delete struct {
	Branch *bool `json:"branch"`
	Tag    *bool `json:"tag"`
}

// FromMask returns the Delete type resulting from the provided integer mask.
func (a *Delete) FromMask(mask int64) *Delete {
	a.SetBranch(mask&constants.AllowDeleteBranch > 0)
	a.SetTag(mask&constants.AllowDeleteTag > 0)

	return a
}

// ToMask returns the integer mask of the values for the Delete set.
func (a *Delete) ToMask() int64 {
	mask := int64(0)

	if a.GetBranch() {
		mask = mask | constants.AllowDeleteBranch
	}

	if a.GetTag() {
		mask = mask | constants.AllowDeleteTag
	}

	return mask
}

// GetBranch returns the Branch field from the provided Delete. If the object is nil,
// or the field within the object is nil, it returns the zero value instead.
func (a *Delete) GetBranch() bool {
	// return zero value if Delete type or Branch field is nil
	if a == nil || a.Branch == nil {
		return false
	}

	return *a.Branch
}

// GetTag returns the Tag field from the provided Delete. If the object is nil,
// or the field within the object is nil, it returns the zero value instead.
func (a *Delete) GetTag() bool {
	// return zero value if Delete type or Tag field is nil
	if a == nil || a.Tag == nil {
		return false
	}

	return *a.Tag
}

// SetBranch sets the Delete Branch field.
//
// When the provided Delete type is nil, it
// will set nothing and immediately return.
func (a *Delete) SetBranch(v bool) {
	// return if Events type is nil
	if a == nil {
		return
	}

	a.Branch = &v
}

// SetTag sets the Delete Tag field.
//
// When the provided Delete type is nil, it
// will set nothing and immediately return.
func (a *Delete) SetTag(v bool) {
	// return if Events type is nil
	if a == nil {
		return
	}

	a.Tag = &v
}

Check failure on line 103 in library/actions/delete_test.go

See this annotation in the file changed.

@github-actions github-actions / golangci

[golangci] library/actions/delete_test.go#L103

redefines-builtin-id: redefinition of the built-in function delete (revive)
Raw output
library/actions/delete_test.go:103:2: redefines-builtin-id: redefinition of the built-in function delete (revive)
	delete := new(Delete)
	^

Check failure on line 158 in library/events_test.go

See this annotation in the file changed.

@github-actions github-actions / golangci

[golangci] library/events_test.go#L158

redefines-builtin-id: redefinition of the built-in function delete (revive)
Raw output
library/events_test.go:158:2: redefines-builtin-id: redefinition of the built-in function delete (revive)
	delete := new(actions.Delete)
	^

Check failure on line 827 in library/repo.go

See this annotation in the file changed.

@github-actions github-actions / golangci

[golangci] library/repo.go#L827

naked return in func `EventAllowed` with 31 lines of code (nakedret)
Raw output
library/repo.go:827:2: naked return in func `EventAllowed` with 31 lines of code (nakedret)
	return
	^