NameStagingDirectory assigns a name that matches the package source information
(source, branch, sha string)
| 358 | |
| 359 | // NameStagingDirectory assigns a name that matches the package source information |
| 360 | func NameStagingDirectory(source, branch, sha string) string { |
| 361 | // Using tags may result in references like /refs/tags/version |
| 362 | // To avoid creating additional directory's use only the last name after a / |
| 363 | splitBranch := strings.Split(branch, "/") |
| 364 | splitSha := strings.Split(sha, "/") |
| 365 | reducedBranch := splitBranch[len(splitBranch)-1] |
| 366 | reducedSha := splitSha[len(splitSha)-1] |
| 367 | |
| 368 | // The branch and sha may not always be known simultaneously |
| 369 | // In these cases the values will be the same. Collapse these references |
| 370 | // when this occurs to avoid confusion/duplicate info. |
| 371 | // This occurs during a remote target operation for example. |
| 372 | if reducedBranch == reducedSha { |
| 373 | return fmt.Sprintf("%s-%s", |
| 374 | source, |
| 375 | reducedBranch) |
| 376 | } |
| 377 | return fmt.Sprintf("%s-%s-%s", |
| 378 | source, |
| 379 | reducedBranch, |
| 380 | shortSha(reducedSha)) |
| 381 | } |