From 616cd8d29286bc7b2aa6da5906ca4d279af29f31 Mon Sep 17 00:00:00 2001 From: Offray Luna Date: Mon, 8 Apr 2019 20:46:49 +0000 Subject: [PATCH] Implementing support for unversioned files. --- repository/Fossil/FossilRepo.class.st | 34 +++++++++++++++-------- repository/Fossil/FossilRepoTest.class.st | 8 ------ 2 files changed, 22 insertions(+), 20 deletions(-) delete mode 100644 repository/Fossil/FossilRepoTest.class.st diff --git a/repository/Fossil/FossilRepo.class.st b/repository/Fossil/FossilRepo.class.st index bf830bc..4bca15a 100644 --- a/repository/Fossil/FossilRepo.class.st +++ b/repository/Fossil/FossilRepo.class.st @@ -57,7 +57,7 @@ FossilRepo >> fetchPage: pageName [ ^ NeoJSONReader fromString: (self jsonWikiDataFor: 'get/', pageName) ] -{ #category : #utility } +{ #category : #utilities } FossilRepo >> jsonDataFor: anUrlSegment [ ^ NeoJSONReader fromString: (self jsonStringFor: anUrlSegment) @@ -66,8 +66,7 @@ FossilRepo >> jsonDataFor: anUrlSegment [ { #category : #querying } FossilRepo >> jsonStringFor: aFileName [ | baseUrl queryForJSONData | - baseUrl := self remote asString. - baseUrl := baseUrl asUrl addPathSegments: #('json' 'finfo'). + baseUrl := self remote addPathSegments: #('json' 'finfo'). queryForJSONData := baseUrl queryAt: 'name' put: aFileName. ^ (ZnEasy get: queryForJSONData) contents. ] @@ -86,6 +85,17 @@ FossilRepo >> lastHashNumberFor: aFileName [ ^ (self checkinsFor: aFileName) first at: 'uuid' ] +{ #category : #utilities } +FossilRepo >> lastVersionPath: aFileNameWithRelativePath [ + "I dicern if my argument concerns to a versioned or an unversioned file, + and return a relative route to the last version of the file in the first + case or the unversioned one." + + (aFileNameWithRelativePath beginsWith: '/uv') + ifTrue: [ ^ aFileNameWithRelativePath ] + ifFalse: [ '/doc/tip/', aFileNameWithRelativePath ] +] + { #category : #accessing } FossilRepo >> local [ ^ local @@ -124,15 +134,6 @@ FossilRepo >> rawCapabilities [ ^ NeoJSONReader fromString: (self jsonDataFor: 'cap') ] -{ #category : #utility } -FossilRepo >> rawContentFor: aFilePath [ - "I provide the file contents of a given file path that exist in the repository." - | checksum | - self remote ifNil: [ ^ self ]. - checksum := self lastHashNumberFor: aFilePath. - ^ (self remote asString, 'raw/', aFilePath, '?name=', checksum) asUrl retrieveContents. -] - { #category : #accessing } FossilRepo >> remote [ ^ remote @@ -143,6 +144,15 @@ FossilRepo >> remote: anUrlString [ remote := anUrlString asUrl ] +{ #category : #utilities } +FossilRepo >> sanitize: aFileNameWithRelativePath [ + "I dicern if my argument concerns to a versioned or an unversioned file, + and return a relative path to put the file." + + (aFileNameWithRelativePath beginsWith: '/uv') + ifTrue: [ ^ aFileNameWithRelativePath copyWithout: '/uv' ] +] + { #category : #authentication } FossilRepo >> whoAmI [ ^ NeoJSONReader fromString: (self jsonDataFor: 'whoami') diff --git a/repository/Fossil/FossilRepoTest.class.st b/repository/Fossil/FossilRepoTest.class.st deleted file mode 100644 index 9d1d10b..0000000 --- a/repository/Fossil/FossilRepoTest.class.st +++ /dev/null @@ -1,8 +0,0 @@ -" -A FossilRepoTest is a test class for testing the behavior of FossilRepo -" -Class { - #name : #FossilRepoTest, - #superclass : #TestCase, - #category : #'Fossil-Tests' -}