Supporting executable detection and repo initialization.

This commit is contained in:
Offray Vladimir Luna Cárdenas 2020-02-19 21:31:31 +00:00
parent 90ad65b589
commit cf6243340c

View File

@ -15,16 +15,40 @@ Class {
'local', 'local',
'remote' 'remote'
], ],
#classInstVars : [
'executable'
],
#category : #Fossil #category : #Fossil
} }
{ #category : #'as yet unclassified' } { #category : #accessing }
FossilRepo class >> executable [
^ executable ifNil: [ executable := self locateExecutable ]
]
{ #category : #accessing }
FossilRepo class >> executable: aPathString [
"I define where the Fossil package is installed in this operative system."
executable := aPathString
]
{ #category : #accessing }
FossilRepo class >> locateExecutable [
Smalltalk os isWindows ifTrue: [ ^ self ].
OSSUnixSubprocess new
command: 'which';
arguments: #('fossil') ;
redirectStdout;
runAndWaitOnExitDo: [ :process :outString | ^ outString ]
]
{ #category : #operation }
FossilRepo >> add: fileRelativePath [ FossilRepo >> add: fileRelativePath [
"I add a file to the working Fossil repository, given that both, the file and the repositor, "I add a file to the working Fossil repository, given that both, the file and the repositor,
share the same root directory/folder." share the same root directory/folder."
OSSUnixSubprocess new OSSUnixSubprocess new
command: '/usr/bin/fossil'; command: self class locateExecutable;
arguments: { 'add' . fileRelativePath }; arguments: { 'add' . fileRelativePath };
workingDirectory: self localFolderName; workingDirectory: self localFolderName;
redirectStdout; redirectStdout;
@ -60,13 +84,13 @@ FossilRepo >> checkinsFor: relativeFilePath [
^ payload at: 'checkins' ^ payload at: 'checkins'
] ]
{ #category : #'as yet unclassified' } { #category : #operation }
FossilRepo >> commit: message [ FossilRepo >> commit: message [
"I add a file to the working Fossil repository, given that both, the file and the repositor, "I add a file to the working Fossil repository, given that both, the file and the repositor,
share the same root directory/folder." share the same root directory/folder."
OSSUnixSubprocess new OSSUnixSubprocess new
command: '/usr/bin/fossil'; command: self class locateExecutable;
arguments: { 'commit' . '--no-warnings' . '-m' . message }; arguments: { 'commit' . '--no-warnings' . '-m' . message };
workingDirectory: self localFolderName; workingDirectory: self localFolderName;
redirectStdout; redirectStdout;
@ -118,6 +142,19 @@ FossilRepo >> getPageContentsFor: anEmbeddedDocUrl [
^ (ZnEasy get: anEmbeddedDocUrl, '?mimetype=text/plain') contents. ^ (ZnEasy get: anEmbeddedDocUrl, '?mimetype=text/plain') contents.
] ]
{ #category : #operation }
FossilRepo >> init: absolutePathString [
"I add a file to the working Fossil repository, given that both, the file and the repositor,
share the same root directory/folder."
Smalltalk os isWindows ifTrue: [ ^ self ].
OSSUnixSubprocess new
command: self class locateExecutable;
arguments: { 'init' . absolutePathString };
workingDirectory: self localFolderName;
redirectStdout;
runAndWaitOnExitDo: [ :process :outString | ^ outString ]
]
{ #category : #utilities } { #category : #utilities }
FossilRepo >> isUnversioned: aFileNameWithRelativePath [ FossilRepo >> isUnversioned: aFileNameWithRelativePath [