( displayName string, rawRef *RawRef, )
| 330 | } |
| 331 | |
| 332 | func (a *refParser) validateRawRef( |
| 333 | displayName string, |
| 334 | rawRef *RawRef, |
| 335 | ) error { |
| 336 | // probably move everything below this point to a new function, perhaps called validateRawRef |
| 337 | if rawRef.Format == "" { |
| 338 | return NewFormatCannotBeDeterminedError(displayName) |
| 339 | } |
| 340 | _, gitOK := a.gitFormatToInfo[rawRef.Format] |
| 341 | archiveFormatInfo, archiveOK := a.archiveFormatToInfo[rawRef.Format] |
| 342 | _, singleOK := a.singleFormatToInfo[rawRef.Format] |
| 343 | if gitOK { |
| 344 | if rawRef.GitBranch != "" && rawRef.GitCommitOrTag != "" { |
| 345 | return NewCannotSpecifyGitBranchAndCommitOrTagError() |
| 346 | } |
| 347 | if rawRef.GitRef != "" && rawRef.GitCommitOrTag != "" { |
| 348 | return NewCannotSpecifyCommitOrTagWithRefError() |
| 349 | } |
| 350 | } else { |
| 351 | if rawRef.GitBranch != "" || rawRef.GitCommitOrTag != "" || rawRef.GitRef != "" || rawRef.GitRecurseSubmodules || rawRef.GitDepth > 0 { |
| 352 | return NewOptionsInvalidForFormatError(rawRef.Format, displayName, "git options set") |
| 353 | } |
| 354 | } |
| 355 | // not an archive format |
| 356 | if !archiveOK { |
| 357 | if rawRef.ArchiveStripComponents > 0 { |
| 358 | return NewOptionsInvalidForFormatError(rawRef.Format, displayName, "archive options set") |
| 359 | } |
| 360 | } else { |
| 361 | if archiveFormatInfo.archiveType == ArchiveTypeZip && rawRef.CompressionType != 0 { |
| 362 | return NewCannotSpecifyCompressionForZipError() |
| 363 | } |
| 364 | } |
| 365 | if !singleOK && !archiveOK { |
| 366 | if rawRef.CompressionType != 0 { |
| 367 | return NewOptionsInvalidForFormatError(rawRef.Format, displayName, "compression set") |
| 368 | } |
| 369 | } |
| 370 | if !archiveOK && !gitOK { |
| 371 | if rawRef.SubDirPath != "" { |
| 372 | return NewOptionsInvalidForFormatError(rawRef.Format, displayName, "subdir set") |
| 373 | } |
| 374 | } |
| 375 | return nil |
| 376 | } |
| 377 | |
| 378 | // empty value is an error |
| 379 | func parseCompressionType(value string) (CompressionType, error) { |
no test coverage detected