-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improve
cmtc install
error messages/remove unused code (#241)
* Improve `cmtc install` error messages/remove unused code * Add extra target folder validation on cmta commands - `cmta linearize` was missing target folder validation altogether - Added target folder validation on `cmta studentify` and `cmta linearize` commands * Better naming
- Loading branch information
Showing
4 changed files
with
38 additions
and
14 deletions.
There are no files selected for viewing
20 changes: 20 additions & 0 deletions
20
cmta/src/main/scala/com/lunatech/cmt/admin/TargetFolderValidation.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package com.lunatech.cmt.admin | ||
|
||
import com.lunatech.cmt.CmtError | ||
import java.io.File | ||
import com.lunatech.cmt.toExecuteCommandErrorMessage | ||
|
||
def validateDestinationFolder(mainRepository: File, destination: File): Either[CmtError, Unit] = | ||
val canonicalTarget = destination.getCanonicalPath | ||
val canonicalMainRepository = mainRepository.getCanonicalPath | ||
val destinationEqualsMainRepository = canonicalTarget == canonicalMainRepository | ||
val destinationIsSubfolderOfmainRepository = | ||
canonicalTarget.startsWith(canonicalMainRepository) | ||
(destinationEqualsMainRepository, destinationIsSubfolderOfmainRepository) match { | ||
case (true, _) => | ||
Left("destination folder cannot be the same as the main repository root folder".toExecuteCommandErrorMessage) | ||
case (_, true) => | ||
Left("destination folder cannot be a subfolder of the main repository".toExecuteCommandErrorMessage) | ||
case _ => | ||
Right(()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters