author | Stefan Vogel <sv@exept.de> |
Fri, 08 Feb 2013 19:40:56 +0100 | |
changeset 3107 | e84a189e6b16 |
parent 2920 | 23a63370b272 |
child 3158 | f8c56a311307 |
child 3310 | abb2ad401f9b |
permissions | -rw-r--r-- |
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 |
|
2789 | 19 |
GitUpdateOptions WorkDirectory' |
2778 | 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 |
|
3107 | 62 |
| s | |
2778 | 63 |
|
3107 | 64 |
GitCommandSemaphore := (Semaphore new:10) name:'Concurrent GIT Commands'. "/ at most 10 git activities concurrently |
2778 | 65 |
GitCommitOptions := ''. |
66 |
GitUpdateOptions := ''. |
|
67 |
DisabledModules := nil. |
|
68 |
PerModuleRepositories isNil ifTrue:[ |
|
69 |
PerModuleRepositories := Dictionary new. |
|
70 |
]. |
|
71 |
||
2812
69143eafd6fc
do not check scm-command at class-init time
Claus Gittinger <cg@exept.de>
parents:
2789
diff
changeset
|
72 |
"/ will do that lazy later, to avoid making startup slower and slower... |
69143eafd6fc
do not check scm-command at class-init time
Claus Gittinger <cg@exept.de>
parents:
2789
diff
changeset
|
73 |
"/ ok := OperatingSystem canExecuteCommand:(self gitExecutable). |
69143eafd6fc
do not check scm-command at class-init time
Claus Gittinger <cg@exept.de>
parents:
2789
diff
changeset
|
74 |
"/ ok ifFalse:[ |
69143eafd6fc
do not check scm-command at class-init time
Claus Gittinger <cg@exept.de>
parents:
2789
diff
changeset
|
75 |
"/ 'GitSourceCodeManager [warning]: disabled because no >>git<< command was found' infoPrintCR. |
69143eafd6fc
do not check scm-command at class-init time
Claus Gittinger <cg@exept.de>
parents:
2789
diff
changeset
|
76 |
"/ ^ self |
69143eafd6fc
do not check scm-command at class-init time
Claus Gittinger <cg@exept.de>
parents:
2789
diff
changeset
|
77 |
"/ ]. |
2778 | 78 |
|
79 |
CacheDirectoryName isNil ifTrue:[ |
|
80 |
self initCacheDirPath. |
|
81 |
]. |
|
82 |
CachingSources isNil ifTrue:[ |
|
83 |
CachingSources := true. |
|
84 |
]. |
|
85 |
||
86 |
"/ |
|
87 |
"/ optionally set the WorkTreeDirectoryName from $STX_WORKTREE; |
|
88 |
"/ if non-nil, a working tree is kept there |
|
89 |
"/ and updated/commited files are not removed. |
|
90 |
"/ If you use a regular (make-) tree, |
|
91 |
"/ set WorkTreeDirectoryName (or the environment variable) to that. |
|
92 |
"/ |
|
93 |
"/ this is not yet finished. |
|
94 |
"/ |
|
95 |
s := OperatingSystem getEnvironment:'STX_WORKTREE'. |
|
96 |
s notNil ifTrue:[ |
|
97 |
WorkTreeDirectoryName := s. |
|
98 |
UseWorkTree := true. |
|
99 |
] |
|
100 |
||
101 |
" |
|
102 |
AbstractSourceCodeManager initialize |
|
103 |
GitSourceCodeManager initialize |
|
104 |
" |
|
105 |
||
106 |
"Created: / 04-11-1995 / 19:14:38 / cg" |
|
107 |
"Modified: / 19-12-1995 / 14:25:46 / stefan" |
|
2812
69143eafd6fc
do not check scm-command at class-init time
Claus Gittinger <cg@exept.de>
parents:
2789
diff
changeset
|
108 |
"Modified (comment): / 20-03-2012 / 19:05:00 / cg" |
2778 | 109 |
! |
110 |
||
111 |
initializeForRepository:aDirectoryName |
|
112 |
"reinitialize. |
|
113 |
Can be used from the launcher to change/configure the repository." |
|
114 |
||
2787 | 115 |
|dir| |
116 |
||
2778 | 117 |
self repositoryName:aDirectoryName. |
118 |
AbstractSourceCodeManager initialize. |
|
119 |
GitSourceCodeManager initialize. |
|
120 |
||
2787 | 121 |
(dir := aDirectoryName asFilename) exists ifFalse:[ |
122 |
dir recursiveMakeDirectory. |
|
123 |
]. |
|
124 |
(dir construct:'.git') exists ifFalse:[ |
|
2839 | 125 |
self executeGitCommand:'init' inDirectory:dir |
2787 | 126 |
]. |
127 |
||
2778 | 128 |
"Created: / 13-08-1997 / 17:20:57 / cg" |
129 |
"Modified: / 25-09-1997 / 12:28:05 / stefan" |
|
2839 | 130 |
"Modified: / 23-07-2012 / 16:16:57 / cg" |
2787 | 131 |
! |
132 |
||
133 |
initializeRepository |
|
134 |
self initializeForRepository:(self repositoryName) |
|
135 |
||
136 |
"Created: / 02-03-2012 / 16:56:21 / cg" |
|
2778 | 137 |
! ! |
138 |
||
139 |
!GitSourceCodeManager class methodsFor:'accessing'! |
|
140 |
||
2839 | 141 |
executeGitCommand:cmd inDirectory:dir |
142 |
|retCode out err| |
|
143 |
||
144 |
retCode := self |
|
145 |
executeGitCommand:cmd |
|
146 |
outputTo:(out := WriteStream on:(String new:100)) |
|
147 |
errorTo:(err := WriteStream on:(String new:100)) |
|
148 |
inDirectory:dir. |
|
149 |
retCode ifFalse:[ |
|
150 |
Transcript showCR:'-----------------------------------------------'. |
|
151 |
Transcript showCR:'out:'. |
|
152 |
Transcript showCR:out contents. |
|
153 |
Transcript showCR:'err:'. |
|
154 |
Transcript showCR:err contents. |
|
155 |
]. |
|
156 |
^ retCode |
|
157 |
||
158 |
"Created: / 23-07-2012 / 16:17:06 / cg" |
|
159 |
! |
|
160 |
||
161 |
executeGitCommand:cmd outputTo:outStreamOrNil errorTo:errStreamOrNil inDirectory:dir |
|
162 |
^ OperatingSystem |
|
163 |
executeCommand:'git ',cmd |
|
164 |
outputTo:outStreamOrNil |
|
165 |
errorTo:errStreamOrNil |
|
166 |
inDirectory:dir asFilename pathName. |
|
167 |
||
168 |
"Created: / 24-07-2012 / 09:33:29 / cg" |
|
169 |
! |
|
170 |
||
2778 | 171 |
gitBinDirectory:ignoredString |
172 |
"ignored - for backward compatibility (to read old settings files)" |
|
173 |
"Created: / 14-01-2012 / 20:49:46 / cg" |
|
174 |
! |
|
175 |
||
176 |
gitCommandTimeout |
|
177 |
^ GitCommandTimeout ? ("360" 120 seconds) |
|
178 |
||
179 |
"Modified (comment): / 08-01-2012 / 19:02:44 / cg" |
|
180 |
"Created: / 02-03-2012 / 15:23:40 / cg" |
|
181 |
! |
|
182 |
||
183 |
gitCommandTimeout:aTimeDuration |
|
184 |
GitCommandTimeout := aTimeDuration asTimeDuration. |
|
185 |
||
186 |
"Created: / 02-03-2012 / 15:23:46 / cg" |
|
187 |
! |
|
188 |
||
189 |
gitCommitOptions |
|
190 |
^ GitCommitOptions ? '' |
|
191 |
||
192 |
"Created: / 02-03-2012 / 15:23:51 / cg" |
|
193 |
! |
|
194 |
||
195 |
gitCommitOptions:aString |
|
196 |
GitCommitOptions := aString. |
|
197 |
||
198 |
"Created: / 02-03-2012 / 15:23:57 / cg" |
|
199 |
! |
|
200 |
||
201 |
gitExecutable |
|
202 |
"return the name of the git executable." |
|
203 |
||
204 |
^ GitExecutable ? 'git' |
|
205 |
||
206 |
"Created: / 02-03-2012 / 15:24:02 / cg" |
|
207 |
! |
|
208 |
||
209 |
gitExecutable:aString |
|
210 |
"set the name of the git executable." |
|
211 |
||
212 |
aString isEmptyOrNil ifTrue:[ |
|
213 |
GitExecutable := nil |
|
214 |
] ifFalse:[ |
|
215 |
GitExecutable := aString. |
|
216 |
]. |
|
217 |
||
218 |
"Modified: / 21-09-2006 / 16:41:33 / cg" |
|
219 |
"Created: / 02-03-2012 / 15:24:07 / cg" |
|
220 |
! |
|
221 |
||
222 |
gitTmpDirectory |
|
223 |
"return the name of the tmp repository. |
|
224 |
That's the directory, where temporary files are created for checkin/checkout. |
|
2920 | 225 |
If nil, the system's default tempDirectory is used." |
2778 | 226 |
|
227 |
^ (GitTempDir ? Filename tempDirectory pathName) |
|
228 |
||
229 |
" |
|
230 |
CVSTempDir := nil |
|
231 |
" |
|
232 |
||
233 |
"Created: / 02-03-2012 / 15:24:12 / cg" |
|
234 |
! |
|
235 |
||
236 |
gitTmpDirectory:aPathNameString |
|
237 |
"set the name of the tmp repository. |
|
238 |
That's the directory, where temporary files are created for checkin/checkout. |
|
2920 | 239 |
If nil, the system's default tempDirectory is used." |
2778 | 240 |
|
241 |
GitTempDir := aPathNameString |
|
242 |
||
243 |
"Created: / 02-03-2012 / 15:24:18 / cg" |
|
244 |
! |
|
245 |
||
246 |
gitUpdateOptions |
|
247 |
^ GitUpdateOptions ? '' |
|
248 |
||
249 |
"Created: / 02-03-2012 / 15:24:24 / cg" |
|
250 |
! |
|
251 |
||
252 |
gitUpdateOptions:aString |
|
253 |
GitUpdateOptions := aString. |
|
254 |
||
255 |
"Created: / 02-03-2012 / 15:24:28 / cg" |
|
256 |
! |
|
257 |
||
258 |
knownModules |
|
259 |
"return the modules, we currently know" |
|
260 |
||
261 |
PerModuleRepositories isEmptyOrNil ifTrue:[^ #() ]. |
|
262 |
^ PerModuleRepositories keys |
|
263 |
||
264 |
"Modified: / 14-01-2012 / 21:23:37 / cg" |
|
265 |
! |
|
266 |
||
267 |
knownRepositories |
|
268 |
"return the modules, we currently know" |
|
269 |
||
270 |
^ PerModuleRepositories values copyWith:DefaultRepository |
|
271 |
||
272 |
"Modified: / 14-01-2012 / 21:23:59 / cg" |
|
273 |
! |
|
274 |
||
275 |
repositoryForPackage:packageId |
|
276 |
"superclass AbstractSourceCodeManager class says that I am responsible to implement this method" |
|
277 |
||
278 |
^self getGitRepositoryForModule: ( packageId upTo:$:) |
|
279 |
||
280 |
"Modified: / 10-10-2011 / 19:38:47 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
281 |
"Modified: / 02-03-2012 / 15:25:19 / cg" |
|
282 |
! |
|
283 |
||
284 |
repositoryInfoPerModule |
|
285 |
"return the dictionary, which associates gitRepositories to module names. |
|
286 |
If no entry is contained in this dictionary for some module, |
|
287 |
the default crepository will be used." |
|
288 |
||
289 |
^ PerModuleRepositories ? #() |
|
290 |
||
291 |
"Modified (comment): / 02-03-2012 / 15:25:28 / cg" |
|
292 |
! |
|
293 |
||
294 |
repositoryInfoPerModule:aDictionary |
|
295 |
"set the dictionary, which associates repositories to module names. |
|
296 |
If no entry is contained in this dictionary for some module, |
|
297 |
the default repository will be used." |
|
298 |
||
299 |
PerModuleRepositories := aDictionary |
|
300 |
||
301 |
"Modified: / 14-01-2012 / 21:25:21 / cg" |
|
302 |
! |
|
303 |
||
304 |
repositoryName |
|
305 |
"return the name of the global repository. |
|
306 |
This is used, if no per-module repository is defined." |
|
307 |
||
308 |
^ DefaultRepository |
|
309 |
||
310 |
"Created: / 14-09-1996 / 13:22:05 / cg" |
|
311 |
"Modified: / 14-01-2012 / 21:25:42 / cg" |
|
312 |
! |
|
313 |
||
314 |
repositoryName:aDirectoryName |
|
315 |
"set the name of the repository; |
|
316 |
that's the name of the global repository, which is used |
|
317 |
if no specific repository was defined for a module." |
|
318 |
||
319 |
DisabledModules := nil. |
|
320 |
DefaultRepository := aDirectoryName. |
|
321 |
||
322 |
"Created: / 14-09-1996 / 13:22:24 / cg" |
|
323 |
"Modified: / 14-01-2012 / 21:26:17 / cg" |
|
324 |
! |
|
325 |
||
326 |
repositoryName:aRepositoryName forModule:aModuleName |
|
327 |
"set the repository which provides the sources for all |
|
328 |
classes in a particular module. |
|
329 |
This can be used from an rc-script, to specify a repository |
|
330 |
for a particular module. |
|
331 |
If left unspecified, the global (i.e. fallBack) repository is used." |
|
332 |
||
333 |
DisabledModules := nil. |
|
334 |
PerModuleRepositories at:aModuleName put:aRepositoryName |
|
335 |
||
336 |
"Modified (comment): / 14-01-2012 / 21:27:08 / cg" |
|
337 |
! |
|
338 |
||
339 |
repositoryNameForModule:aModuleName |
|
340 |
"return the repository which provides the sources for all |
|
341 |
classes in a particular module. |
|
342 |
Nil is returned for unspecified moduleRoots; in this case, |
|
343 |
the global (i.e. fallBack) repository will be used for source access." |
|
344 |
||
345 |
^ PerModuleRepositories at:aModuleName ifAbsent:nil. |
|
346 |
||
347 |
"Created: / 19-09-1997 / 06:13:06 / cg" |
|
348 |
! |
|
349 |
||
2850
4b3dec16d86b
initial implementation for package checkin
Claus Gittinger <cg@exept.de>
parents:
2839
diff
changeset
|
350 |
repositoryNameForPackage:packageId |
4b3dec16d86b
initial implementation for package checkin
Claus Gittinger <cg@exept.de>
parents:
2839
diff
changeset
|
351 |
^ self repositoryNameForModule:(packageId upTo:$:) |
2778 | 352 |
|
353 |
"Created: / 10-10-2011 / 19:44:51 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
2850
4b3dec16d86b
initial implementation for package checkin
Claus Gittinger <cg@exept.de>
parents:
2839
diff
changeset
|
354 |
"Modified (format): / 25-07-2012 / 18:23:06 / cg" |
2789 | 355 |
! |
356 |
||
357 |
workDirectory |
|
358 |
^ WorkDirectory |
|
359 |
||
360 |
"Created: / 03-03-2012 / 11:08:29 / cg" |
|
361 |
! |
|
362 |
||
363 |
workDirectory:aPath |
|
364 |
WorkDirectory := aPath |
|
365 |
||
366 |
"Created: / 03-03-2012 / 11:08:37 / cg" |
|
2778 | 367 |
! ! |
368 |
||
369 |
!GitSourceCodeManager class methodsFor:'basic administration'! |
|
370 |
||
2850
4b3dec16d86b
initial implementation for package checkin
Claus Gittinger <cg@exept.de>
parents:
2839
diff
changeset
|
371 |
addFile:fileName inDirectory:dirPath |
4b3dec16d86b
initial implementation for package checkin
Claus Gittinger <cg@exept.de>
parents:
2839
diff
changeset
|
372 |
self executeGitCommand:('add "',fileName,'"') inDirectory:dirPath |
4b3dec16d86b
initial implementation for package checkin
Claus Gittinger <cg@exept.de>
parents:
2839
diff
changeset
|
373 |
|
4b3dec16d86b
initial implementation for package checkin
Claus Gittinger <cg@exept.de>
parents:
2839
diff
changeset
|
374 |
"Created: / 25-07-2012 / 23:07:57 / cg" |
4b3dec16d86b
initial implementation for package checkin
Claus Gittinger <cg@exept.de>
parents:
2839
diff
changeset
|
375 |
! |
4b3dec16d86b
initial implementation for package checkin
Claus Gittinger <cg@exept.de>
parents:
2839
diff
changeset
|
376 |
|
2839 | 377 |
checkForExistingContainer:fileName inModule:moduleName directory:dirName |
378 |
"check for a container to be present" |
|
379 |
||
380 |
|path subDir| |
|
381 |
||
382 |
path := (self repositoryName asFilename construct:moduleName) construct:dirName. |
|
383 |
path exists ifFalse:[ |
|
384 |
subDir := moduleName asFilename construct:dirName. |
|
385 |
self executeGitCommand:'checkout ',subDir name inDirectory:self repositoryName. |
|
386 |
]. |
|
387 |
^ (path construct:fileName) exists |
|
388 |
||
389 |
"Created: / 23-07-2012 / 16:21:02 / cg" |
|
390 |
! |
|
391 |
||
392 |
checkForExistingModule:moduleName |
|
393 |
"check for a module to be present" |
|
394 |
||
395 |
|path subDir| |
|
396 |
||
397 |
path := self repositoryName asFilename construct:moduleName. |
|
398 |
path exists ifFalse:[ |
|
399 |
subDir := moduleName asFilename. |
|
400 |
self executeGitCommand:'checkout ',subDir name inDirectory:self repositoryName. |
|
401 |
self halt. |
|
402 |
]. |
|
403 |
^ path exists |
|
404 |
||
405 |
"Created: / 23-07-2012 / 18:44:27 / cg" |
|
406 |
! |
|
407 |
||
408 |
checkForExistingModule:moduleName directory:packageDir |
|
409 |
"check for a package directory to be present" |
|
410 |
||
411 |
|path subDir| |
|
412 |
||
413 |
path := (self repositoryName asFilename construct:moduleName) construct:packageDir. |
|
414 |
path exists ifFalse:[ |
|
415 |
subDir := moduleName asFilename construct:packageDir. |
|
416 |
self executeGitCommand:'checkout ',subDir name inDirectory:self repositoryName. |
|
417 |
]. |
|
418 |
^ path exists |
|
419 |
||
420 |
"Created: / 23-07-2012 / 19:07:34 / cg" |
|
421 |
! |
|
422 |
||
2850
4b3dec16d86b
initial implementation for package checkin
Claus Gittinger <cg@exept.de>
parents:
2839
diff
changeset
|
423 |
checkin:containerFilename text:someText directory:packageDir module:moduleDir logMessage:logMessage force:force |
4b3dec16d86b
initial implementation for package checkin
Claus Gittinger <cg@exept.de>
parents:
2839
diff
changeset
|
424 |
|path relPath| |
4b3dec16d86b
initial implementation for package checkin
Claus Gittinger <cg@exept.de>
parents:
2839
diff
changeset
|
425 |
|
4b3dec16d86b
initial implementation for package checkin
Claus Gittinger <cg@exept.de>
parents:
2839
diff
changeset
|
426 |
relPath := (moduleDir asFilename construct:packageDir) construct:containerFilename. |
4b3dec16d86b
initial implementation for package checkin
Claus Gittinger <cg@exept.de>
parents:
2839
diff
changeset
|
427 |
path := self repositoryName asFilename construct:relPath. |
4b3dec16d86b
initial implementation for package checkin
Claus Gittinger <cg@exept.de>
parents:
2839
diff
changeset
|
428 |
path contents: someText. |
4b3dec16d86b
initial implementation for package checkin
Claus Gittinger <cg@exept.de>
parents:
2839
diff
changeset
|
429 |
|
4b3dec16d86b
initial implementation for package checkin
Claus Gittinger <cg@exept.de>
parents:
2839
diff
changeset
|
430 |
^ self checkinClass:nil |
4b3dec16d86b
initial implementation for package checkin
Claus Gittinger <cg@exept.de>
parents:
2839
diff
changeset
|
431 |
fileName:containerFilename |
4b3dec16d86b
initial implementation for package checkin
Claus Gittinger <cg@exept.de>
parents:
2839
diff
changeset
|
432 |
directory:packageDir |
4b3dec16d86b
initial implementation for package checkin
Claus Gittinger <cg@exept.de>
parents:
2839
diff
changeset
|
433 |
module:moduleDir |
4b3dec16d86b
initial implementation for package checkin
Claus Gittinger <cg@exept.de>
parents:
2839
diff
changeset
|
434 |
source:nil |
4b3dec16d86b
initial implementation for package checkin
Claus Gittinger <cg@exept.de>
parents:
2839
diff
changeset
|
435 |
logMessage:logMessage |
4b3dec16d86b
initial implementation for package checkin
Claus Gittinger <cg@exept.de>
parents:
2839
diff
changeset
|
436 |
force:force |
4b3dec16d86b
initial implementation for package checkin
Claus Gittinger <cg@exept.de>
parents:
2839
diff
changeset
|
437 |
|
4b3dec16d86b
initial implementation for package checkin
Claus Gittinger <cg@exept.de>
parents:
2839
diff
changeset
|
438 |
"Created: / 25-07-2012 / 14:29:10 / cg" |
4b3dec16d86b
initial implementation for package checkin
Claus Gittinger <cg@exept.de>
parents:
2839
diff
changeset
|
439 |
! |
4b3dec16d86b
initial implementation for package checkin
Claus Gittinger <cg@exept.de>
parents:
2839
diff
changeset
|
440 |
|
4b3dec16d86b
initial implementation for package checkin
Claus Gittinger <cg@exept.de>
parents:
2839
diff
changeset
|
441 |
checkinClass:aClassOrNil fileName:classFileName directory:packageDir module:moduleDir source:sourceFileOrNil logMessage:logMessage force:force |
2839 | 442 |
"checkin of a class into the source repository. |
443 |
Return true if ok, false if not." |
|
444 |
||
445 |
|path relPath logArg out err| |
|
446 |
||
447 |
relPath := (moduleDir asFilename construct:packageDir) construct:classFileName. |
|
448 |
path := self repositoryName asFilename construct:relPath. |
|
2850
4b3dec16d86b
initial implementation for package checkin
Claus Gittinger <cg@exept.de>
parents:
2839
diff
changeset
|
449 |
sourceFileOrNil notNil ifTrue:[ |
4b3dec16d86b
initial implementation for package checkin
Claus Gittinger <cg@exept.de>
parents:
2839
diff
changeset
|
450 |
sourceFileOrNil asFilename moveTo: path. |
4b3dec16d86b
initial implementation for package checkin
Claus Gittinger <cg@exept.de>
parents:
2839
diff
changeset
|
451 |
]. |
2839 | 452 |
|
453 |
(self executeGitCommand:'add ',relPath name inDirectory:self repositoryName) ifFalse:[ |
|
454 |
self halt |
|
455 |
]. |
|
456 |
||
457 |
out := WriteStream on:(String new:100). |
|
458 |
err := WriteStream on:(String new:100). |
|
459 |
(self executeGitCommand:'status --porcelain' outputTo:out errorTo:err inDirectory:self repositoryName) ifFalse:[ |
|
460 |
self halt. |
|
461 |
]. |
|
462 |
(out contents withoutSeparators isEmptyOrNil) ifTrue:[ |
|
463 |
(err contents withoutSeparators isEmptyOrNil) ifTrue:[ |
|
464 |
"/ nothing to commit |
|
465 |
^ true |
|
466 |
]. |
|
467 |
]. |
|
468 |
logArg := logMessage copyReplaceAll:$" withAll:''''''. |
|
469 |
(self executeGitCommand:'commit -m "',logArg,'"' inDirectory:self repositoryName) ifFalse:[ |
|
470 |
self halt |
|
471 |
]. |
|
472 |
^ true |
|
473 |
||
474 |
"Created: / 23-07-2012 / 20:05:14 / cg" |
|
475 |
! |
|
476 |
||
2850
4b3dec16d86b
initial implementation for package checkin
Claus Gittinger <cg@exept.de>
parents:
2839
diff
changeset
|
477 |
commitRepository:repositoryDirectory logMessage:logMessage |
4b3dec16d86b
initial implementation for package checkin
Claus Gittinger <cg@exept.de>
parents:
2839
diff
changeset
|
478 |
|logArg| |
4b3dec16d86b
initial implementation for package checkin
Claus Gittinger <cg@exept.de>
parents:
2839
diff
changeset
|
479 |
|
4b3dec16d86b
initial implementation for package checkin
Claus Gittinger <cg@exept.de>
parents:
2839
diff
changeset
|
480 |
self |
4b3dec16d86b
initial implementation for package checkin
Claus Gittinger <cg@exept.de>
parents:
2839
diff
changeset
|
481 |
executeGitCommand:('status') |
4b3dec16d86b
initial implementation for package checkin
Claus Gittinger <cg@exept.de>
parents:
2839
diff
changeset
|
482 |
outputTo:Transcript |
4b3dec16d86b
initial implementation for package checkin
Claus Gittinger <cg@exept.de>
parents:
2839
diff
changeset
|
483 |
errorTo:Transcript |
4b3dec16d86b
initial implementation for package checkin
Claus Gittinger <cg@exept.de>
parents:
2839
diff
changeset
|
484 |
inDirectory:repositoryDirectory. |
4b3dec16d86b
initial implementation for package checkin
Claus Gittinger <cg@exept.de>
parents:
2839
diff
changeset
|
485 |
|
4b3dec16d86b
initial implementation for package checkin
Claus Gittinger <cg@exept.de>
parents:
2839
diff
changeset
|
486 |
logArg := logMessage copyReplaceAll:$" withAll:''''''. |
4b3dec16d86b
initial implementation for package checkin
Claus Gittinger <cg@exept.de>
parents:
2839
diff
changeset
|
487 |
self |
4b3dec16d86b
initial implementation for package checkin
Claus Gittinger <cg@exept.de>
parents:
2839
diff
changeset
|
488 |
executeGitCommand:('commit -m "',logArg,'"') |
4b3dec16d86b
initial implementation for package checkin
Claus Gittinger <cg@exept.de>
parents:
2839
diff
changeset
|
489 |
outputTo:Transcript |
4b3dec16d86b
initial implementation for package checkin
Claus Gittinger <cg@exept.de>
parents:
2839
diff
changeset
|
490 |
errorTo:Transcript |
4b3dec16d86b
initial implementation for package checkin
Claus Gittinger <cg@exept.de>
parents:
2839
diff
changeset
|
491 |
inDirectory:repositoryDirectory. |
4b3dec16d86b
initial implementation for package checkin
Claus Gittinger <cg@exept.de>
parents:
2839
diff
changeset
|
492 |
|
4b3dec16d86b
initial implementation for package checkin
Claus Gittinger <cg@exept.de>
parents:
2839
diff
changeset
|
493 |
"Created: / 25-07-2012 / 22:47:57 / cg" |
4b3dec16d86b
initial implementation for package checkin
Claus Gittinger <cg@exept.de>
parents:
2839
diff
changeset
|
494 |
! |
4b3dec16d86b
initial implementation for package checkin
Claus Gittinger <cg@exept.de>
parents:
2839
diff
changeset
|
495 |
|
2778 | 496 |
createContainerFor:aClass inModule:moduleName directory:dirName container:fileName |
497 |
"create a new container & check into it an initial version of aClass" |
|
498 |
||
499 |
^ self shouldImplement |
|
2839 | 500 |
! |
501 |
||
502 |
createModule:moduleName |
|
503 |
"create a new module directory" |
|
504 |
||
505 |
|dir| |
|
506 |
||
507 |
dir := self repositoryName asFilename construct:moduleName. |
|
508 |
dir exists ifTrue:[^ true]. |
|
509 |
dir recursiveMakeDirectory. |
|
510 |
^ dir exists. |
|
511 |
||
512 |
"Created: / 23-07-2012 / 19:04:51 / cg" |
|
513 |
! |
|
514 |
||
515 |
createModule:moduleName directory:directory |
|
516 |
"create a new package directory" |
|
517 |
||
518 |
|dir| |
|
519 |
||
520 |
dir := (self repositoryName asFilename construct:moduleName) construct:directory. |
|
521 |
dir exists ifTrue:[^ true]. |
|
522 |
dir recursiveMakeDirectory. |
|
523 |
^ dir exists. |
|
524 |
||
525 |
"Created: / 23-07-2012 / 19:08:22 / cg" |
|
526 |
! |
|
527 |
||
528 |
initialRevisionStringFor:aClass inModule:moduleDir directory:packageDir container:fileName |
|
529 |
"return a string usable as initial revision string" |
|
530 |
||
531 |
^ self |
|
532 |
revisionStringFor:aClass |
|
533 |
inModule:moduleDir |
|
534 |
directory:packageDir |
|
535 |
container:fileName |
|
536 |
revision:'1' |
|
537 |
||
538 |
"Created: / 23-07-2012 / 18:40:25 / cg" |
|
539 |
! |
|
540 |
||
541 |
revisionInfoFromString:aString |
|
542 |
"{ Pragma: +optSpace }" |
|
543 |
||
544 |
"return a VersionInfo object filled with revision info. |
|
545 |
This extracts the relevant info from aString." |
|
546 |
||
547 |
^ self revisionInfoFromStandardVersionString:aString |
|
548 |
||
549 |
" |
|
550 |
self revisionInfoFromString:'Path: stx/libbasic/Array.st, Version: 123, User: cg, Time: 2011-12-21T21:03:08.826' |
|
551 |
" |
|
552 |
||
553 |
"Created: / 23-07-2012 / 19:02:56 / cg" |
|
554 |
! |
|
555 |
||
556 |
revisionStringFor:aClass inModule:moduleDir directory:packageDir container:fileName revision:revisionString |
|
557 |
"utility function: return a string usable as initial revision string" |
|
558 |
||
559 |
^ self standardRevisionStringFor:aClass inModule:moduleDir directory:packageDir container:fileName revision:revisionString |
|
560 |
||
561 |
"Created: / 23-07-2012 / 19:01:17 / cg" |
|
2850
4b3dec16d86b
initial implementation for package checkin
Claus Gittinger <cg@exept.de>
parents:
2839
diff
changeset
|
562 |
! |
4b3dec16d86b
initial implementation for package checkin
Claus Gittinger <cg@exept.de>
parents:
2839
diff
changeset
|
563 |
|
4b3dec16d86b
initial implementation for package checkin
Claus Gittinger <cg@exept.de>
parents:
2839
diff
changeset
|
564 |
updateRepository:repositoryDirectory |
4b3dec16d86b
initial implementation for package checkin
Claus Gittinger <cg@exept.de>
parents:
2839
diff
changeset
|
565 |
self executeGitCommand:'update' inDirectory:repositoryDirectory |
4b3dec16d86b
initial implementation for package checkin
Claus Gittinger <cg@exept.de>
parents:
2839
diff
changeset
|
566 |
|
4b3dec16d86b
initial implementation for package checkin
Claus Gittinger <cg@exept.de>
parents:
2839
diff
changeset
|
567 |
"Created: / 25-07-2012 / 18:55:56 / cg" |
2778 | 568 |
! ! |
569 |
||
570 |
!GitSourceCodeManager class methodsFor:'debugging'! |
|
571 |
||
572 |
verboseSourceCodeAccess |
|
573 |
^ Verbose ? false |
|
574 |
! |
|
575 |
||
576 |
verboseSourceCodeAccess:aBoolean |
|
577 |
Verbose := aBoolean |
|
578 |
! ! |
|
579 |
||
580 |
!GitSourceCodeManager class methodsFor:'queries'! |
|
581 |
||
2850
4b3dec16d86b
initial implementation for package checkin
Claus Gittinger <cg@exept.de>
parents:
2839
diff
changeset
|
582 |
isContainerBased |
4b3dec16d86b
initial implementation for package checkin
Claus Gittinger <cg@exept.de>
parents:
2839
diff
changeset
|
583 |
^ false |
4b3dec16d86b
initial implementation for package checkin
Claus Gittinger <cg@exept.de>
parents:
2839
diff
changeset
|
584 |
|
4b3dec16d86b
initial implementation for package checkin
Claus Gittinger <cg@exept.de>
parents:
2839
diff
changeset
|
585 |
"Created: / 24-07-2012 / 18:21:32 / cg" |
4b3dec16d86b
initial implementation for package checkin
Claus Gittinger <cg@exept.de>
parents:
2839
diff
changeset
|
586 |
! |
4b3dec16d86b
initial implementation for package checkin
Claus Gittinger <cg@exept.de>
parents:
2839
diff
changeset
|
587 |
|
2778 | 588 |
isResponsibleForPackage:aString |
589 |
^true. |
|
590 |
||
591 |
"Created: / 09-07-2011 / 14:32:20 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
592 |
"Modified (comment): / 02-03-2012 / 15:05:14 / cg" |
|
593 |
! |
|
594 |
||
595 |
managerTypeName |
|
596 |
^ 'Git' |
|
597 |
||
598 |
"Created: / 16-08-2006 / 11:05:56 / cg" |
|
599 |
! |
|
600 |
||
601 |
nameOfVersionMethodForExtensions |
|
602 |
^ #'extensionsVersion_Git' |
|
603 |
||
604 |
"Modified: / 02-03-2012 / 15:05:02 / cg" |
|
605 |
! |
|
606 |
||
607 |
nameOfVersionMethodInClasses |
|
608 |
^ #'version_Git' |
|
609 |
||
610 |
"Modified: / 02-03-2012 / 15:04:56 / cg" |
|
611 |
! |
|
612 |
||
613 |
settingsApplicationClass |
|
614 |
"link to my settings application (needed for the settings dialog" |
|
615 |
||
616 |
^ GitSourceCodeManagementSettingsAppl |
|
617 |
||
618 |
"Created: / 19-04-2011 / 12:43:29 / cg" |
|
619 |
"Modified: / 02-03-2012 / 15:04:50 / cg" |
|
620 |
! ! |
|
621 |
||
622 |
!GitSourceCodeManager class methodsFor:'saving'! |
|
623 |
||
624 |
savePreferencesOn:aStream |
|
625 |
aStream nextPutLine:'GitSourceCodeManager notNil ifTrue:['. |
|
626 |
self repositoryInfoPerModule notEmptyOrNil ifTrue:[ |
|
627 |
aStream nextPutLine:' GitSourceCodeManager repositoryInfoPerModule:' , self repositoryInfoPerModule storeString , '.'. |
|
628 |
]. |
|
629 |
GitExecutable notNil ifTrue:[ |
|
630 |
aStream nextPutLine:' GitSourceCodeManager gitExecutable:' , GitExecutable storeString , '.'. |
|
631 |
]. |
|
632 |
(Smalltalk at:#SourceCodeManager) == self ifTrue:[ |
|
633 |
aStream nextPutLine:' Smalltalk at:#SourceCodeManager put: GitSourceCodeManager.'. |
|
634 |
aStream nextPutLine:' GitSourceCodeManager initializeForRepository:' , self repositoryName storeString , '.'. |
|
635 |
] ifFalse:[ |
|
636 |
aStream nextPutLine:' GitSourceCodeManager repositoryName:' , self repositoryName storeString , '.'. |
|
637 |
]. |
|
638 |
aStream nextPutLine:'].'. |
|
639 |
||
640 |
"Created: / 09-11-2006 / 15:09:25 / cg" |
|
641 |
"Modified: / 02-03-2012 / 15:17:42 / cg" |
|
642 |
! ! |
|
643 |
||
644 |
!GitSourceCodeManager class methodsFor:'testing'! |
|
645 |
||
646 |
isGit |
|
647 |
^ true |
|
648 |
||
649 |
"Created: / 02-03-2012 / 15:17:19 / cg" |
|
650 |
! ! |
|
651 |
||
652 |
!GitSourceCodeManager class methodsFor:'documentation'! |
|
653 |
||
654 |
version |
|
3107 | 655 |
^ '$Header: /cvs/stx/stx/libbasic3/GitSourceCodeManager.st,v 1.8 2013-02-08 18:40:56 stefan Exp $' |
2778 | 656 |
! |
657 |
||
658 |
version_CVS |
|
3107 | 659 |
^ '$Header: /cvs/stx/stx/libbasic3/GitSourceCodeManager.st,v 1.8 2013-02-08 18:40:56 stefan Exp $' |
2778 | 660 |
! ! |
661 |
||
3107 | 662 |
|
2778 | 663 |
GitSourceCodeManager initialize! |