forked from
tangled.org/core
fork
Configure Feed
Select the types of activity you want to include in your feed.
Monorepo for Tangled
fork
Configure Feed
Select the types of activity you want to include in your feed.
1package validator
2
3import (
4 "fmt"
5 "strings"
6
7 "tangled.org/core/patchutil"
8)
9
10func (v *Validator) ValidatePatch(patch *string) error {
11 if patch == nil || *patch == "" {
12 return fmt.Errorf("patch is empty")
13 }
14
15 // add newline if not present to diff style patches
16 if !patchutil.IsFormatPatch(*patch) && !strings.HasSuffix(*patch, "\n") {
17 *patch = *patch + "\n"
18 }
19
20 if err := patchutil.IsPatchValid(*patch); err != nil {
21 return err
22 }
23
24 return nil
25}