author | Jan Vrany <jan.vrany@fit.cvut.cz> |
Thu, 28 Mar 2013 12:22:48 +0000 | |
branch | jv |
changeset 3158 | f8c56a311307 |
parent 3101 | f8e4d06048d2 |
parent 3107 | e84a189e6b16 |
child 3329 | a4cbc797038b |
permissions | -rw-r--r-- |
2778 | 1 |
" |
2 |
COPYRIGHT (c) 2012 by Claus Gittinger |
|
3 |
All Rights Reserved |
|
4 |
||
5 |
This software is furnished under a license and may be used |
|
6 |
only in accordance with the terms of that license and with the |
|
7 |
inclusion of the above copyright notice. This software may not |
|
8 |
be provided or otherwise made available to, or used by, any |
|
9 |
other person. No title to or ownership of the software is |
|
10 |
hereby transferred. |
|
11 |
" |
|
12 |
"{ Package: 'stx:libbasic3' }" |
|
13 |
||
14 |
AbstractSourceCodeManager subclass:#GitSourceCodeManager |
|
15 |
instanceVariableNames:'' |
|
16 |
classVariableNames:'Verbose DefaultRepository PerModuleRepositories DisabledModules |
|
17 |
RecentlyCheckedModulesAndPackages GitCommandTimeout GitTempDir |
|
18 |
GitCommandSemaphore GitExecutable GitCommitOptions |
|
2789 | 19 |
GitUpdateOptions WorkDirectory' |
2778 | 20 |
poolDictionaries:'' |
21 |
category:'System-SourceCodeManagement' |
|
22 |
! |
|
23 |
||
24 |
!GitSourceCodeManager class methodsFor:'documentation'! |
|
25 |
||
26 |
copyright |
|
27 |
" |
|
28 |
COPYRIGHT (c) 2012 by Claus Gittinger |
|
29 |
All Rights Reserved |
|
30 |
||
31 |
This software is furnished under a license and may be used |
|
32 |
only in accordance with the terms of that license and with the |
|
33 |
inclusion of the above copyright notice. This software may not |
|
34 |
be provided or otherwise made available to, or used by, any |
|
35 |
other person. No title to or ownership of the software is |
|
36 |
hereby transferred. |
|
37 |
" |
|
38 |
! |
|
39 |
||
40 |
documentation |
|
41 |
" |
|
42 |
SourceCodeManager which accesses the sourcecode through Git. |
|
43 |
ongoing work - unfinished and unusable |
|
44 |
||
45 |
Comment: |
|
46 |
The code here is a copy-paste mess; it definitely needs some cleanup... |
|
47 |
||
48 |
[author:] |
|
49 |
Claus Gittinger |
|
50 |
||
51 |
[see also:] |
|
52 |
" |
|
53 |
! ! |
|
54 |
||
3158
f8c56a311307
Merged 87750af738dc and 72ca7e81fbbf (branch default - CVS HEAD)
Jan Vrany <jan.vrany@fit.cvut.cz>
diff
changeset
|
55 |
|
2778 | 56 |
!GitSourceCodeManager class methodsFor:'initialization'! |
57 |
||
58 |
forgetDisabledModules |
|
59 |
DisabledModules := nil. |
|
60 |
! |
|
61 |
||
62 |
initialize |
|
3107 | 63 |
| s | |
2778 | 64 |
|
3107 | 65 |
GitCommandSemaphore := (Semaphore new:10) name:'Concurrent GIT Commands'. "/ at most 10 git activities concurrently |
2778 | 66 |
GitCommitOptions := ''. |
67 |
GitUpdateOptions := ''. |
|
68 |
DisabledModules := nil. |
|
69 |
PerModuleRepositories isNil ifTrue:[ |
|
70 |
PerModuleRepositories := Dictionary new. |
|
71 |
]. |
|
72 |
||
2812
69143eafd6fc
do not check scm-command at class-init time
Claus Gittinger <cg@exept.de>
parents:
2789
diff
changeset
|
73 |
"/ 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
|
74 |
"/ ok := OperatingSystem canExecuteCommand:(self gitExecutable). |
69143eafd6fc
do not check scm-command at class-init time
Claus Gittinger <cg@exept.de>
parents:
2789
diff
changeset
|
75 |
"/ ok ifFalse:[ |
69143eafd6fc
do not check scm-command at class-init time
Claus Gittinger <cg@exept.de>
parents:
2789
diff
changeset
|
76 |
"/ '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
|
77 |
"/ ^ self |
69143eafd6fc
do not check scm-command at class-init time
Claus Gittinger <cg@exept.de>
parents:
2789
diff
changeset
|
78 |
"/ ]. |
2778 | 79 |
|
80 |
CacheDirectoryName isNil ifTrue:[ |
|
81 |
self initCacheDirPath. |
|
82 |
]. |
|
83 |
CachingSources isNil ifTrue:[ |
|
84 |
CachingSources := true. |
|
85 |
]. |
|
86 |
||
87 |
"/ |
|
88 |
"/ optionally set the WorkTreeDirectoryName from $STX_WORKTREE; |
|
89 |
"/ if non-nil, a working tree is kept there |
|
90 |
"/ and updated/commited files are not removed. |
|
91 |
"/ If you use a regular (make-) tree, |
|
92 |
"/ set WorkTreeDirectoryName (or the environment variable) to that. |
|
93 |
"/ |
|
94 |
"/ this is not yet finished. |
|
95 |
"/ |
|
96 |
s := OperatingSystem getEnvironment:'STX_WORKTREE'. |
|
97 |
s notNil ifTrue:[ |
|
98 |
WorkTreeDirectoryName := s. |
|
99 |
UseWorkTree := true. |
|
100 |
] |
|
101 |
||
102 |
" |
|
103 |
AbstractSourceCodeManager initialize |
|
104 |
GitSourceCodeManager initialize |
|
105 |
" |
|
106 |
||
107 |
"Created: / 04-11-1995 / 19:14:38 / cg" |
|
108 |
"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
|
109 |
"Modified (comment): / 20-03-2012 / 19:05:00 / cg" |
2778 | 110 |
! |
111 |
||
112 |
initializeForRepository:aDirectoryName |
|
113 |
"reinitialize. |
|
114 |
Can be used from the launcher to change/configure the repository." |
|
115 |
||
2787 | 116 |
|dir| |
117 |
||
2778 | 118 |
self repositoryName:aDirectoryName. |
119 |
AbstractSourceCodeManager initialize. |
|
120 |
GitSourceCodeManager initialize. |
|
121 |
||
2787 | 122 |
(dir := aDirectoryName asFilename) exists ifFalse:[ |
123 |
dir recursiveMakeDirectory. |
|
124 |
]. |
|
125 |
(dir construct:'.git') exists ifFalse:[ |
|
2839 | 126 |
self executeGitCommand:'init' inDirectory:dir |
2787 | 127 |
]. |
128 |
||
2778 | 129 |
"Created: / 13-08-1997 / 17:20:57 / cg" |
130 |
"Modified: / 25-09-1997 / 12:28:05 / stefan" |
|
2839 | 131 |
"Modified: / 23-07-2012 / 16:16:57 / cg" |
2787 | 132 |
! |
133 |
||
134 |
initializeRepository |
|
135 |
self initializeForRepository:(self repositoryName) |
|
136 |
||
137 |
"Created: / 02-03-2012 / 16:56:21 / cg" |
|
2778 | 138 |
! ! |
139 |
||
3158
f8c56a311307
Merged 87750af738dc and 72ca7e81fbbf (branch default - CVS HEAD)
Jan Vrany <jan.vrany@fit.cvut.cz>
diff
changeset
|
140 |
|
2778 | 141 |
!GitSourceCodeManager class methodsFor:'accessing'! |
142 |
||
2839 | 143 |
executeGitCommand:cmd inDirectory:dir |
144 |
|retCode out err| |
|
145 |
||
146 |
retCode := self |
|
147 |
executeGitCommand:cmd |
|
148 |
outputTo:(out := WriteStream on:(String new:100)) |
|
149 |
errorTo:(err := WriteStream on:(String new:100)) |
|
150 |
inDirectory:dir. |
|
151 |
retCode ifFalse:[ |
|
152 |
Transcript showCR:'-----------------------------------------------'. |
|
153 |
Transcript showCR:'out:'. |
|
154 |
Transcript showCR:out contents. |
|
155 |
Transcript showCR:'err:'. |
|
156 |
Transcript showCR:err contents. |
|
157 |
]. |
|
158 |
^ retCode |
|
159 |
||
160 |
"Created: / 23-07-2012 / 16:17:06 / cg" |
|
161 |
! |
|
162 |
||
163 |
executeGitCommand:cmd outputTo:outStreamOrNil errorTo:errStreamOrNil inDirectory:dir |
|
164 |
^ OperatingSystem |
|
165 |
executeCommand:'git ',cmd |
|
166 |
outputTo:outStreamOrNil |
|
167 |
errorTo:errStreamOrNil |
|
168 |
inDirectory:dir asFilename pathName. |
|
169 |
||
170 |
"Created: / 24-07-2012 / 09:33:29 / cg" |
|
171 |
! |
|
172 |
||
2778 | 173 |
gitBinDirectory:ignoredString |
174 |
"ignored - for backward compatibility (to read old settings files)" |
|
175 |
"Created: / 14-01-2012 / 20:49:46 / cg" |
|
176 |
! |
|
177 |
||
178 |
gitCommandTimeout |
|
179 |
^ GitCommandTimeout ? ("360" 120 seconds) |
|
180 |
||
181 |
"Modified (comment): / 08-01-2012 / 19:02:44 / cg" |
|
182 |
"Created: / 02-03-2012 / 15:23:40 / cg" |
|
183 |
! |
|
184 |
||
185 |
gitCommandTimeout:aTimeDuration |
|
186 |
GitCommandTimeout := aTimeDuration asTimeDuration. |
|
187 |
||
188 |
"Created: / 02-03-2012 / 15:23:46 / cg" |
|
189 |
! |
|
190 |
||
191 |
gitCommitOptions |
|
192 |
^ GitCommitOptions ? '' |
|
193 |
||
194 |
"Created: / 02-03-2012 / 15:23:51 / cg" |
|
195 |
! |
|
196 |
||
197 |
gitCommitOptions:aString |
|
198 |
GitCommitOptions := aString. |
|
199 |
||
200 |
"Created: / 02-03-2012 / 15:23:57 / cg" |
|
201 |
! |
|
202 |
||
203 |
gitExecutable |
|
204 |
"return the name of the git executable." |
|
205 |
||
206 |
^ GitExecutable ? 'git' |
|
207 |
||
208 |
"Created: / 02-03-2012 / 15:24:02 / cg" |
|
209 |
! |
|
210 |
||
211 |
gitExecutable:aString |
|
212 |
"set the name of the git executable." |
|
213 |
||
214 |
aString isEmptyOrNil ifTrue:[ |
|
215 |
GitExecutable := nil |
|
216 |
] ifFalse:[ |
|
217 |
GitExecutable := aString. |
|
218 |
]. |
|
219 |
||
220 |
"Modified: / 21-09-2006 / 16:41:33 / cg" |
|
221 |
"Created: / 02-03-2012 / 15:24:07 / cg" |
|
222 |
! |
|
223 |
||
224 |
gitTmpDirectory |
|
225 |
"return the name of the tmp repository. |
|
226 |
That's the directory, where temporary files are created for checkin/checkout. |
|
2920 | 227 |
If nil, the system's default tempDirectory is used." |
2778 | 228 |
|
229 |
^ (GitTempDir ? Filename tempDirectory pathName) |
|
230 |
||
231 |
" |
|
232 |
CVSTempDir := nil |
|
233 |
" |
|
234 |
||
235 |
"Created: / 02-03-2012 / 15:24:12 / cg" |
|
236 |
! |
|
237 |
||
238 |
gitTmpDirectory:aPathNameString |
|
239 |
"set the name of the tmp repository. |
|
240 |
That's the directory, where temporary files are created for checkin/checkout. |
|
2920 | 241 |
If nil, the system's default tempDirectory is used." |
2778 | 242 |
|
243 |
GitTempDir := aPathNameString |
|
244 |
||
245 |
"Created: / 02-03-2012 / 15:24:18 / cg" |
|
246 |
! |
|
247 |
||
248 |
gitUpdateOptions |
|
249 |
^ GitUpdateOptions ? '' |
|
250 |
||
251 |
"Created: / 02-03-2012 / 15:24:24 / cg" |
|
252 |
! |
|
253 |
||
254 |
gitUpdateOptions:aString |
|
255 |
GitUpdateOptions := aString. |
|
256 |
||
257 |
"Created: / 02-03-2012 / 15:24:28 / cg" |
|
258 |
! |
|
259 |
||
260 |
knownModules |
|
261 |
"return the modules, we currently know" |
|
262 |
||
263 |
PerModuleRepositories isEmptyOrNil ifTrue:[^ #() ]. |
|
264 |
^ PerModuleRepositories keys |
|
265 |
||
266 |
"Modified: / 14-01-2012 / 21:23:37 / cg" |
|
267 |
! |
|
268 |
||
269 |
knownRepositories |
|
270 |
"return the modules, we currently know" |
|
271 |
||
272 |
^ PerModuleRepositories values copyWith:DefaultRepository |
|
273 |
||
274 |
"Modified: / 14-01-2012 / 21:23:59 / cg" |
|
275 |
! |
|
276 |
||
277 |
repositoryForPackage:packageId |
|
278 |
"superclass AbstractSourceCodeManager class says that I am responsible to implement this method" |
|
279 |
||
280 |
^self getGitRepositoryForModule: ( packageId upTo:$:) |
|
281 |
||
282 |
"Modified: / 10-10-2011 / 19:38:47 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
283 |
"Modified: / 02-03-2012 / 15:25:19 / cg" |
|
284 |
! |
|
285 |
||
286 |
repositoryInfoPerModule |
|
287 |
"return the dictionary, which associates gitRepositories to module names. |
|
288 |
If no entry is contained in this dictionary for some module, |
|
289 |
the default crepository will be used." |
|
290 |
||
291 |
^ PerModuleRepositories ? #() |
|
292 |
||
293 |
"Modified (comment): / 02-03-2012 / 15:25:28 / cg" |
|
294 |
! |
|
295 |
||
296 |
repositoryInfoPerModule:aDictionary |
|
297 |
"set the dictionary, which associates repositories to module names. |
|
298 |
If no entry is contained in this dictionary for some module, |
|
299 |
the default repository will be used." |
|
300 |
||
301 |
PerModuleRepositories := aDictionary |
|
302 |
||
303 |
"Modified: / 14-01-2012 / 21:25:21 / cg" |
|
304 |
! |
|
305 |
||
306 |
repositoryName |
|
307 |
"return the name of the global repository. |
|
308 |
This is used, if no per-module repository is defined." |
|
309 |
||
310 |
^ DefaultRepository |
|
311 |
||
312 |
"Created: / 14-09-1996 / 13:22:05 / cg" |
|
313 |
"Modified: / 14-01-2012 / 21:25:42 / cg" |
|
314 |
! |
|
315 |
||
316 |
repositoryName:aDirectoryName |
|
317 |
"set the name of the repository; |
|
318 |
that's the name of the global repository, which is used |
|
319 |
if no specific repository was defined for a module." |
|
320 |
||
321 |
DisabledModules := nil. |
|
322 |
DefaultRepository := aDirectoryName. |
|
323 |
||
324 |
"Created: / 14-09-1996 / 13:22:24 / cg" |
|
325 |
"Modified: / 14-01-2012 / 21:26:17 / cg" |
|
326 |
! |
|
327 |
||
328 |
repositoryName:aRepositoryName forModule:aModuleName |
|
329 |
"set the repository which provides the sources for all |
|
330 |
classes in a particular module. |
|
331 |
This can be used from an rc-script, to specify a repository |
|
332 |
for a particular module. |
|
333 |
If left unspecified, the global (i.e. fallBack) repository is used." |
|
334 |
||
335 |
DisabledModules := nil. |
|
336 |
PerModuleRepositories at:aModuleName put:aRepositoryName |
|
337 |
||
338 |
"Modified (comment): / 14-01-2012 / 21:27:08 / cg" |
|
339 |
! |
|
340 |
||
341 |
repositoryNameForModule:aModuleName |
|
342 |
"return the repository which provides the sources for all |
|
343 |
classes in a particular module. |
|
344 |
Nil is returned for unspecified moduleRoots; in this case, |
|
345 |
the global (i.e. fallBack) repository will be used for source access." |
|
346 |
||
347 |
^ PerModuleRepositories at:aModuleName ifAbsent:nil. |
|
348 |
||
349 |
"Created: / 19-09-1997 / 06:13:06 / cg" |
|
350 |
! |
|
351 |
||
2850
4b3dec16d86b
initial implementation for package checkin
Claus Gittinger <cg@exept.de>
parents:
2839
diff
changeset
|
352 |
repositoryNameForPackage:packageId |
4b3dec16d86b
initial implementation for package checkin
Claus Gittinger <cg@exept.de>
parents:
2839
diff
changeset
|
353 |
^ self repositoryNameForModule:(packageId upTo:$:) |
2778 | 354 |
|
355 |
"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
|
356 |
"Modified (format): / 25-07-2012 / 18:23:06 / cg" |
2789 | 357 |
! |
358 |
||
359 |
workDirectory |
|
360 |
^ WorkDirectory |
|
361 |
||
362 |
"Created: / 03-03-2012 / 11:08:29 / cg" |
|
363 |
! |
|
364 |
||
365 |
workDirectory:aPath |
|
366 |
WorkDirectory := aPath |
|
367 |
||
368 |
"Created: / 03-03-2012 / 11:08:37 / cg" |
|
2778 | 369 |
! ! |
370 |
||
3158
f8c56a311307
Merged 87750af738dc and 72ca7e81fbbf (branch default - CVS HEAD)
Jan Vrany <jan.vrany@fit.cvut.cz>
diff
changeset
|
371 |
|
2778 | 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. |
|
404 |
self halt. |
|
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:[ |
|
457 |
self halt |
|
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:[ |
|
463 |
self halt. |
|
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:[ |
|
473 |
self halt |
|
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 |
||
559 |
revisionStringFor:aClass inModule:moduleDir directory:packageDir container:fileName revision:revisionString |
|
560 |
"utility function: return a string usable as initial revision string" |
|
561 |
||
562 |
^ self standardRevisionStringFor:aClass inModule:moduleDir directory:packageDir container:fileName revision:revisionString |
|
563 |
||
564 |
"Created: / 23-07-2012 / 19:01:17 / cg" |
|
2850
4b3dec16d86b
initial implementation for package checkin
Claus Gittinger <cg@exept.de>
parents:
2839
diff
changeset
|
565 |
! |
4b3dec16d86b
initial implementation for package checkin
Claus Gittinger <cg@exept.de>
parents:
2839
diff
changeset
|
566 |
|
4b3dec16d86b
initial implementation for package checkin
Claus Gittinger <cg@exept.de>
parents:
2839
diff
changeset
|
567 |
updateRepository:repositoryDirectory |
4b3dec16d86b
initial implementation for package checkin
Claus Gittinger <cg@exept.de>
parents:
2839
diff
changeset
|
568 |
self executeGitCommand:'update' inDirectory:repositoryDirectory |
4b3dec16d86b
initial implementation for package checkin
Claus Gittinger <cg@exept.de>
parents:
2839
diff
changeset
|
569 |
|
4b3dec16d86b
initial implementation for package checkin
Claus Gittinger <cg@exept.de>
parents:
2839
diff
changeset
|
570 |
"Created: / 25-07-2012 / 18:55:56 / cg" |
2778 | 571 |
! ! |
572 |
||
3158
f8c56a311307
Merged 87750af738dc and 72ca7e81fbbf (branch default - CVS HEAD)
Jan Vrany <jan.vrany@fit.cvut.cz>
diff
changeset
|
573 |
|
2778 | 574 |
!GitSourceCodeManager class methodsFor:'debugging'! |
575 |
||
576 |
verboseSourceCodeAccess |
|
577 |
^ Verbose ? false |
|
578 |
! |
|
579 |
||
580 |
verboseSourceCodeAccess:aBoolean |
|
581 |
Verbose := aBoolean |
|
582 |
! ! |
|
583 |
||
3158
f8c56a311307
Merged 87750af738dc and 72ca7e81fbbf (branch default - CVS HEAD)
Jan Vrany <jan.vrany@fit.cvut.cz>
diff
changeset
|
584 |
|
2778 | 585 |
!GitSourceCodeManager class methodsFor:'queries'! |
586 |
||
2850
4b3dec16d86b
initial implementation for package checkin
Claus Gittinger <cg@exept.de>
parents:
2839
diff
changeset
|
587 |
isContainerBased |
4b3dec16d86b
initial implementation for package checkin
Claus Gittinger <cg@exept.de>
parents:
2839
diff
changeset
|
588 |
^ false |
4b3dec16d86b
initial implementation for package checkin
Claus Gittinger <cg@exept.de>
parents:
2839
diff
changeset
|
589 |
|
4b3dec16d86b
initial implementation for package checkin
Claus Gittinger <cg@exept.de>
parents:
2839
diff
changeset
|
590 |
"Created: / 24-07-2012 / 18:21:32 / cg" |
4b3dec16d86b
initial implementation for package checkin
Claus Gittinger <cg@exept.de>
parents:
2839
diff
changeset
|
591 |
! |
4b3dec16d86b
initial implementation for package checkin
Claus Gittinger <cg@exept.de>
parents:
2839
diff
changeset
|
592 |
|
3101
f8e4d06048d2
Make MercurialSourceCodeManager & GitSourceCodeManager experimental.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3088
diff
changeset
|
593 |
isExperimental |
f8e4d06048d2
Make MercurialSourceCodeManager & GitSourceCodeManager experimental.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3088
diff
changeset
|
594 |
^ true |
f8e4d06048d2
Make MercurialSourceCodeManager & GitSourceCodeManager experimental.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3088
diff
changeset
|
595 |
|
f8e4d06048d2
Make MercurialSourceCodeManager & GitSourceCodeManager experimental.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3088
diff
changeset
|
596 |
"Created: / 21-01-2013 / 09:10:56 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
f8e4d06048d2
Make MercurialSourceCodeManager & GitSourceCodeManager experimental.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3088
diff
changeset
|
597 |
! |
f8e4d06048d2
Make MercurialSourceCodeManager & GitSourceCodeManager experimental.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3088
diff
changeset
|
598 |
|
2778 | 599 |
isResponsibleForPackage:aString |
600 |
^true. |
|
601 |
||
602 |
"Created: / 09-07-2011 / 14:32:20 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
603 |
"Modified (comment): / 02-03-2012 / 15:05:14 / cg" |
|
604 |
! |
|
605 |
||
606 |
managerTypeName |
|
607 |
^ 'Git' |
|
608 |
||
609 |
"Created: / 16-08-2006 / 11:05:56 / cg" |
|
610 |
! |
|
611 |
||
612 |
nameOfVersionMethodForExtensions |
|
613 |
^ #'extensionsVersion_Git' |
|
614 |
||
615 |
"Modified: / 02-03-2012 / 15:05:02 / cg" |
|
616 |
! |
|
617 |
||
618 |
nameOfVersionMethodInClasses |
|
619 |
^ #'version_Git' |
|
620 |
||
621 |
"Modified: / 02-03-2012 / 15:04:56 / cg" |
|
622 |
! |
|
623 |
||
624 |
settingsApplicationClass |
|
625 |
"link to my settings application (needed for the settings dialog" |
|
626 |
||
627 |
^ GitSourceCodeManagementSettingsAppl |
|
628 |
||
629 |
"Created: / 19-04-2011 / 12:43:29 / cg" |
|
630 |
"Modified: / 02-03-2012 / 15:04:50 / cg" |
|
631 |
! ! |
|
632 |
||
3158
f8c56a311307
Merged 87750af738dc and 72ca7e81fbbf (branch default - CVS HEAD)
Jan Vrany <jan.vrany@fit.cvut.cz>
diff
changeset
|
633 |
|
2778 | 634 |
!GitSourceCodeManager class methodsFor:'saving'! |
635 |
||
636 |
savePreferencesOn:aStream |
|
637 |
aStream nextPutLine:'GitSourceCodeManager notNil ifTrue:['. |
|
638 |
self repositoryInfoPerModule notEmptyOrNil ifTrue:[ |
|
639 |
aStream nextPutLine:' GitSourceCodeManager repositoryInfoPerModule:' , self repositoryInfoPerModule storeString , '.'. |
|
640 |
]. |
|
641 |
GitExecutable notNil ifTrue:[ |
|
642 |
aStream nextPutLine:' GitSourceCodeManager gitExecutable:' , GitExecutable storeString , '.'. |
|
643 |
]. |
|
644 |
(Smalltalk at:#SourceCodeManager) == self ifTrue:[ |
|
645 |
aStream nextPutLine:' Smalltalk at:#SourceCodeManager put: GitSourceCodeManager.'. |
|
646 |
aStream nextPutLine:' GitSourceCodeManager initializeForRepository:' , self repositoryName storeString , '.'. |
|
647 |
] ifFalse:[ |
|
648 |
aStream nextPutLine:' GitSourceCodeManager repositoryName:' , self repositoryName storeString , '.'. |
|
649 |
]. |
|
650 |
aStream nextPutLine:'].'. |
|
651 |
||
652 |
"Created: / 09-11-2006 / 15:09:25 / cg" |
|
653 |
"Modified: / 02-03-2012 / 15:17:42 / cg" |
|
654 |
! ! |
|
655 |
||
3158
f8c56a311307
Merged 87750af738dc and 72ca7e81fbbf (branch default - CVS HEAD)
Jan Vrany <jan.vrany@fit.cvut.cz>
diff
changeset
|
656 |
|
2778 | 657 |
!GitSourceCodeManager class methodsFor:'testing'! |
658 |
||
659 |
isGit |
|
660 |
^ true |
|
661 |
||
662 |
"Created: / 02-03-2012 / 15:17:19 / cg" |
|
663 |
! ! |
|
664 |
||
3158
f8c56a311307
Merged 87750af738dc and 72ca7e81fbbf (branch default - CVS HEAD)
Jan Vrany <jan.vrany@fit.cvut.cz>
diff
changeset
|
665 |
|
2778 | 666 |
!GitSourceCodeManager class methodsFor:'documentation'! |
667 |
||
668 |
version |
|
3107 | 669 |
^ '$Header: /cvs/stx/stx/libbasic3/GitSourceCodeManager.st,v 1.8 2013-02-08 18:40:56 stefan Exp $' |
2778 | 670 |
! |
671 |
||
672 |
version_CVS |
|
3107 | 673 |
^ '$Header: /cvs/stx/stx/libbasic3/GitSourceCodeManager.st,v 1.8 2013-02-08 18:40:56 stefan Exp $' |
3040 | 674 |
! |
675 |
||
3101
f8e4d06048d2
Make MercurialSourceCodeManager & GitSourceCodeManager experimental.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3088
diff
changeset
|
676 |
version_HG |
f8e4d06048d2
Make MercurialSourceCodeManager & GitSourceCodeManager experimental.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3088
diff
changeset
|
677 |
|
f8e4d06048d2
Make MercurialSourceCodeManager & GitSourceCodeManager experimental.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3088
diff
changeset
|
678 |
^ '$Changeset: <not expanded> $' |
f8e4d06048d2
Make MercurialSourceCodeManager & GitSourceCodeManager experimental.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3088
diff
changeset
|
679 |
! |
f8e4d06048d2
Make MercurialSourceCodeManager & GitSourceCodeManager experimental.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3088
diff
changeset
|
680 |
|
3040 | 681 |
version_SVN |
3101
f8e4d06048d2
Make MercurialSourceCodeManager & GitSourceCodeManager experimental.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3088
diff
changeset
|
682 |
^ '§Id:: §' |
2778 | 683 |
! ! |
684 |
||
3107 | 685 |
|
2778 | 686 |
GitSourceCodeManager initialize! |