Skip to content

Commit

Permalink
Merge pull request #1788 from guillep/new-metacello-adapter
Browse files Browse the repository at this point in the history
Better metacello adapter API
  • Loading branch information
guillep authored Jan 2, 2024
2 parents 40062f8 + 1614f8a commit 784beeb
Show file tree
Hide file tree
Showing 4 changed files with 87 additions and 39 deletions.
21 changes: 0 additions & 21 deletions Iceberg-Metacello-Integration/IceGithubRepositoryType.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -13,24 +13,3 @@ Class {
IceGithubRepositoryType class >> type [
^ 'github'
]

{ #category : 'accessing' }
IceGithubRepositoryType >> mcRepository [
| baseRepo |

self guessRegisteredRepository
ifNotNil: [ :repo |
repo isValid ifTrue: [ ^ repo metacelloAdapter: self projectVersion ].
"If the repo is not valid, we forget it and reget a new one. Because Metacello want to use it"
repo forget ].

baseRepo := self mcRepositoryClass location: self location.
^ (Iceberg icebergRepositoriesURLs includes: baseRepo scpUrl)
ifTrue: [
"Do not use Iceberg to load iceberg code,
see https://github.com/pharo-vcs/iceberg/issues/168"
baseRepo ]
ifFalse: [
baseRepo getOrCreateIcebergRepository metacelloAdapter: self projectVersion ]

]
22 changes: 14 additions & 8 deletions Iceberg-Metacello-Integration/IceProviderRepositoryType.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -45,16 +45,22 @@ IceProviderRepositoryType >> guessRegisteredRepository [

{ #category : 'accessing' }
IceProviderRepositoryType >> mcRepository [

| baseRepo |

self guessRegisteredRepository
ifNotNil: [ :repo |
repo isValid ifTrue: [ ^ repo metacelloAdapter: self projectVersion ].
"If the repo is not valid, we forget it and reget a new one.
Because Metacello want to use it"
repo forget ].
self guessRegisteredRepository ifNotNil: [ :repo |
repo isValid ifTrue: [ ^ repo metacelloAdapter: self projectVersion ].
"If the repo is not valid, we forget it and reget a new one.
Because Metacello want to use it"
repo forget ].

baseRepo := self mcRepositoryClass location: self location.
^ baseRepo getOrCreateIcebergRepository metacelloAdapter: self projectVersion
^ (Iceberg icebergRepositoriesURLs includes: baseRepo scpUrl)
ifTrue: [ "Do not use Iceberg to load iceberg code,
see https://github.com/pharo-vcs/iceberg/issues/168"
baseRepo ]
ifFalse: [
baseRepo getOrCreateIcebergRepository metacelloAdapter:
self projectVersion ]
]

{ #category : 'accessing' }
Expand Down
59 changes: 59 additions & 0 deletions Iceberg/IceMetacelloRepositoryAdapter.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,15 @@ IceMetacelloRepositoryAdapter >> description [
^ self repository origin url, '[', projectVersion, ']'
]

{ #category : 'fetching' }
IceMetacelloRepositoryAdapter >> fetchPackageNamed: aString [
"The fetch operation just makes sure we have the correct version in disk"

self repository head description = projectVersion ifFalse: [
(self repository commitishNamed: projectVersion)
checkoutWithStrategy: IceCheckoutDoNotLoadPackages new ]
]

{ #category : 'initialization' }
IceMetacelloRepositoryAdapter >> flushForScriptGet [
"do nothing"
Expand Down Expand Up @@ -120,6 +129,18 @@ IceMetacelloRepositoryAdapter >> isValid [
^ true
]

{ #category : 'accessing' }
IceMetacelloRepositoryAdapter >> loadPackageNamed: aName intoLoader: aLoader [

| package found |
package := self repository workingCopy packageNamed: aName.
found := package latestVersion mcVersion.
aLoader addVersion: found.
^ {
found.
self }
]

{ #category : 'MonticelloGUI' }
IceMetacelloRepositoryAdapter >> morphicOpen: workingCopy [

Expand All @@ -138,6 +159,44 @@ Do you want to open the Iceberg Browser instead?' format: {
IceTipRepositoriesBrowser new open
]

{ #category : 'accessing' }
IceMetacelloRepositoryAdapter >> packageNamed: aName [

^ self packageNamed: aName ifAbsent: [ NotFound signal: aName ]
]

{ #category : 'accessing' }
IceMetacelloRepositoryAdapter >> packageNamed: aName ifAbsent: aBlock [

^ self
packageNamed: aName
ifPresent: [ :found | found ]
ifAbsent: aBlock
]

{ #category : 'accessing' }
IceMetacelloRepositoryAdapter >> packageNamed: aName ifPresent: aBlock [

^ self
packageNamed: aName
ifPresent: aBlock
ifAbsent: [ NotFound signal: aName ]
]

{ #category : 'accessing' }
IceMetacelloRepositoryAdapter >> packageNamed: aName ifPresent: presentBlock ifAbsent: absentBlock [

| package |
self repository head description = projectVersion ifFalse: [
(self repository commitishNamed: projectVersion)
checkoutWithStrategy: IceCheckoutDoNotLoadPackages new ].

package := self repository workingCopy
packageNamed: aName
ifAbsent: [ ^ absentBlock value ].
^ presentBlock value: package latestVersion mcVersion
]

{ #category : 'accessing' }
IceMetacelloRepositoryAdapter >> projectPath [
^ self repository origin projectPath
Expand Down
24 changes: 14 additions & 10 deletions Iceberg/IceWorkingCopy.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -462,20 +462,18 @@ IceWorkingCopy >> loadPackagesNamed: aCollection [

{ #category : 'private - monticello' }
IceWorkingCopy >> loadPackagesNamed: aCollection fromCommit: aCommit [

aCollection ifEmpty: [ ^ self ].

self ignoreNotificationsDuring: [ | loader |

self ignoreNotificationsDuring: [
| loader |
loader := MCVersionLoader new.
aCollection do: [ :name | | package packageVersion |
aCollection do: [ :name |
| package packageVersion |
package := self packageNamed: name.
packageVersion := (IceSavedPackageVersion
fromCommit: aCommit
package: package)
mcVersion.
packageVersion := (aCommit versionFor: package) mcVersion.
loader addVersion: packageVersion.
package beClean.
].
package beClean ].
loader load ]
]

Expand Down Expand Up @@ -560,6 +558,12 @@ IceWorkingCopy >> packageNamed: aString [
^ self packagesDictionary at: aString
]

{ #category : 'API - packages' }
IceWorkingCopy >> packageNamed: aString ifAbsent: aBlock [

^ self packagesDictionary at: aString ifAbsent: aBlock
]

{ #category : 'API - packages' }
IceWorkingCopy >> packageNames [

Expand Down

0 comments on commit 784beeb

Please sign in to comment.