-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add option to skipp or overwrite all mapped paths when importing a di…
…rectory
- Loading branch information
Showing
2 changed files
with
45 additions
and
6 deletions.
There are no files selected for viewing
49 changes: 44 additions & 5 deletions
49
src/Squot.package/SquotAssetBrowser.class/instance/importDirectory..st
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 |
---|---|---|
@@ -1,8 +1,47 @@ | ||
importing | ||
importDirectory: aReference | ||
| basePath | | ||
basePath := (self | ||
requestPathWithSuffix: nil | ||
title: 'Base path for assets in the repository:') ifNil: [^ self]. | ||
| optionIfMapped basePath | | ||
optionIfMapped := nil. | ||
basePath := self initialPathRequestAnswerWithSuffix: nil. | ||
[| askAgain mappedPaths | | ||
basePath := (SquotPathUtilities | ||
requestAbsolute: 'Base path for assets in the repository:' | ||
initialAnswer: basePath) | ||
ifNil: [^ self]. | ||
askAgain := false. | ||
mappedPaths := ((aReference allFiles | ||
collect: [:each | basePath resolve: (each path relativeTo: aReference path)]) | ||
reject: [:each | self activeWorkingCopy isUnmappedPath: each]) | ||
collect: [:each | SquotPathUtilities asString: each]. | ||
mappedPaths ifNotEmpty: [| answer | | ||
answer := UIManager default | ||
chooseOptionFrom: { | ||
'Choose a different base path'. | ||
'Skip taken paths'. | ||
'Overwrite taken paths (if possible)'. | ||
'Ask for each taken path'. | ||
'Cancel'. | ||
} | ||
values: {#different. #skip. #overwrite. #ask. #cancel} | ||
title: (('{1} paths' format: {mappedPaths size}) asText | ||
addAttribute: (PluggableTextAttribute evalBlock: [ | ||
self inform: (mappedPaths joinSeparatedBy: String cr)]); | ||
yourself), ' inside the base path are already taken.'. | ||
answer caseOf: { | ||
[#different] -> [askAgain := true]. | ||
[#skip] -> [optionIfMapped := #skip]. | ||
[#overwrite] -> [optionIfMapped := #overwrite]. | ||
[#ask] -> ["fall through"]. | ||
[#cancel] -> [^ self]. | ||
}]. | ||
askAgain] whileTrue. | ||
aReference allFiles do: [:each | | ||
self importFile: each getPath: [basePath resolve: (each path relativeTo: aReference path)]]. | ||
self importFile: each getPath: [| relativePath answer | | ||
relativePath := each path relativeTo: aReference path. | ||
answer := self activeWorkingCopy | ||
getUnmappedPathFrom: (basePath resolve: relativePath) | ||
withTitle: ('Path in the respository for the imported asset {1}:' format: {relativePath}) | ||
additionalOptions: {'Skip this file' -> #skip} | ||
optionIfMapped: [optionIfMapped]. | ||
answer ifNil: [^ self "cancel entire directory import"]. | ||
answer = #skip ifTrue: [nil] ifFalse: [answer]]]. |
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