diff options
Diffstat (limited to 'internal/git2go/signature.go')
-rw-r--r-- | internal/git2go/signature.go | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/internal/git2go/signature.go b/internal/git2go/signature.go new file mode 100644 index 000000000..79306c051 --- /dev/null +++ b/internal/git2go/signature.go @@ -0,0 +1,27 @@ +package git2go + +import ( + "strings" + "time" +) + +var signatureSanitizer = strings.NewReplacer("\n", "", "<", "", ">", "") + +// Signature represents a commits signature. +type Signature struct { + // Name of the author or the committer. + Name string + // Email of the author or the committer. + Email string + // When is the time of the commit. + When time.Time +} + +// NewSignature creates a new sanitized signature. +func NewSignature(name, email string, when time.Time) Signature { + return Signature{ + Name: signatureSanitizer.Replace(name), + Email: signatureSanitizer.Replace(email), + When: when.Truncate(time.Second), + } +} |