Skip to content

Commit 3a995f9

Browse files
committed
Move GitFetch and GitCommit content enforcement back to Parse2822 (since they have a different format when coming from line-based legacy files)
1 parent 187e703 commit 3a995f9

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

manifest/rfc2822.go

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -161,12 +161,6 @@ func (manifest *Manifest2822) AddEntry(entry Manifest2822Entry) error {
161161
if entry.GitRepo == "" || entry.GitFetch == "" || entry.GitCommit == "" {
162162
return fmt.Errorf("Tags %q missing one of GitRepo, GitFetch, or GitCommit", entry.TagsString())
163163
}
164-
if !GitFetchRegex.MatchString(entry.GitFetch) {
165-
return fmt.Errorf(`Tags %q has invalid GitFetch (must be "refs/heads/..." or "refs/tags/..."): %q`, entry.TagsString(), entry.GitFetch)
166-
}
167-
if !GitCommitRegex.MatchString(entry.GitCommit) {
168-
return fmt.Errorf(`Tags %q has invalid GitCommit (must be a commit, not a tag or ref): %q`, entry.TagsString(), entry.GitCommit)
169-
}
170164
if invalidMaintainers := entry.InvalidMaintainers(); len(invalidMaintainers) > 0 {
171165
return fmt.Errorf("Tags %q has invalid Maintainers: %q (expected format %q)", strings.Join(invalidMaintainers, ", "), MaintainersFormat)
172166
}
@@ -270,6 +264,13 @@ func Parse2822(readerIn io.Reader) (*Manifest2822, error) {
270264
return nil, err
271265
}
272266

267+
if !GitFetchRegex.MatchString(entry.GitFetch) {
268+
return fmt.Errorf(`Tags %q has invalid GitFetch (must be "refs/heads/..." or "refs/tags/..."): %q`, entry.TagsString(), entry.GitFetch)
269+
}
270+
if !GitCommitRegex.MatchString(entry.GitCommit) {
271+
return fmt.Errorf(`Tags %q has invalid GitCommit (must be a commit, not a tag or ref): %q`, entry.TagsString(), entry.GitCommit)
272+
}
273+
273274
err = manifest.AddEntry(entry)
274275
if err != nil {
275276
return nil, err

0 commit comments

Comments
 (0)