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