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