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