From cf6243340c768ef71714a27548d1f951bc008e73 Mon Sep 17 00:00:00 2001 From: Offray Luna Date: Wed, 19 Feb 2020 21:31:31 +0000 Subject: [PATCH] Supporting executable detection and repo initialization. --- repository/Fossil/FossilRepo.class.st | 45 ++++++++++++++++++++++++--- 1 file changed, 41 insertions(+), 4 deletions(-) diff --git a/repository/Fossil/FossilRepo.class.st b/repository/Fossil/FossilRepo.class.st index 3a832ac..fc0998c 100644 --- a/repository/Fossil/FossilRepo.class.st +++ b/repository/Fossil/FossilRepo.class.st @@ -15,16 +15,40 @@ Class { 'local', 'remote' ], + #classInstVars : [ + 'executable' + ], #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 [ "I add a file to the working Fossil repository, given that both, the file and the repositor, share the same root directory/folder." OSSUnixSubprocess new - command: '/usr/bin/fossil'; + command: self class locateExecutable; arguments: { 'add' . fileRelativePath }; workingDirectory: self localFolderName; redirectStdout; @@ -60,13 +84,13 @@ FossilRepo >> checkinsFor: relativeFilePath [ ^ payload at: 'checkins' ] -{ #category : #'as yet unclassified' } +{ #category : #operation } FossilRepo >> commit: message [ "I add a file to the working Fossil repository, given that both, the file and the repositor, share the same root directory/folder." OSSUnixSubprocess new - command: '/usr/bin/fossil'; + command: self class locateExecutable; arguments: { 'commit' . '--no-warnings' . '-m' . message }; workingDirectory: self localFolderName; redirectStdout; @@ -118,6 +142,19 @@ FossilRepo >> getPageContentsFor: anEmbeddedDocUrl [ ^ (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 } FossilRepo >> isUnversioned: aFileNameWithRelativePath [