Skip to content

Commit

Permalink
Introduce temporary versions, to allow handling some requirements whi…
Browse files Browse the repository at this point in the history
…le code is being loaded.
Fixed failing tests.
Added test for metacello integration.
Extend interface of IceMetacelloRepositoryAdapter (better metacello integration).
  • Loading branch information
npasserini committed Oct 21, 2016
1 parent 45306f2 commit 6d3ceb1
Show file tree
Hide file tree
Showing 14 changed files with 49 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ testMetacelloIntegration
detect: [ :repo | repo origin projectName = projectName ]
ifNone: [ self fail: 'Could not find repository for project: ', projectName ].

self assert: (repository loadedCode loadedVersions allSatisfy: [ :version | version isKindOf: IceSavedPackageVersion ]).
self assert: (repository loadedCode loadedVersions noneSatisfy: [ :version | version isKindOf: IceForeignVersion ]).
self assert: ((repository loadedCode versionFor: (repository packageNamed: packageName)) isKindOf: IceSavedPackageVersion ).
self assert: repository incommingCommits isEmpty.
self assert: repository outgoingCommits isEmpty.
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
patches
updatedVersion
updated
^ self
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
as yet unclassified
mcVersion
self halt.
^ mcVersion ifNil: [ mcVersion := self package workingCopy loadedVersion ]
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
initialization
computeReferenceCommit
| candidates |


loadedVersions := self loadedVersions collect: #updated.
"1. If no code has been loaded, take HEAD commit as reference."
self loadedVersions isEmpty ifTrue: [ ^ self repository headCommit ].
loadedVersions isEmpty ifTrue: [ ^ self repository headCommit ].

"2. Happy path: see if all loaded code has the same updation commit.
If we can't compute an updation commit for some loaded code, it means that it has been
probably loaded from another kind of repository, we just ignore it."
candidates := (self loadedVersions collect: [:version | version commit] as: Set) reject: #isNil.
candidates := (loadedVersions collect: [:version | version commit] as: Set) reject: #isNil.
candidates size = 1 ifTrue: [ ^ candidates anyOne ].

"3. None of the loaded versions produced a non nil candidate, just use the HEAD commit"
Expand Down
12 changes: 6 additions & 6 deletions Iceberg.package/IceLoadedCode.class/instance/loadedVersions.st
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
accessing
loadedVersions
^ loadedVersions ifNil: [
loadedVersions := Dictionary new.
repository loadedPackages do: [ :pkg | self versionLoaded: pkg computeLoadedVersion ].

loadedVersions
]
^ loadedVersions
ifNil: [
loadedVersions := Dictionary new.
repository loadedPackages do: [ :pkg | self versionLoaded: pkg computeLoadedVersion ].
loadedVersions
]
4 changes: 2 additions & 2 deletions Iceberg.package/IceLoadedCode.class/instance/versionFor..st
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
querying
versionFor: package
versionFor: package
^ self loadedVersions
at: package
ifPresent: #updatedVersion
ifPresent: #updated
ifAbsentPut: [ package computeLoadedVersion ]

Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
testing
canUpgradeTo: anMCGitBasedRepository
"Copied from MCGitBasedNetworkRepository"
self halt.
(anMCGitBasedRepository isKindOf: self class) ifFalse: [ ^ false ].

^ self projectPath = anMCGitBasedRepository projectPath
and: [ self repoPath = anMCGitBasedRepository repoPath ]
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
testing
hasNoLoadConflicts: anMCGitBasedRepository
"Copied from MCGitBasedNetworkRepository"
(anMCGitBasedRepository isKindOf: self class) ifFalse: [ ^ false ].

^ self projectPath = anMCGitBasedRepository projectPath and: [
self repoPath = anMCGitBasedRepository repoPath and: [
self projectVersion = anMCGitBasedRepository projectVersion ] ]
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
accessing
projectPath
^ self repository origin projectPath
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
accessing
projectVersion
^ self repository branch name
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
accessing
repoPath
^ self repository subdirectory
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
accessing
projectPath
^ self owner, '/', self projectName
5 changes: 5 additions & 0 deletions Iceberg.package/IceTemporaryVersion.class/instance/commit.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
as yet unclassified
commit
"I am a temporary version, I am not related to any commit or it is unknown.
When computing a reference commit I must be ignored."
^ nil
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
patches
updatedVersion
updated
| newVersion |
newVersion := self package computeLoadedVersion.
self package repository loadedCode versionLoaded: newVersion.
Expand Down

0 comments on commit 6d3ceb1

Please sign in to comment.