From 5cd52c73693e07930336e7cba26173972d118e3f Mon Sep 17 00:00:00 2001 From: Guille Polito Date: Thu, 28 Dec 2023 22:24:33 +0100 Subject: [PATCH 1/3] Extend API to remove gofer dependencies --- Iceberg/IceMetacelloRepositoryAdapter.class.st | 14 ++++++++++++++ Iceberg/IceWorkingCopy.class.st | 6 ++++++ 2 files changed, 20 insertions(+) diff --git a/Iceberg/IceMetacelloRepositoryAdapter.class.st b/Iceberg/IceMetacelloRepositoryAdapter.class.st index 43f6b91a27..04f3b964ec 100644 --- a/Iceberg/IceMetacelloRepositoryAdapter.class.st +++ b/Iceberg/IceMetacelloRepositoryAdapter.class.st @@ -138,6 +138,20 @@ Do you want to open the Iceberg Browser instead?' format: { IceTipRepositoriesBrowser new open ] +{ #category : 'accessing' } +IceMetacelloRepositoryAdapter >> packageNamed: aName ifAbsent: aBlock [ + + | package | + self repository head description = projectVersion ifFalse: [ + (self repository commitishNamed: projectVersion) + checkoutWithStrategy: IceCheckoutDoNotLoadPackages new ]. + + package := self repository workingCopy + packageNamed: aName + ifAbsent: [ ^ aBlock value ]. + ^ package latestVersion mcVersion +] + { #category : 'accessing' } IceMetacelloRepositoryAdapter >> projectPath [ ^ self repository origin projectPath diff --git a/Iceberg/IceWorkingCopy.class.st b/Iceberg/IceWorkingCopy.class.st index 0d6ffe7727..b10130ac48 100644 --- a/Iceberg/IceWorkingCopy.class.st +++ b/Iceberg/IceWorkingCopy.class.st @@ -560,6 +560,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 [ From 20f4fb72fb3c4ba629ac0738532ca63c783b8f02 Mon Sep 17 00:00:00 2001 From: Guille Polito Date: Fri, 29 Dec 2023 22:48:38 +0100 Subject: [PATCH 2/3] Better metacello adapter API --- .../IceGithubRepositoryType.class.st | 21 --------- .../IceProviderRepositoryType.class.st | 22 +++++---- .../IceMetacelloRepositoryAdapter.class.st | 47 +++++++++++++++++-- Iceberg/IceWorkingCopy.class.st | 18 ++++--- 4 files changed, 66 insertions(+), 42 deletions(-) diff --git a/Iceberg-Metacello-Integration/IceGithubRepositoryType.class.st b/Iceberg-Metacello-Integration/IceGithubRepositoryType.class.st index 00b3bf513c..846c3b946e 100644 --- a/Iceberg-Metacello-Integration/IceGithubRepositoryType.class.st +++ b/Iceberg-Metacello-Integration/IceGithubRepositoryType.class.st @@ -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 ] - -] diff --git a/Iceberg-Metacello-Integration/IceProviderRepositoryType.class.st b/Iceberg-Metacello-Integration/IceProviderRepositoryType.class.st index 4036cf4c81..7b4951ff54 100644 --- a/Iceberg-Metacello-Integration/IceProviderRepositoryType.class.st +++ b/Iceberg-Metacello-Integration/IceProviderRepositoryType.class.st @@ -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' } diff --git a/Iceberg/IceMetacelloRepositoryAdapter.class.st b/Iceberg/IceMetacelloRepositoryAdapter.class.st index 04f3b964ec..0ba29a57fe 100644 --- a/Iceberg/IceMetacelloRepositoryAdapter.class.st +++ b/Iceberg/IceMetacelloRepositoryAdapter.class.st @@ -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" @@ -120,6 +129,14 @@ IceMetacelloRepositoryAdapter >> isValid [ ^ true ] +{ #category : 'accessing' } +IceMetacelloRepositoryAdapter >> loadPackageNamed: aName intoLoader: aLoader [ + + | package | + package := self repository workingCopy packageNamed: aName. + ^ aLoader addVersion: package latestVersion mcVersion +] + { #category : 'MonticelloGUI' } IceMetacelloRepositoryAdapter >> morphicOpen: workingCopy [ @@ -138,18 +155,42 @@ 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: [ ^ aBlock value ]. - ^ package latestVersion mcVersion + packageNamed: aName + ifAbsent: [ ^ absentBlock value ]. + ^ presentBlock value: package latestVersion mcVersion ] { #category : 'accessing' } diff --git a/Iceberg/IceWorkingCopy.class.st b/Iceberg/IceWorkingCopy.class.st index b10130ac48..782f0cd47b 100644 --- a/Iceberg/IceWorkingCopy.class.st +++ b/Iceberg/IceWorkingCopy.class.st @@ -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 ] ] From 1614f8ac4fb31d0e81f6c4b98d7ff7d5d1867fc4 Mon Sep 17 00:00:00 2001 From: Guille Polito Date: Tue, 2 Jan 2024 15:33:54 +0100 Subject: [PATCH 3/3] Re-add backwards compatible later with old baselines needed for bootstrapping --- Iceberg/IceMetacelloRepositoryAdapter.class.st | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/Iceberg/IceMetacelloRepositoryAdapter.class.st b/Iceberg/IceMetacelloRepositoryAdapter.class.st index 0ba29a57fe..d41a0fd3cf 100644 --- a/Iceberg/IceMetacelloRepositoryAdapter.class.st +++ b/Iceberg/IceMetacelloRepositoryAdapter.class.st @@ -132,9 +132,13 @@ IceMetacelloRepositoryAdapter >> isValid [ { #category : 'accessing' } IceMetacelloRepositoryAdapter >> loadPackageNamed: aName intoLoader: aLoader [ - | package | + | package found | package := self repository workingCopy packageNamed: aName. - ^ aLoader addVersion: package latestVersion mcVersion + found := package latestVersion mcVersion. + aLoader addVersion: found. + ^ { + found. + self } ] { #category : 'MonticelloGUI' }