aboutsummaryrefslogtreecommitdiffstats
path: root/options.go
diff options
context:
space:
mode:
Diffstat (limited to 'options.go')
-rw-r--r--options.go8
1 files changed, 7 insertions, 1 deletions
diff --git a/options.go b/options.go
index 6b00b0d..ed0baa3 100644
--- a/options.go
+++ b/options.go
@@ -3,6 +3,7 @@ package git
import (
"errors"
"regexp"
+ "strings"
"golang.org/x/crypto/openpgp"
"gopkg.in/src-d/go-git.v4/config"
@@ -389,7 +390,9 @@ var (
type TagObjectOptions struct {
// Tagger defines the signature of the tag creator.
Tagger *object.Signature
- // Message defines the annotation of the tag.
+ // Message defines the annotation of the tag. It is canonicalized during
+ // validation into the format expected by git - no leading whitespace and
+ // ending in a newline.
Message string
// TargetType is the object type of the target. The object specified by
// Target must be of this type.
@@ -409,6 +412,9 @@ func (o *TagObjectOptions) Validate(r *Repository, hash plumbing.Hash) error {
return ErrMissingMessage
}
+ // Canonicalize the message into the expected message format.
+ o.Message = strings.TrimSpace(o.Message) + "\n"
+
if o.TargetType == plumbing.InvalidObject || o.TargetType == plumbing.AnyObject {
return ErrBadObjectType
}