--- a/GitSourceCodeManager.st Thu Jul 19 15:05:10 2012 +0200
+++ b/GitSourceCodeManager.st Tue Jul 24 09:38:58 2012 +0200
@@ -122,12 +122,12 @@
dir recursiveMakeDirectory.
].
(dir construct:'.git') exists ifFalse:[
- OperatingSystem executeCommand:'git init' inDirectory:dir pathName
+ self executeGitCommand:'init' inDirectory:dir
].
"Created: / 13-08-1997 / 17:20:57 / cg"
"Modified: / 25-09-1997 / 12:28:05 / stefan"
- "Modified: / 02-03-2012 / 17:02:22 / cg"
+ "Modified: / 23-07-2012 / 16:16:57 / cg"
!
initializeRepository
@@ -138,6 +138,36 @@
!GitSourceCodeManager class methodsFor:'accessing'!
+executeGitCommand:cmd inDirectory:dir
+ |retCode out err|
+
+ retCode := self
+ executeGitCommand:cmd
+ outputTo:(out := WriteStream on:(String new:100))
+ errorTo:(err := WriteStream on:(String new:100))
+ inDirectory:dir.
+ retCode ifFalse:[
+ Transcript showCR:'-----------------------------------------------'.
+ Transcript showCR:'out:'.
+ Transcript showCR:out contents.
+ Transcript showCR:'err:'.
+ Transcript showCR:err contents.
+ ].
+ ^ retCode
+
+ "Created: / 23-07-2012 / 16:17:06 / cg"
+!
+
+executeGitCommand:cmd outputTo:outStreamOrNil errorTo:errStreamOrNil inDirectory:dir
+ ^ OperatingSystem
+ executeCommand:'git ',cmd
+ outputTo:outStreamOrNil
+ errorTo:errStreamOrNil
+ inDirectory:dir asFilename pathName.
+
+ "Created: / 24-07-2012 / 09:33:29 / cg"
+!
+
gitBinDirectory:ignoredString
"ignored - for backward compatibility (to read old settings files)"
"Created: / 14-01-2012 / 20:49:46 / cg"
@@ -340,10 +370,152 @@
!GitSourceCodeManager class methodsFor:'basic administration'!
+checkForExistingContainer:fileName inModule:moduleName directory:dirName
+ "check for a container to be present"
+
+ |path subDir|
+
+ path := (self repositoryName asFilename construct:moduleName) construct:dirName.
+ path exists ifFalse:[
+ subDir := moduleName asFilename construct:dirName.
+ self executeGitCommand:'checkout ',subDir name inDirectory:self repositoryName.
+ ].
+ ^ (path construct:fileName) exists
+
+ "Created: / 23-07-2012 / 16:21:02 / cg"
+!
+
+checkForExistingModule:moduleName
+ "check for a module to be present"
+
+ |path subDir|
+
+ path := self repositoryName asFilename construct:moduleName.
+ path exists ifFalse:[
+ subDir := moduleName asFilename.
+ self executeGitCommand:'checkout ',subDir name inDirectory:self repositoryName.
+self halt.
+ ].
+ ^ path exists
+
+ "Created: / 23-07-2012 / 18:44:27 / cg"
+!
+
+checkForExistingModule:moduleName directory:packageDir
+ "check for a package directory to be present"
+
+ |path subDir|
+
+ path := (self repositoryName asFilename construct:moduleName) construct:packageDir.
+ path exists ifFalse:[
+ subDir := moduleName asFilename construct:packageDir.
+ self executeGitCommand:'checkout ',subDir name inDirectory:self repositoryName.
+ ].
+ ^ path exists
+
+ "Created: / 23-07-2012 / 19:07:34 / cg"
+!
+
+checkinClass:aClass fileName:classFileName directory:packageDir module:moduleDir source:sourceFile logMessage:logMessage force:force
+ "checkin of a class into the source repository.
+ Return true if ok, false if not."
+
+ |path relPath logArg out err|
+
+ relPath := (moduleDir asFilename construct:packageDir) construct:classFileName.
+ path := self repositoryName asFilename construct:relPath.
+ sourceFile asFilename moveTo: path.
+
+ (self executeGitCommand:'add ',relPath name inDirectory:self repositoryName) ifFalse:[
+ self halt
+ ].
+
+ out := WriteStream on:(String new:100).
+ err := WriteStream on:(String new:100).
+ (self executeGitCommand:'status --porcelain' outputTo:out errorTo:err inDirectory:self repositoryName) ifFalse:[
+ self halt.
+ ].
+ (out contents withoutSeparators isEmptyOrNil) ifTrue:[
+ (err contents withoutSeparators isEmptyOrNil) ifTrue:[
+ "/ nothing to commit
+ ^ true
+ ].
+ ].
+ logArg := logMessage copyReplaceAll:$" withAll:''''''.
+ (self executeGitCommand:'commit -m "',logArg,'"' inDirectory:self repositoryName) ifFalse:[
+ self halt
+ ].
+ ^ true
+
+ "Created: / 23-07-2012 / 20:05:14 / cg"
+!
+
createContainerFor:aClass inModule:moduleName directory:dirName container:fileName
"create a new container & check into it an initial version of aClass"
^ self shouldImplement
+!
+
+createModule:moduleName
+ "create a new module directory"
+
+ |dir|
+
+ dir := self repositoryName asFilename construct:moduleName.
+ dir exists ifTrue:[^ true].
+ dir recursiveMakeDirectory.
+ ^ dir exists.
+
+ "Created: / 23-07-2012 / 19:04:51 / cg"
+!
+
+createModule:moduleName directory:directory
+ "create a new package directory"
+
+ |dir|
+
+ dir := (self repositoryName asFilename construct:moduleName) construct:directory.
+ dir exists ifTrue:[^ true].
+ dir recursiveMakeDirectory.
+ ^ dir exists.
+
+ "Created: / 23-07-2012 / 19:08:22 / cg"
+!
+
+initialRevisionStringFor:aClass inModule:moduleDir directory:packageDir container:fileName
+ "return a string usable as initial revision string"
+
+ ^ self
+ revisionStringFor:aClass
+ inModule:moduleDir
+ directory:packageDir
+ container:fileName
+ revision:'1'
+
+ "Created: / 23-07-2012 / 18:40:25 / cg"
+!
+
+revisionInfoFromString:aString
+ "{ Pragma: +optSpace }"
+
+ "return a VersionInfo object filled with revision info.
+ This extracts the relevant info from aString."
+
+ ^ self revisionInfoFromStandardVersionString:aString
+
+ "
+ self revisionInfoFromString:'Path: stx/libbasic/Array.st, Version: 123, User: cg, Time: 2011-12-21T21:03:08.826'
+ "
+
+ "Created: / 23-07-2012 / 19:02:56 / cg"
+!
+
+revisionStringFor:aClass inModule:moduleDir directory:packageDir container:fileName revision:revisionString
+ "utility function: return a string usable as initial revision string"
+
+ ^ self standardRevisionStringFor:aClass inModule:moduleDir directory:packageDir container:fileName revision:revisionString
+
+ "Created: / 23-07-2012 / 19:01:17 / cg"
! !
!GitSourceCodeManager class methodsFor:'debugging'!
@@ -425,11 +597,11 @@
!GitSourceCodeManager class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libbasic3/GitSourceCodeManager.st,v 1.4 2012-03-20 18:05:42 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libbasic3/GitSourceCodeManager.st,v 1.5 2012-07-24 07:38:58 cg Exp $'
!
version_CVS
- ^ '$Header: /cvs/stx/stx/libbasic3/GitSourceCodeManager.st,v 1.4 2012-03-20 18:05:42 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libbasic3/GitSourceCodeManager.st,v 1.5 2012-07-24 07:38:58 cg Exp $'
! !
GitSourceCodeManager initialize!