author | Merge Script |
Fri, 08 Apr 2016 07:05:17 +0200 | |
branch | jv |
changeset 3980 | 8c574e894f77 |
parent 3838 | 474d8ec95b33 |
parent 3978 | f41428f4ff65 |
child 4053 | 7817fc8db06e |
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 |
||
66 |
initialize |
|
3107 | 67 |
| s | |
2778 | 68 |
|
3107 | 69 |
GitCommandSemaphore := (Semaphore new:10) name:'Concurrent GIT Commands'. "/ at most 10 git activities concurrently |
2778 | 70 |
GitCommitOptions := ''. |
71 |
GitUpdateOptions := ''. |
|
72 |
DisabledModules := nil. |
|
73 |
PerModuleRepositories isNil ifTrue:[ |
|
74 |
PerModuleRepositories := Dictionary new. |
|
75 |
]. |
|
76 |
||
2812
69143eafd6fc
do not check scm-command at class-init time
Claus Gittinger <cg@exept.de>
parents:
2789
diff
changeset
|
77 |
"/ 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
|
78 |
"/ ok := OperatingSystem canExecuteCommand:(self gitExecutable). |
69143eafd6fc
do not check scm-command at class-init time
Claus Gittinger <cg@exept.de>
parents:
2789
diff
changeset
|
79 |
"/ ok ifFalse:[ |
69143eafd6fc
do not check scm-command at class-init time
Claus Gittinger <cg@exept.de>
parents:
2789
diff
changeset
|
80 |
"/ '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
|
81 |
"/ ^ self |
69143eafd6fc
do not check scm-command at class-init time
Claus Gittinger <cg@exept.de>
parents:
2789
diff
changeset
|
82 |
"/ ]. |
2778 | 83 |
|
3978 | 84 |
"/ CacheDirectoryName isNil ifTrue:[ |
85 |
"/ self initCacheDirPath. |
|
86 |
"/ ]. |
|
87 |
"/ CachingSources isNil ifTrue:[ |
|
88 |
"/ CachingSources := true. |
|
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 |
|
2839 | 382 |
checkForExistingContainer:fileName inModule:moduleName directory:dirName |
383 |
"check for a container to be present" |
|
384 |
||
385 |
|path subDir| |
|
386 |
||
387 |
path := (self repositoryName asFilename construct:moduleName) construct:dirName. |
|
388 |
path exists ifFalse:[ |
|
389 |
subDir := moduleName asFilename construct:dirName. |
|
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" |
|
395 |
! |
|
396 |
||
397 |
checkForExistingModule:moduleName |
|
398 |
"check for a module to be present" |
|
399 |
||
400 |
|path subDir| |
|
401 |
||
402 |
path := self repositoryName asFilename construct:moduleName. |
|
403 |
path exists ifFalse:[ |
|
404 |
subDir := moduleName asFilename. |
|
405 |
self executeGitCommand:'checkout ',subDir name inDirectory:self repositoryName. |
|
3310 | 406 |
self breakPoint:#cg. |
2839 | 407 |
]. |
408 |
^ path exists |
|
409 |
||
410 |
"Created: / 23-07-2012 / 18:44:27 / cg" |
|
411 |
! |
|
412 |
||
413 |
checkForExistingModule:moduleName directory:packageDir |
|
414 |
"check for a package directory to be present" |
|
415 |
||
416 |
|path subDir| |
|
417 |
||
418 |
path := (self repositoryName asFilename construct:moduleName) construct:packageDir. |
|
419 |
path exists ifFalse:[ |
|
420 |
subDir := moduleName asFilename construct:packageDir. |
|
421 |
self executeGitCommand:'checkout ',subDir name inDirectory:self repositoryName. |
|
422 |
]. |
|
423 |
^ path exists |
|
424 |
||
425 |
"Created: / 23-07-2012 / 19:07:34 / cg" |
|
426 |
! |
|
427 |
||
2850
4b3dec16d86b
initial implementation for package checkin
Claus Gittinger <cg@exept.de>
parents:
2839
diff
changeset
|
428 |
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
|
429 |
|path relPath| |
4b3dec16d86b
initial implementation for package checkin
Claus Gittinger <cg@exept.de>
parents:
2839
diff
changeset
|
430 |
|
4b3dec16d86b
initial implementation for package checkin
Claus Gittinger <cg@exept.de>
parents:
2839
diff
changeset
|
431 |
relPath := (moduleDir asFilename construct:packageDir) construct:containerFilename. |
4b3dec16d86b
initial implementation for package checkin
Claus Gittinger <cg@exept.de>
parents:
2839
diff
changeset
|
432 |
path := self repositoryName asFilename construct:relPath. |
4b3dec16d86b
initial implementation for package checkin
Claus Gittinger <cg@exept.de>
parents:
2839
diff
changeset
|
433 |
path contents: someText. |
4b3dec16d86b
initial implementation for package checkin
Claus Gittinger <cg@exept.de>
parents:
2839
diff
changeset
|
434 |
|
4b3dec16d86b
initial implementation for package checkin
Claus Gittinger <cg@exept.de>
parents:
2839
diff
changeset
|
435 |
^ self checkinClass:nil |
4b3dec16d86b
initial implementation for package checkin
Claus Gittinger <cg@exept.de>
parents:
2839
diff
changeset
|
436 |
fileName:containerFilename |
4b3dec16d86b
initial implementation for package checkin
Claus Gittinger <cg@exept.de>
parents:
2839
diff
changeset
|
437 |
directory:packageDir |
4b3dec16d86b
initial implementation for package checkin
Claus Gittinger <cg@exept.de>
parents:
2839
diff
changeset
|
438 |
module:moduleDir |
4b3dec16d86b
initial implementation for package checkin
Claus Gittinger <cg@exept.de>
parents:
2839
diff
changeset
|
439 |
source:nil |
4b3dec16d86b
initial implementation for package checkin
Claus Gittinger <cg@exept.de>
parents:
2839
diff
changeset
|
440 |
logMessage:logMessage |
4b3dec16d86b
initial implementation for package checkin
Claus Gittinger <cg@exept.de>
parents:
2839
diff
changeset
|
441 |
force:force |
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 |
"Created: / 25-07-2012 / 14:29:10 / cg" |
4b3dec16d86b
initial implementation for package checkin
Claus Gittinger <cg@exept.de>
parents:
2839
diff
changeset
|
444 |
! |
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 |
checkinClass:aClassOrNil fileName:classFileName directory:packageDir module:moduleDir source:sourceFileOrNil logMessage:logMessage force:force |
2839 | 447 |
"checkin of a class into the source repository. |
448 |
Return true if ok, false if not." |
|
449 |
||
450 |
|path relPath logArg out err| |
|
451 |
||
452 |
relPath := (moduleDir asFilename construct:packageDir) construct:classFileName. |
|
453 |
path := self repositoryName asFilename construct:relPath. |
|
2850
4b3dec16d86b
initial implementation for package checkin
Claus Gittinger <cg@exept.de>
parents:
2839
diff
changeset
|
454 |
sourceFileOrNil notNil ifTrue:[ |
4b3dec16d86b
initial implementation for package checkin
Claus Gittinger <cg@exept.de>
parents:
2839
diff
changeset
|
455 |
sourceFileOrNil asFilename moveTo: path. |
4b3dec16d86b
initial implementation for package checkin
Claus Gittinger <cg@exept.de>
parents:
2839
diff
changeset
|
456 |
]. |
2839 | 457 |
|
458 |
(self executeGitCommand:'add ',relPath name inDirectory:self repositoryName) ifFalse:[ |
|
3310 | 459 |
self halt:'git command failed' |
2839 | 460 |
]. |
461 |
||
462 |
out := WriteStream on:(String new:100). |
|
463 |
err := WriteStream on:(String new:100). |
|
464 |
(self executeGitCommand:'status --porcelain' outputTo:out errorTo:err inDirectory:self repositoryName) ifFalse:[ |
|
3310 | 465 |
self halt:'git command failed' |
2839 | 466 |
]. |
467 |
(out contents withoutSeparators isEmptyOrNil) ifTrue:[ |
|
468 |
(err contents withoutSeparators isEmptyOrNil) ifTrue:[ |
|
469 |
"/ nothing to commit |
|
470 |
^ true |
|
471 |
]. |
|
472 |
]. |
|
473 |
logArg := logMessage copyReplaceAll:$" withAll:''''''. |
|
474 |
(self executeGitCommand:'commit -m "',logArg,'"' inDirectory:self repositoryName) ifFalse:[ |
|
3310 | 475 |
self halt:'git command failed' |
2839 | 476 |
]. |
477 |
^ true |
|
478 |
||
479 |
"Created: / 23-07-2012 / 20:05:14 / cg" |
|
480 |
! |
|
481 |
||
2850
4b3dec16d86b
initial implementation for package checkin
Claus Gittinger <cg@exept.de>
parents:
2839
diff
changeset
|
482 |
commitRepository:repositoryDirectory logMessage:logMessage |
4b3dec16d86b
initial implementation for package checkin
Claus Gittinger <cg@exept.de>
parents:
2839
diff
changeset
|
483 |
|logArg| |
4b3dec16d86b
initial implementation for package checkin
Claus Gittinger <cg@exept.de>
parents:
2839
diff
changeset
|
484 |
|
4b3dec16d86b
initial implementation for package checkin
Claus Gittinger <cg@exept.de>
parents:
2839
diff
changeset
|
485 |
self |
4b3dec16d86b
initial implementation for package checkin
Claus Gittinger <cg@exept.de>
parents:
2839
diff
changeset
|
486 |
executeGitCommand:('status') |
4b3dec16d86b
initial implementation for package checkin
Claus Gittinger <cg@exept.de>
parents:
2839
diff
changeset
|
487 |
outputTo:Transcript |
4b3dec16d86b
initial implementation for package checkin
Claus Gittinger <cg@exept.de>
parents:
2839
diff
changeset
|
488 |
errorTo:Transcript |
4b3dec16d86b
initial implementation for package checkin
Claus Gittinger <cg@exept.de>
parents:
2839
diff
changeset
|
489 |
inDirectory:repositoryDirectory. |
4b3dec16d86b
initial implementation for package checkin
Claus Gittinger <cg@exept.de>
parents:
2839
diff
changeset
|
490 |
|
4b3dec16d86b
initial implementation for package checkin
Claus Gittinger <cg@exept.de>
parents:
2839
diff
changeset
|
491 |
logArg := logMessage copyReplaceAll:$" withAll:''''''. |
4b3dec16d86b
initial implementation for package checkin
Claus Gittinger <cg@exept.de>
parents:
2839
diff
changeset
|
492 |
self |
4b3dec16d86b
initial implementation for package checkin
Claus Gittinger <cg@exept.de>
parents:
2839
diff
changeset
|
493 |
executeGitCommand:('commit -m "',logArg,'"') |
4b3dec16d86b
initial implementation for package checkin
Claus Gittinger <cg@exept.de>
parents:
2839
diff
changeset
|
494 |
outputTo:Transcript |
4b3dec16d86b
initial implementation for package checkin
Claus Gittinger <cg@exept.de>
parents:
2839
diff
changeset
|
495 |
errorTo:Transcript |
4b3dec16d86b
initial implementation for package checkin
Claus Gittinger <cg@exept.de>
parents:
2839
diff
changeset
|
496 |
inDirectory:repositoryDirectory. |
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 |
"Created: / 25-07-2012 / 22:47:57 / cg" |
4b3dec16d86b
initial implementation for package checkin
Claus Gittinger <cg@exept.de>
parents:
2839
diff
changeset
|
499 |
! |
4b3dec16d86b
initial implementation for package checkin
Claus Gittinger <cg@exept.de>
parents:
2839
diff
changeset
|
500 |
|
2778 | 501 |
createContainerFor:aClass inModule:moduleName directory:dirName container:fileName |
502 |
"create a new container & check into it an initial version of aClass" |
|
503 |
||
504 |
^ self shouldImplement |
|
2839 | 505 |
! |
506 |
||
507 |
createModule:moduleName |
|
508 |
"create a new module directory" |
|
509 |
||
510 |
|dir| |
|
511 |
||
512 |
dir := self repositoryName asFilename construct:moduleName. |
|
513 |
dir exists ifTrue:[^ true]. |
|
514 |
dir recursiveMakeDirectory. |
|
515 |
^ dir exists. |
|
516 |
||
517 |
"Created: / 23-07-2012 / 19:04:51 / cg" |
|
518 |
! |
|
519 |
||
520 |
createModule:moduleName directory:directory |
|
521 |
"create a new package directory" |
|
522 |
||
523 |
|dir| |
|
524 |
||
525 |
dir := (self repositoryName asFilename construct:moduleName) construct:directory. |
|
526 |
dir exists ifTrue:[^ true]. |
|
527 |
dir recursiveMakeDirectory. |
|
528 |
^ dir exists. |
|
529 |
||
530 |
"Created: / 23-07-2012 / 19:08:22 / cg" |
|
531 |
! |
|
532 |
||
533 |
initialRevisionStringFor:aClass inModule:moduleDir directory:packageDir container:fileName |
|
534 |
"return a string usable as initial revision string" |
|
535 |
||
536 |
^ self |
|
537 |
revisionStringFor:aClass |
|
538 |
inModule:moduleDir |
|
539 |
directory:packageDir |
|
540 |
container:fileName |
|
541 |
revision:'1' |
|
542 |
||
543 |
"Created: / 23-07-2012 / 18:40:25 / cg" |
|
544 |
! |
|
545 |
||
546 |
revisionInfoFromString:aString |
|
547 |
"{ Pragma: +optSpace }" |
|
548 |
||
549 |
"return a VersionInfo object filled with revision info. |
|
550 |
This extracts the relevant info from aString." |
|
551 |
||
552 |
^ self revisionInfoFromStandardVersionString:aString |
|
553 |
||
554 |
" |
|
555 |
self revisionInfoFromString:'Path: stx/libbasic/Array.st, Version: 123, User: cg, Time: 2011-12-21T21:03:08.826' |
|
556 |
" |
|
557 |
||
558 |
"Created: / 23-07-2012 / 19:02:56 / cg" |
|
559 |
! |
|
560 |
||
2850
4b3dec16d86b
initial implementation for package checkin
Claus Gittinger <cg@exept.de>
parents:
2839
diff
changeset
|
561 |
updateRepository:repositoryDirectory |
4b3dec16d86b
initial implementation for package checkin
Claus Gittinger <cg@exept.de>
parents:
2839
diff
changeset
|
562 |
self executeGitCommand:'update' inDirectory:repositoryDirectory |
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 |
"Created: / 25-07-2012 / 18:55:56 / cg" |
2778 | 565 |
! ! |
566 |
||
567 |
!GitSourceCodeManager class methodsFor:'debugging'! |
|
568 |
||
569 |
verboseSourceCodeAccess |
|
570 |
^ Verbose ? false |
|
571 |
! |
|
572 |
||
573 |
verboseSourceCodeAccess:aBoolean |
|
574 |
Verbose := aBoolean |
|
575 |
! ! |
|
576 |
||
577 |
!GitSourceCodeManager class methodsFor:'queries'! |
|
578 |
||
2850
4b3dec16d86b
initial implementation for package checkin
Claus Gittinger <cg@exept.de>
parents:
2839
diff
changeset
|
579 |
isContainerBased |
4b3dec16d86b
initial implementation for package checkin
Claus Gittinger <cg@exept.de>
parents:
2839
diff
changeset
|
580 |
^ false |
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 |
"Created: / 24-07-2012 / 18:21:32 / cg" |
4b3dec16d86b
initial implementation for package checkin
Claus Gittinger <cg@exept.de>
parents:
2839
diff
changeset
|
583 |
! |
4b3dec16d86b
initial implementation for package checkin
Claus Gittinger <cg@exept.de>
parents:
2839
diff
changeset
|
584 |
|
3458 | 585 |
isExperimental |
586 |
^ true |
|
587 |
||
588 |
"Created: / 21-01-2013 / 09:10:56 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
589 |
! |
|
590 |
||
2778 | 591 |
isResponsibleForPackage:aString |
592 |
^true. |
|
593 |
||
594 |
"Created: / 09-07-2011 / 14:32:20 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
595 |
"Modified (comment): / 02-03-2012 / 15:05:14 / cg" |
|
596 |
! |
|
597 |
||
598 |
managerTypeName |
|
599 |
^ 'Git' |
|
600 |
||
601 |
"Created: / 16-08-2006 / 11:05:56 / cg" |
|
602 |
! |
|
603 |
||
604 |
nameOfVersionMethodForExtensions |
|
605 |
^ #'extensionsVersion_Git' |
|
606 |
||
607 |
"Modified: / 02-03-2012 / 15:05:02 / cg" |
|
608 |
! |
|
609 |
||
610 |
nameOfVersionMethodInClasses |
|
611 |
^ #'version_Git' |
|
612 |
||
613 |
"Modified: / 02-03-2012 / 15:04:56 / cg" |
|
614 |
! |
|
615 |
||
616 |
settingsApplicationClass |
|
617 |
"link to my settings application (needed for the settings dialog" |
|
618 |
||
619 |
^ GitSourceCodeManagementSettingsAppl |
|
620 |
||
621 |
"Created: / 19-04-2011 / 12:43:29 / cg" |
|
622 |
"Modified: / 02-03-2012 / 15:04:50 / cg" |
|
623 |
! ! |
|
624 |
||
625 |
!GitSourceCodeManager class methodsFor:'saving'! |
|
626 |
||
627 |
savePreferencesOn:aStream |
|
628 |
aStream nextPutLine:'GitSourceCodeManager notNil ifTrue:['. |
|
629 |
self repositoryInfoPerModule notEmptyOrNil ifTrue:[ |
|
630 |
aStream nextPutLine:' GitSourceCodeManager repositoryInfoPerModule:' , self repositoryInfoPerModule storeString , '.'. |
|
631 |
]. |
|
632 |
GitExecutable notNil ifTrue:[ |
|
633 |
aStream nextPutLine:' GitSourceCodeManager gitExecutable:' , GitExecutable storeString , '.'. |
|
634 |
]. |
|
635 |
(Smalltalk at:#SourceCodeManager) == self ifTrue:[ |
|
636 |
aStream nextPutLine:' Smalltalk at:#SourceCodeManager put: GitSourceCodeManager.'. |
|
637 |
aStream nextPutLine:' GitSourceCodeManager initializeForRepository:' , self repositoryName storeString , '.'. |
|
638 |
] ifFalse:[ |
|
639 |
aStream nextPutLine:' GitSourceCodeManager repositoryName:' , self repositoryName storeString , '.'. |
|
640 |
]. |
|
641 |
aStream nextPutLine:'].'. |
|
642 |
||
643 |
"Created: / 09-11-2006 / 15:09:25 / cg" |
|
644 |
"Modified: / 02-03-2012 / 15:17:42 / cg" |
|
645 |
! ! |
|
646 |
||
647 |
!GitSourceCodeManager class methodsFor:'testing'! |
|
648 |
||
649 |
isGit |
|
650 |
^ true |
|
651 |
||
652 |
"Created: / 02-03-2012 / 15:17:19 / cg" |
|
653 |
! ! |
|
654 |
||
655 |
!GitSourceCodeManager class methodsFor:'documentation'! |
|
656 |
||
657 |
version |
|
3978 | 658 |
^ '$Header$' |
2778 | 659 |
! |
660 |
||
661 |
version_CVS |
|
3978 | 662 |
^ '$Header$' |
2778 | 663 |
! ! |
664 |
||
3107 | 665 |
|
2778 | 666 |
GitSourceCodeManager initialize! |