2778
|
1 |
"
|
|
2 |
COPYRIGHT (c) 2012 by Claus Gittinger
|
|
3 |
All Rights Reserved
|
|
4 |
|
|
5 |
This software is furnished under a license and may be used
|
|
6 |
only in accordance with the terms of that license and with the
|
|
7 |
inclusion of the above copyright notice. This software may not
|
|
8 |
be provided or otherwise made available to, or used by, any
|
|
9 |
other person. No title to or ownership of the software is
|
|
10 |
hereby transferred.
|
|
11 |
"
|
|
12 |
"{ Package: 'stx:libbasic3' }"
|
|
13 |
|
|
14 |
AbstractSourceCodeManager subclass:#GitSourceCodeManager
|
|
15 |
instanceVariableNames:''
|
|
16 |
classVariableNames:'Verbose DefaultRepository PerModuleRepositories DisabledModules
|
|
17 |
RecentlyCheckedModulesAndPackages GitCommandTimeout GitTempDir
|
|
18 |
GitCommandSemaphore GitExecutable GitCommitOptions
|
|
19 |
GitUpdateOptions'
|
|
20 |
poolDictionaries:''
|
|
21 |
category:'System-SourceCodeManagement'
|
|
22 |
!
|
|
23 |
|
|
24 |
!GitSourceCodeManager class methodsFor:'documentation'!
|
|
25 |
|
|
26 |
copyright
|
|
27 |
"
|
|
28 |
COPYRIGHT (c) 2012 by Claus Gittinger
|
|
29 |
All Rights Reserved
|
|
30 |
|
|
31 |
This software is furnished under a license and may be used
|
|
32 |
only in accordance with the terms of that license and with the
|
|
33 |
inclusion of the above copyright notice. This software may not
|
|
34 |
be provided or otherwise made available to, or used by, any
|
|
35 |
other person. No title to or ownership of the software is
|
|
36 |
hereby transferred.
|
|
37 |
"
|
|
38 |
!
|
|
39 |
|
|
40 |
documentation
|
|
41 |
"
|
|
42 |
SourceCodeManager which accesses the sourcecode through Git.
|
|
43 |
ongoing work - unfinished and unusable
|
|
44 |
|
|
45 |
Comment:
|
|
46 |
The code here is a copy-paste mess; it definitely needs some cleanup...
|
|
47 |
|
|
48 |
[author:]
|
|
49 |
Claus Gittinger
|
|
50 |
|
|
51 |
[see also:]
|
|
52 |
"
|
|
53 |
! !
|
|
54 |
|
|
55 |
!GitSourceCodeManager class methodsFor:'initialization'!
|
|
56 |
|
|
57 |
forgetDisabledModules
|
|
58 |
DisabledModules := nil.
|
|
59 |
!
|
|
60 |
|
|
61 |
initialize
|
|
62 |
| s ok |
|
|
63 |
|
|
64 |
GitCommandSemaphore := Semaphore new:10. "/ at most 10 git activities concurrently
|
|
65 |
GitCommitOptions := ''.
|
|
66 |
GitUpdateOptions := ''.
|
|
67 |
DisabledModules := nil.
|
|
68 |
PerModuleRepositories isNil ifTrue:[
|
|
69 |
PerModuleRepositories := Dictionary new.
|
|
70 |
].
|
|
71 |
|
|
72 |
ok := OperatingSystem canExecuteCommand:(self gitExecutable).
|
|
73 |
ok ifFalse:[
|
|
74 |
'GitSourceCodeManager [warning]: disabled because no >>git<< command was found' infoPrintCR.
|
|
75 |
^ self
|
|
76 |
].
|
|
77 |
|
|
78 |
CacheDirectoryName isNil ifTrue:[
|
|
79 |
self initCacheDirPath.
|
|
80 |
].
|
|
81 |
CachingSources isNil ifTrue:[
|
|
82 |
CachingSources := true.
|
|
83 |
].
|
|
84 |
|
|
85 |
"/
|
|
86 |
"/ optionally set the WorkTreeDirectoryName from $STX_WORKTREE;
|
|
87 |
"/ if non-nil, a working tree is kept there
|
|
88 |
"/ and updated/commited files are not removed.
|
|
89 |
"/ If you use a regular (make-) tree,
|
|
90 |
"/ set WorkTreeDirectoryName (or the environment variable) to that.
|
|
91 |
"/
|
|
92 |
"/ this is not yet finished.
|
|
93 |
"/
|
|
94 |
s := OperatingSystem getEnvironment:'STX_WORKTREE'.
|
|
95 |
s notNil ifTrue:[
|
|
96 |
WorkTreeDirectoryName := s.
|
|
97 |
UseWorkTree := true.
|
|
98 |
]
|
|
99 |
|
|
100 |
"
|
|
101 |
AbstractSourceCodeManager initialize
|
|
102 |
GitSourceCodeManager initialize
|
|
103 |
"
|
|
104 |
|
|
105 |
"Created: / 04-11-1995 / 19:14:38 / cg"
|
|
106 |
"Modified: / 19-12-1995 / 14:25:46 / stefan"
|
|
107 |
"Modified: / 02-03-2012 / 15:25:02 / cg"
|
|
108 |
!
|
|
109 |
|
|
110 |
initializeForRepository:aDirectoryName
|
|
111 |
"reinitialize.
|
|
112 |
Can be used from the launcher to change/configure the repository."
|
|
113 |
|
|
114 |
self repositoryName:aDirectoryName.
|
|
115 |
AbstractSourceCodeManager initialize.
|
|
116 |
GitSourceCodeManager initialize.
|
|
117 |
|
|
118 |
"Created: / 13-08-1997 / 17:20:57 / cg"
|
|
119 |
"Modified: / 25-09-1997 / 12:28:05 / stefan"
|
|
120 |
"Modified: / 02-03-2012 / 15:17:10 / cg"
|
|
121 |
! !
|
|
122 |
|
|
123 |
!GitSourceCodeManager class methodsFor:'accessing'!
|
|
124 |
|
|
125 |
gitBinDirectory:ignoredString
|
|
126 |
"ignored - for backward compatibility (to read old settings files)"
|
|
127 |
"Created: / 14-01-2012 / 20:49:46 / cg"
|
|
128 |
!
|
|
129 |
|
|
130 |
gitCommandTimeout
|
|
131 |
^ GitCommandTimeout ? ("360" 120 seconds)
|
|
132 |
|
|
133 |
"Modified (comment): / 08-01-2012 / 19:02:44 / cg"
|
|
134 |
"Created: / 02-03-2012 / 15:23:40 / cg"
|
|
135 |
!
|
|
136 |
|
|
137 |
gitCommandTimeout:aTimeDuration
|
|
138 |
GitCommandTimeout := aTimeDuration asTimeDuration.
|
|
139 |
|
|
140 |
"Created: / 02-03-2012 / 15:23:46 / cg"
|
|
141 |
!
|
|
142 |
|
|
143 |
gitCommitOptions
|
|
144 |
^ GitCommitOptions ? ''
|
|
145 |
|
|
146 |
"Created: / 02-03-2012 / 15:23:51 / cg"
|
|
147 |
!
|
|
148 |
|
|
149 |
gitCommitOptions:aString
|
|
150 |
GitCommitOptions := aString.
|
|
151 |
|
|
152 |
"Created: / 02-03-2012 / 15:23:57 / cg"
|
|
153 |
!
|
|
154 |
|
|
155 |
gitExecutable
|
|
156 |
"return the name of the git executable."
|
|
157 |
|
|
158 |
^ GitExecutable ? 'git'
|
|
159 |
|
|
160 |
"Created: / 02-03-2012 / 15:24:02 / cg"
|
|
161 |
!
|
|
162 |
|
|
163 |
gitExecutable:aString
|
|
164 |
"set the name of the git executable."
|
|
165 |
|
|
166 |
aString isEmptyOrNil ifTrue:[
|
|
167 |
GitExecutable := nil
|
|
168 |
] ifFalse:[
|
|
169 |
GitExecutable := aString.
|
|
170 |
].
|
|
171 |
|
|
172 |
"Modified: / 21-09-2006 / 16:41:33 / cg"
|
|
173 |
"Created: / 02-03-2012 / 15:24:07 / cg"
|
|
174 |
!
|
|
175 |
|
|
176 |
gitTmpDirectory
|
|
177 |
"return the name of the tmp repository.
|
|
178 |
That's the directory, where temporary files are created for checkin/checkout.
|
|
179 |
If nil, the systems default tempDirectory is used."
|
|
180 |
|
|
181 |
^ (GitTempDir ? Filename tempDirectory pathName)
|
|
182 |
|
|
183 |
"
|
|
184 |
CVSTempDir := nil
|
|
185 |
"
|
|
186 |
|
|
187 |
"Created: / 02-03-2012 / 15:24:12 / cg"
|
|
188 |
!
|
|
189 |
|
|
190 |
gitTmpDirectory:aPathNameString
|
|
191 |
"set the name of the tmp repository.
|
|
192 |
That's the directory, where temporary files are created for checkin/checkout.
|
|
193 |
If nil, the systems default tempDirectory is used."
|
|
194 |
|
|
195 |
GitTempDir := aPathNameString
|
|
196 |
|
|
197 |
"Created: / 02-03-2012 / 15:24:18 / cg"
|
|
198 |
!
|
|
199 |
|
|
200 |
gitUpdateOptions
|
|
201 |
^ GitUpdateOptions ? ''
|
|
202 |
|
|
203 |
"Created: / 02-03-2012 / 15:24:24 / cg"
|
|
204 |
!
|
|
205 |
|
|
206 |
gitUpdateOptions:aString
|
|
207 |
GitUpdateOptions := aString.
|
|
208 |
|
|
209 |
"Created: / 02-03-2012 / 15:24:28 / cg"
|
|
210 |
!
|
|
211 |
|
|
212 |
knownModules
|
|
213 |
"return the modules, we currently know"
|
|
214 |
|
|
215 |
PerModuleRepositories isEmptyOrNil ifTrue:[^ #() ].
|
|
216 |
^ PerModuleRepositories keys
|
|
217 |
|
|
218 |
"Modified: / 14-01-2012 / 21:23:37 / cg"
|
|
219 |
!
|
|
220 |
|
|
221 |
knownRepositories
|
|
222 |
"return the modules, we currently know"
|
|
223 |
|
|
224 |
^ PerModuleRepositories values copyWith:DefaultRepository
|
|
225 |
|
|
226 |
"Modified: / 14-01-2012 / 21:23:59 / cg"
|
|
227 |
!
|
|
228 |
|
|
229 |
repositoryForPackage:packageId
|
|
230 |
"superclass AbstractSourceCodeManager class says that I am responsible to implement this method"
|
|
231 |
|
|
232 |
^self getGitRepositoryForModule: ( packageId upTo:$:)
|
|
233 |
|
|
234 |
"Modified: / 10-10-2011 / 19:38:47 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
235 |
"Modified: / 02-03-2012 / 15:25:19 / cg"
|
|
236 |
!
|
|
237 |
|
|
238 |
repositoryInfoPerModule
|
|
239 |
"return the dictionary, which associates gitRepositories to module names.
|
|
240 |
If no entry is contained in this dictionary for some module,
|
|
241 |
the default crepository will be used."
|
|
242 |
|
|
243 |
^ PerModuleRepositories ? #()
|
|
244 |
|
|
245 |
"Modified (comment): / 02-03-2012 / 15:25:28 / cg"
|
|
246 |
!
|
|
247 |
|
|
248 |
repositoryInfoPerModule:aDictionary
|
|
249 |
"set the dictionary, which associates repositories to module names.
|
|
250 |
If no entry is contained in this dictionary for some module,
|
|
251 |
the default repository will be used."
|
|
252 |
|
|
253 |
PerModuleRepositories := aDictionary
|
|
254 |
|
|
255 |
"Modified: / 14-01-2012 / 21:25:21 / cg"
|
|
256 |
!
|
|
257 |
|
|
258 |
repositoryName
|
|
259 |
"return the name of the global repository.
|
|
260 |
This is used, if no per-module repository is defined."
|
|
261 |
|
|
262 |
^ DefaultRepository
|
|
263 |
|
|
264 |
"Created: / 14-09-1996 / 13:22:05 / cg"
|
|
265 |
"Modified: / 14-01-2012 / 21:25:42 / cg"
|
|
266 |
!
|
|
267 |
|
|
268 |
repositoryName:aDirectoryName
|
|
269 |
"set the name of the repository;
|
|
270 |
that's the name of the global repository, which is used
|
|
271 |
if no specific repository was defined for a module."
|
|
272 |
|
|
273 |
DisabledModules := nil.
|
|
274 |
DefaultRepository := aDirectoryName.
|
|
275 |
|
|
276 |
"Created: / 14-09-1996 / 13:22:24 / cg"
|
|
277 |
"Modified: / 14-01-2012 / 21:26:17 / cg"
|
|
278 |
!
|
|
279 |
|
|
280 |
repositoryName:aRepositoryName forModule:aModuleName
|
|
281 |
"set the repository which provides the sources for all
|
|
282 |
classes in a particular module.
|
|
283 |
This can be used from an rc-script, to specify a repository
|
|
284 |
for a particular module.
|
|
285 |
If left unspecified, the global (i.e. fallBack) repository is used."
|
|
286 |
|
|
287 |
DisabledModules := nil.
|
|
288 |
PerModuleRepositories at:aModuleName put:aRepositoryName
|
|
289 |
|
|
290 |
"Modified (comment): / 14-01-2012 / 21:27:08 / cg"
|
|
291 |
!
|
|
292 |
|
|
293 |
repositoryNameForModule:aModuleName
|
|
294 |
"return the repository which provides the sources for all
|
|
295 |
classes in a particular module.
|
|
296 |
Nil is returned for unspecified moduleRoots; in this case,
|
|
297 |
the global (i.e. fallBack) repository will be used for source access."
|
|
298 |
|
|
299 |
^ PerModuleRepositories at:aModuleName ifAbsent:nil.
|
|
300 |
|
|
301 |
"Created: / 19-09-1997 / 06:13:06 / cg"
|
|
302 |
!
|
|
303 |
|
|
304 |
repositoryNameForPackage:packageId
|
|
305 |
"superclass AbstractSourceCodeManager class says that I am responsible to implement this method"
|
|
306 |
|
|
307 |
^ self getGitRepositoryForModule:(packageId upTo:$: )
|
|
308 |
|
|
309 |
"Created: / 10-10-2011 / 19:44:51 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
310 |
"Modified: / 02-03-2012 / 15:25:35 / cg"
|
|
311 |
! !
|
|
312 |
|
|
313 |
!GitSourceCodeManager class methodsFor:'basic administration'!
|
|
314 |
|
|
315 |
createContainerFor:aClass inModule:moduleName directory:dirName container:fileName
|
|
316 |
"create a new container & check into it an initial version of aClass"
|
|
317 |
|
|
318 |
^ self shouldImplement
|
|
319 |
! !
|
|
320 |
|
|
321 |
!GitSourceCodeManager class methodsFor:'debugging'!
|
|
322 |
|
|
323 |
verboseSourceCodeAccess
|
|
324 |
^ Verbose ? false
|
|
325 |
!
|
|
326 |
|
|
327 |
verboseSourceCodeAccess:aBoolean
|
|
328 |
Verbose := aBoolean
|
|
329 |
! !
|
|
330 |
|
|
331 |
!GitSourceCodeManager class methodsFor:'queries'!
|
|
332 |
|
|
333 |
isResponsibleForPackage:aString
|
|
334 |
^true.
|
|
335 |
|
|
336 |
"Created: / 09-07-2011 / 14:32:20 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
337 |
"Modified (comment): / 02-03-2012 / 15:05:14 / cg"
|
|
338 |
!
|
|
339 |
|
|
340 |
managerTypeName
|
|
341 |
^ 'Git'
|
|
342 |
|
|
343 |
"Created: / 16-08-2006 / 11:05:56 / cg"
|
|
344 |
!
|
|
345 |
|
|
346 |
nameOfVersionMethodForExtensions
|
|
347 |
^ #'extensionsVersion_Git'
|
|
348 |
|
|
349 |
"Modified: / 02-03-2012 / 15:05:02 / cg"
|
|
350 |
!
|
|
351 |
|
|
352 |
nameOfVersionMethodInClasses
|
|
353 |
^ #'version_Git'
|
|
354 |
|
|
355 |
"Modified: / 02-03-2012 / 15:04:56 / cg"
|
|
356 |
!
|
|
357 |
|
|
358 |
settingsApplicationClass
|
|
359 |
"link to my settings application (needed for the settings dialog"
|
|
360 |
|
|
361 |
^ GitSourceCodeManagementSettingsAppl
|
|
362 |
|
|
363 |
"Created: / 19-04-2011 / 12:43:29 / cg"
|
|
364 |
"Modified: / 02-03-2012 / 15:04:50 / cg"
|
|
365 |
! !
|
|
366 |
|
|
367 |
!GitSourceCodeManager class methodsFor:'saving'!
|
|
368 |
|
|
369 |
savePreferencesOn:aStream
|
|
370 |
aStream nextPutLine:'GitSourceCodeManager notNil ifTrue:['.
|
|
371 |
self repositoryInfoPerModule notEmptyOrNil ifTrue:[
|
|
372 |
aStream nextPutLine:' GitSourceCodeManager repositoryInfoPerModule:' , self repositoryInfoPerModule storeString , '.'.
|
|
373 |
].
|
|
374 |
GitExecutable notNil ifTrue:[
|
|
375 |
aStream nextPutLine:' GitSourceCodeManager gitExecutable:' , GitExecutable storeString , '.'.
|
|
376 |
].
|
|
377 |
(Smalltalk at:#SourceCodeManager) == self ifTrue:[
|
|
378 |
aStream nextPutLine:' Smalltalk at:#SourceCodeManager put: GitSourceCodeManager.'.
|
|
379 |
aStream nextPutLine:' GitSourceCodeManager initializeForRepository:' , self repositoryName storeString , '.'.
|
|
380 |
] ifFalse:[
|
|
381 |
aStream nextPutLine:' GitSourceCodeManager repositoryName:' , self repositoryName storeString , '.'.
|
|
382 |
].
|
|
383 |
aStream nextPutLine:'].'.
|
|
384 |
|
|
385 |
"Created: / 09-11-2006 / 15:09:25 / cg"
|
|
386 |
"Modified: / 02-03-2012 / 15:17:42 / cg"
|
|
387 |
! !
|
|
388 |
|
|
389 |
!GitSourceCodeManager class methodsFor:'testing'!
|
|
390 |
|
|
391 |
isGit
|
|
392 |
^ true
|
|
393 |
|
|
394 |
"Created: / 02-03-2012 / 15:17:19 / cg"
|
|
395 |
! !
|
|
396 |
|
|
397 |
!GitSourceCodeManager class methodsFor:'documentation'!
|
|
398 |
|
|
399 |
version
|
|
400 |
^ '$Header: /cvs/stx/stx/libbasic3/GitSourceCodeManager.st,v 1.1 2012-03-02 14:28:01 cg Exp $'
|
|
401 |
!
|
|
402 |
|
|
403 |
version_CVS
|
|
404 |
^ '$Header: /cvs/stx/stx/libbasic3/GitSourceCodeManager.st,v 1.1 2012-03-02 14:28:01 cg Exp $'
|
|
405 |
! !
|
|
406 |
|
|
407 |
GitSourceCodeManager initialize!
|