Skip to content

Commit

Permalink
Update cmta/src/main/scala/com/lunatech/cmt/admin/command/New.scala
Browse files Browse the repository at this point in the history
Co-authored-by: Trevor Burton-McCreadie <[email protected]>
  • Loading branch information
eloots and thinkmorestupidless authored Jul 14, 2023
1 parent f3f7749 commit aa71124
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions cmta/src/main/scala/com/lunatech/cmt/admin/command/New.scala
Original file line number Diff line number Diff line change
Expand Up @@ -52,17 +52,22 @@ object New:
// list the contents of the ~/Courses directory, if there's anything already matching the
// name then get the count so we can append to the name and prevent conflicts
template <- options.template.value
existingFilesWithSameName = sbtio.listFiles(
configuration.coursesDirectory.value,
new FileFilter {
override def accept(file: File): Boolean =
file.name.startsWith(template.project)
})
discriminator = if (existingFilesWithSameName.size > 0) s"-${existingFilesWithSameName.size}" else ""
targetDirectoryName = s"${template.project}$discriminator"
template <- options.template.value
targetDirectoryName = createTargetDirectoryName()
newRepo <- newCmtRepoFromGithubProject(template, targetDirectoryName, configuration)
} yield newRepo

private def createTargetDirectoryName(): String = {
val existingFilesWithSameName = sbtio.listFiles(
configuration.coursesDirectory.value,
new FileFilter {
override def accept(file: File): Boolean =
file.name.startsWith(template.project)
})
val discriminator = if (existingFilesWithSameName.size > 0) s"-${existingFilesWithSameName.size}" else ""
s"${template.project}$discriminator"
}

private def cloneMainRepo(githubProject: GithubProject, tmpDir: File): Either[CmtError, TagSet] =
val project = githubProject.project
val organisation = githubProject.organisation
Expand Down

0 comments on commit aa71124

Please sign in to comment.