Skip to content

Commit

Permalink
Remove usage of categories in MCOrganizationDefinition
Browse files Browse the repository at this point in the history
Base the organization definition on packages and tags instead of categories.

#ensureMCClassOrganisationHasCorrectStructure: has been simplified because now the organization knows the package and we do not need to do magic to ensure we have the right one

IcePackageDefinition has been updated to use the package name and tag names instead of categories.

This change includes pharo-vcs#1728
  • Loading branch information
jecisc committed Sep 6, 2023
1 parent 1778263 commit 034d567
Show file tree
Hide file tree
Showing 3 changed files with 66 additions and 80 deletions.
61 changes: 17 additions & 44 deletions Iceberg-Plugin-Migration/IceConvertFormatAction.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -34,21 +34,9 @@ IceConvertFormatAction >> codeDirectoryWithDelim [

{ #category : #private }
IceConvertFormatAction >> ensureMCClassOrganisationHasCorrectStructure: mcVersion [
| organisation |

organisation := mcVersion snapshot definitions
detect: [ :each | each isOrganizationDefinition ].

(organisation categories size = 1) ifFalse: [ | baseCategory |
baseCategory := self
obtainCommonCategory: organisation categories first
from: organisation categories.
baseCategory ifEmpty: [
self error: 'I didn''t find a base category, something is wrong with the package definition' ].
baseCategory = organisation categories first ifFalse: [
organisation categories: (organisation categories copyWithFirst: baseCategory) ] ].

^ mcVersion
(mcVersion snapshot definitions detect: [ :each | each isOrganizationDefinition ]) packageName ifNil: [
self error: 'I have no package name in the organization definition' ]
]

{ #category : #private }
Expand All @@ -57,16 +45,14 @@ IceConvertFormatAction >> ensureMCVersionWithClassOrganisation: mcVersion [
only for extensions, we need to ensure it has one, otherwise package creation will
fail"

^ mcVersion snapshot definitions
detect: [ :each | each isClassDefinition ]
ifFound: [ :each | mcVersion ]
ifNone: [
MCVersion
package: mcVersion package
info: mcVersion info
snapshot: (MCSnapshot fromDefinitions: (
{ MCOrganizationDefinition categories: { mcVersion package name }},
mcVersion snapshot definitions)) ]
^ mcVersion snapshot definitions
detect: [ :each | each isClassDefinition ]
ifFound: [ :each | mcVersion ]
ifNone: [
MCVersion
package: mcVersion package
info: mcVersion info
snapshot: (MCSnapshot fromDefinitions: { (MCOrganizationDefinition packageName: mcVersion package name) } , mcVersion snapshot definitions) ]
]

{ #category : #execution }
Expand Down Expand Up @@ -103,22 +89,20 @@ IceConvertFormatAction >> mergeWithCurrentBranch: anObject [

{ #category : #private }
IceConvertFormatAction >> migratePackage: packageName commit: commit [

| filetreePackage srcDir subDirWithDelim mcVersion |

srcDir := self codeDirectory.
subDirWithDelim := self codeDirectoryWithDelim.

mcVersion := (commit versionFor: packageName) mcVersion.
mcVersion := self ensureMCVersionWithClassOrganisation: mcVersion.
mcVersion := self ensureMCClassOrganisationHasCorrectStructure: mcVersion.
self writerClass
forInternalStoreFileOut: mcVersion
on: repository.
self ensureMCClassOrganisationHasCorrectStructure: mcVersion.
self writerClass forInternalStoreFileOut: mcVersion on: repository.
filetreePackage := commit writerClass directoryNameFor: packageName.
(srcDir / filetreePackage) ensureDeleteAll.
self repository addFilesToIndex: {
subDirWithDelim, (IceLibgitTonelWriter directoryNameFor: packageName).
subDirWithDelim, (IceLibgitFiletreeWriter directoryNameFor: packageName) }
self repository addFilesToIndex: {
(subDirWithDelim , (IceLibgitTonelWriter directoryNameFor: packageName)).
(subDirWithDelim , (IceLibgitFiletreeWriter directoryNameFor: packageName)) }
]

{ #category : #private }
Expand Down Expand Up @@ -152,17 +136,6 @@ IceConvertFormatAction >> migrateSources [
andParents: { commit }.
]

{ #category : #private }
IceConvertFormatAction >> obtainCommonCategory: aString from: aCollection [

^ (aCollection allSatisfy: [ :each | each beginsWith: aString ])
ifTrue: [ aString ]
ifFalse: [
(aString includes: $-)
ifTrue: [ self obtainCommonCategory: (aString copyUpToLast: $-) from: aCollection ]
ifFalse: [ '' ] ]
]

{ #category : #private }
IceConvertFormatAction >> removeFiletreeRemnants [
"remove .filetree remaining"
Expand Down
8 changes: 5 additions & 3 deletions Iceberg/IceMCDefinitionImporter.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -123,9 +123,11 @@ IceMCDefinitionImporter >> visitMethodDefinition: aMCMethodDefinition [
]

{ #category : #visiting }
IceMCDefinitionImporter >> visitOrganizationDefinition: aMCOrganizationDefinition [

packageNode value categories: aMCOrganizationDefinition categories
IceMCDefinitionImporter >> visitOrganizationDefinition: aMCOrganizationDefinition [

packageNode value
packageName: aMCOrganizationDefinition packageName;
tagNames: aMCOrganizationDefinition tagNames
]

{ #category : #visiting }
Expand Down
77 changes: 44 additions & 33 deletions Iceberg/IcePackageDefinition.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,11 @@ Class {
#superclass : #IceDefinition,
#instVars : [
'package',
'categories',
'path'
'path',
'packageName',
'tagNames'
],
#category : 'Iceberg-Changes'
#category : #'Iceberg-Changes'
}

{ #category : #visiting }
Expand All @@ -37,44 +38,30 @@ IcePackageDefinition >> addModification: anIceModification toPatcher: aMCPatcher

{ #category : #patching }
IcePackageDefinition >> addToPatcher: aPatcher [

aPatcher addDefinition: (MCOrganizationDefinition categories: categories)
]

{ #category : #accessing }
IcePackageDefinition >> asMCDefinition [

^ MCOrganizationDefinition categories: categories
]

{ #category : #accessing }
IcePackageDefinition >> categories [
^ categories
aPatcher addDefinition: self asMCDefinition
]

{ #category : #accessing }
IcePackageDefinition >> categories: aCollection [
IcePackageDefinition >> asMCDefinition [

categories := aCollection
^ MCOrganizationDefinition packageName: packageName tagNames: tagNames
]

{ #category : #accessing }
IcePackageDefinition >> contents [

^ String streamContents: [ :stream |
stream nextPutAll: 'Package tags: '.
categories do: [ :elem |
stream nextPutAll: String crlf;
nextPutAll: String tab;
nextPutAll: elem.
]]
]

{ #category : #initialization }
IcePackageDefinition >> initialize [

super initialize.
categories := #()
^ String streamContents: [ :stream |
stream
nextPutAll: 'Package: ';
nextPutAll: self packageName;
crlf;
nextPutAll: 'Tags: '.
self tagNames do: [ :tagName |
stream
nextPutAll: String crlf;
nextPutAll: String tab;
nextPutAll: tagName ] ]
]

{ #category : #testing }
Expand All @@ -89,6 +76,18 @@ IcePackageDefinition >> package [
^ package
]

{ #category : #accessing }
IcePackageDefinition >> packageName [

^ packageName
]

{ #category : #accessing }
IcePackageDefinition >> packageName: anObject [

packageName := anObject
]

{ #category : #accessing }
IcePackageDefinition >> path [
^ path
Expand All @@ -107,6 +106,18 @@ IcePackageDefinition >> removeFrom: aVisitor [

{ #category : #patching }
IcePackageDefinition >> removeFromPatcher: aPatcher [

aPatcher removeDefinition: (MCOrganizationDefinition categories: categories)

aPatcher removeDefinition: self asMCDefinition
]

{ #category : #accessing }
IcePackageDefinition >> tagNames [

^ tagNames
]

{ #category : #accessing }
IcePackageDefinition >> tagNames: anObject [

tagNames := anObject
]

0 comments on commit 034d567

Please sign in to comment.