/
Gofer.class.st
468 lines (365 loc) · 14.9 KB
/
Gofer.class.st
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
"
: Gofer, a person who runs errands. Origin 1960s: from go for, i.e. go and fetch.
: ''The New Oxford American Dictionary''
! Synopsis
Gofer is a small tool on top of Monticello that loads, updates, merges, diffs, reverts, commits, recompiles and unloads groups of Monticello packages. Contrary to existing tools Gofer makes sure that these operations are performed as clean as possible:
- Gofer treats packages from one or more repository in one operation.
- Gofer works with fixed versions or tries to find the ""latest"" version using a given package name.
- Gofer automatically assigns repositories to all packages, so that the other tools are ready to be used on individual packages.
- Gofer makes sure that there is only one repository instance registered for a single physical location.
- Gofer works with Monticello dependencies and uniformly treats them like the primary package.
- Gofer prefers to work with faster repositories if there is a choice.
- Gofer cleans up after Monticello, no empty class categories and no empty method protocols are to be expected.
- Gofer supports operations to sync remote and local repositories with each other.
! Installation
Gofer is included with the latest Pharo and GemStone distributions. To update to the latest version you can use Gofer itself:
== Gofer upgrade
In case you are missing Gofer in your image, grab it from *http://source.lukas-renggli.ch/gofer.html*.
! Description
Gofer is very simple by design, the basic useage scenario is always the same and consists of three steps:
# You specify one or more Monticello repository URLs. You can do this using the methods ==url:==, ==url:username:password:== (HTTP, FTP), ==directory:==, or ==repository:== if you need full control. You might also use the convenience methods like ==squeaksource:==, ==wiresong:==, or ==gemsource:== for well known repositories. Additionally the following settings are available:
#- Gofer implicitly declares the local package cache as a repository. To disable the local package cache use the method ==disablePackageCache==, to re-enable use ==enablePackageCache==.
#- Gofer throws an error if a repository is not reachable. To silently ignore repository erros use the message ==disableRepositoryErrors==, to re-enable use ==enableRepositoryErrors==.
# You specify one or more Monticello packages you want to work with, by adding them to the Gofer instance. Use ==version:== to add a specific version, or use ==package:== to add the ""latest"" version in the given repository. Furthermore there is ==package:constraint:== that allows you to further constraint the version to be loaded in a block passed in as the second argument.
# You specify one or more actions to be performed on the specified packages:
| ==load== | Load the specified packages.
| ==update== | Update the specified packages.
| ==merge== | Merge the specified packages into their working copies.
| ==localChanges== | Answer the changes between the base version and the working copy.
| ==browseLocalChanges== | Browse the changes between the base version and the working copy.
| ==remoteChanges== | Answer the changes between the working copy and the remote changes.
| ==browseRemoteChanges== | Browse the changes between the working copy and the remote changes.
| ==cleanup== | Cleans the specified packages.
| ==commit== | Commit the modified specified packages.
| ==commit:== | Commit the modified specified packages with the given commit message.
| ==revert== | Revert the specified packages to the currently loaded version.
| ==recompile== | Recompile the specified packages.
| ==reinitialize== | Call the class side initializers on the specified packages.
| ==unload== | Unload the specified packages.
| ==fetch== | Download versions from remote repositories into the local cache.
| ==push== | Upload local versions from local cache into remote repositories.
! Example
To use Gofer to update to exact versions of the Kom Server, the 'latest' code of Seaside 2.8 and the 'latest' code of the Scriptaculous package that is committed by the author with the initials 'lr' one could evaluate:
== Gofer new
== squeaksource: 'KomHttpServer';
== version: 'DynamicBindings-gc.7';
== version: 'KomServices-gc.19';
== version: 'KomHttpServer-gc.32';
== update.
== Gofer new
== squeaksource: 'Seaside';
== package: 'Seaside2.8a';
== package: 'Scriptaculous' constraint: [ :version | version author = 'lr' ];
== load
"
Class {
#name : #Gofer,
#superclass : #Object,
#instVars : [
'references',
'repositories',
'errorBlock',
'packageCacheRepository',
'resolvedReferencesCache'
],
#category : #'Gofer-Core-Base'
}
{ #category : #private }
Gofer class >> gofer [
"Create a Gofer instance of Gofer."
^ self new
renggli: 'gofer';
package: 'Gofer-Core';
package: 'Gofer-Tests';
yourself
]
{ #category : #'instance creation' }
Gofer class >> it [
^ self new
]
{ #category : #deprecated }
Gofer >> addPackage: aPackage [
self package: aPackage
]
{ #category : #accessing }
Gofer >> allResolved [
"Answer all sorted references within the configured repositories."
| resolved |
resolved := OrderedCollection new.
self repositories
do: [ :repository | resolved addAll: (self allResolvedIn: repository) ].
^ resolved asSortedCollection asArray
]
{ #category : #accessing }
Gofer >> allResolvedIn: aRepository [
"Answer all sorted references within aRepository. For efficiency cache the references."
^ (resolvedReferencesCache ifNil: [ resolvedReferencesCache := Dictionary new ])
at: aRepository ifAbsentPut: [ self basicReferencesIn: aRepository ]
]
{ #category : #private }
Gofer >> basicReferencesIn: aRepository [
^ [ aRepository goferReferences asSortedCollection asArray ]
on: GoferRepositoryError
do: errorBlock
]
{ #category : #'repositories-places' }
Gofer >> blueplane: aString [
self url: 'http://squeaksource.blueplane.jp/' , aString
]
{ #category : #operations }
Gofer >> cleanup [
"Cleans the specified packages."
^ self execute: GoferCleanup
]
{ #category : #operations }
Gofer >> commit [
"Commit the modified packages."
^ self execute: GoferCommit
]
{ #category : #operations }
Gofer >> commit: aString [
"Commit the modified packages with the given commit message."
^ self execute: GoferCommit do: [ :operation | operation message: aString ]
]
{ #category : #references }
Gofer >> configuration [
"Add a default Configuration package by using the repository name.
Assumes that there has been at least one repository set"
^ self configurationOf: self repositories last project capitalized.
]
{ #category : #references }
Gofer >> configurationOf: aProjectName [
"Add a package reference to the configuration of the given project"
references addLast: (GoferConfigurationReference name: aProjectName)
]
{ #category : #repositories }
Gofer >> directory: aDirectoryOrString [
"Add a file-system repository at aDirectoryOrString."
| repository |
repository := (aDirectoryOrString isString and: [ aDirectoryOrString endsWith: '*' ])
ifTrue: [
MCSubDirectoryRepository new
directory: aDirectoryOrString allButLast asFileReference;
yourself ]
ifFalse: [
(MCDirectoryRepository new)
directory:
(aDirectoryOrString isString
ifTrue: [ aDirectoryOrString asFileReference ]
ifFalse: [ aDirectoryOrString ]);
yourself ].
self repository: repository
]
{ #category : #'repositories-options' }
Gofer >> disablePackageCache [
"Disable the use of the package-cache repository."
packageCacheRepository := nil
]
{ #category : #'repositories-options' }
Gofer >> disableRepositoryErrors [
"Silently swallow all repository errors."
errorBlock := [ :error | error resume: #() ]
]
{ #category : #'repositories-options' }
Gofer >> enablePackageCache [
"Enable the use of the package-cache repository."
packageCacheRepository := MCCacheRepository uniqueInstance.
]
{ #category : #'repositories-options' }
Gofer >> enableRepositoryErrors [
"Throw an exception when repositories are not available."
errorBlock := [ :error | error pass ]
]
{ #category : #private }
Gofer >> execute: anOperationClass [
^ self execute: anOperationClass do: nil
]
{ #category : #private }
Gofer >> execute: anOperationClass do: aBlock [
| operation |
operation := anOperationClass on: self copy.
aBlock ifNotNil: [ aBlock value: operation ].
^ operation execute
]
{ #category : #operations }
Gofer >> fetch [
"Download versions from remote repositories into the local cache."
^ self execute: GoferFetch
]
{ #category : #'repositories-places' }
Gofer >> gemsource: aString [
self url: 'http://seaside.gemstone.com/ss/' , aString
]
{ #category : #'repositories-places' }
Gofer >> impara: aString [
self url: 'http://source.impara.de/' , aString
]
{ #category : #initialization }
Gofer >> initialize [
self enablePackageCache; enableRepositoryErrors.
references := OrderedCollection new.
repositories := OrderedCollection new
]
{ #category : #operations }
Gofer >> load [
"Load the specified packages into the image."
^ self execute: GoferLoad
]
{ #category : #operations }
Gofer >> loadBleedingEdge [
"Load the baseline of the previously specifed configuration."
^ self loadVersion: #bleedingEdge
]
{ #category : #operations }
Gofer >> loadDevelopment [
"Load the development version of the previously specifed configuration."
^ self loadVersion: #development
]
{ #category : #operations }
Gofer >> loadStable [
"Load the stable version of the previously specifed configuration."
^ self loadVersion: #stable
]
{ #category : #operations }
Gofer >> loadVersion: anMetacelloVersionIdentifierSymbol [
"Load the given version name"
^ self execute: GoferMetacelloLoad do: [ :operation|
operation version: anMetacelloVersionIdentifierSymbol ]
]
{ #category : #operations }
Gofer >> localChanges [
"Answer the changes between the base version and the working copy."
^ self execute: GoferLocalChanges
]
{ #category : #operations }
Gofer >> merge [
"Merge the specified packages into their working copies."
^ self execute: GoferMerge
]
{ #category : #references }
Gofer >> package: aString [
"Add the package aString to the receiver. aString is a package name as it appears in the Monticello Browser, something like 'Magritte-Seaside'. Gofer will try to resolve this name to an actual version in one of the configured repositories before doing something with the package. Gofer sorts all the versions in all the repositories according to branch name (versions without a branch are preferred), version number, author name and repository priority. The top hit of this sorted list is eventually going to be loaded and used."
references addLast: (GoferPackageReference name: aString)
]
{ #category : #references }
Gofer >> package: aString constraint: aOneArgumentBlock [
"Add the package aString to the receiver, but constraint the resulting versions further with aOneArgumentBlock. For details on the package, see #package:. The following example defines various constraints:
aGofer package: 'Magritte-Seaside' constraint: [ :version |
version author = 'lr'
and: [ version branch = 'trial'
and: [ version versionNumber > 120 ] ] ]"
references addLast: (GoferConstraintReference name: aString constraint: aOneArgumentBlock)
]
{ #category : #copying }
Gofer >> postCopy [
references := references copy.
repositories := repositories copy.
resolvedReferencesCache := nil
]
{ #category : #operations }
Gofer >> push [
"Upload local versions from local cache into remote repositories."
^ self execute: GoferPush
]
{ #category : #operations }
Gofer >> recompile [
"Recompile the specified packages."
^ self execute: GoferRecompile
]
{ #category : #accessing }
Gofer >> references [
"Answer the configured references."
^ Array withAll: references
]
{ #category : #operations }
Gofer >> reinitialize [
"Calls the class side initializers on all package code."
^ self execute: GoferReinitialize
]
{ #category : #operations }
Gofer >> remoteChanges [
"Display the changes between the working copy and the remote changes."
^ self execute: GoferRemoteChanges
]
{ #category : #'repositories-places' }
Gofer >> renggli: aString [
self url: 'http://source.lukas-renggli.ch/' , aString
]
{ #category : #accessing }
Gofer >> repositories [
"Answer the configured monticello repositories."
| result |
result := OrderedCollection withAll: repositories.
packageCacheRepository ifNotNil: [ result addFirst: packageCacheRepository ].
^ result asArray
]
{ #category : #repositories }
Gofer >> repository: aRepository [
"Add aRepository to the repository configuration. If there is already a repository defined in the global configuration with that URL take this one instead."
| repository |
repository := MCRepositoryGroup default repositories
detect: [ :each | each = aRepository ]
ifNone: [ aRepository ].
repositories addLast: repository
]
{ #category : #accessing }
Gofer >> resolved [
"Answer the resolved references of the receiver."
^ self references collect: [ :each | each resolveWith: self ]
]
{ #category : #operations }
Gofer >> revert [
"Revert the specified packages to the currently loaded version."
^ self execute: GoferRevert
]
{ #category : #'repositories-places' }
Gofer >> smalltalkhubUser: aUserName project: aProjectName [
self repository: (MCSmalltalkhubRepository owner: aUserName project: aProjectName)
]
{ #category : #'repositories-places' }
Gofer >> squeakfoundation: aString [
self url: 'http://source.squeakfoundation.org/' , aString
]
{ #category : #'repositories-places' }
Gofer >> squeaksource3: aProjectName [
self repository: (MCGemstoneRepository location: 'http://ss3.gemtalksystems.com/ss/' , aProjectName)
]
{ #category : #'repositories-places' }
Gofer >> squeaksource: aProjectName [
self repository: (MCSqueaksourceRepository location: 'http://www.squeaksource.com/' , aProjectName)
]
{ #category : #operations }
Gofer >> unload [
"Unload the specified packages."
^ self execute: GoferUnload
]
{ #category : #operations }
Gofer >> update [
"Update the specified packages."
^ self execute: GoferUpdate
]
{ #category : #repositories }
Gofer >> url: anUrlString [
"Add anUrlString as a repository for the following package operations."
self url: anUrlString username: String new password: String new
]
{ #category : #repositories }
Gofer >> url: urlString username: username password: passwordString [
"Add urlString as a repository for the following package operations."
| repository |
repository := MCRepository fromUrl:
(urlString asUrl
username: (username ifEmpty: [ nil ]);
password: (passwordString ifEmpty: [ nil ]);
yourself).
self repository: repository.
]
{ #category : #references }
Gofer >> version: aString [
"Add the version aString to the receiver. aString is a version name as it appears in the Monticello Repository Browser, something like 'Magritte-Seaside-lr.334'. Gofer will try to resolve this name to one of the configured repositories before loading the code."
references addLast: (GoferVersionReference name: aString)
]
{ #category : #'repositories-places' }
Gofer >> wiresong: aString [
self url: 'http://source.wiresong.ca/' , aString
]