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