Implementing support for unversioned files.

This commit is contained in:
Offray Vladimir Luna Cárdenas 2019-04-08 20:46:49 +00:00
parent 1910b685a6
commit 616cd8d292
2 changed files with 22 additions and 20 deletions

View File

@ -57,7 +57,7 @@ FossilRepo >> fetchPage: pageName [
^ NeoJSONReader fromString: (self jsonWikiDataFor: 'get/', pageName) ^ NeoJSONReader fromString: (self jsonWikiDataFor: 'get/', pageName)
] ]
{ #category : #utility } { #category : #utilities }
FossilRepo >> jsonDataFor: anUrlSegment [ FossilRepo >> jsonDataFor: anUrlSegment [
^ NeoJSONReader fromString: (self jsonStringFor: anUrlSegment) ^ NeoJSONReader fromString: (self jsonStringFor: anUrlSegment)
@ -66,8 +66,7 @@ FossilRepo >> jsonDataFor: anUrlSegment [
{ #category : #querying } { #category : #querying }
FossilRepo >> jsonStringFor: aFileName [ FossilRepo >> jsonStringFor: aFileName [
| baseUrl queryForJSONData | | baseUrl queryForJSONData |
baseUrl := self remote asString. baseUrl := self remote addPathSegments: #('json' 'finfo').
baseUrl := baseUrl asUrl addPathSegments: #('json' 'finfo').
queryForJSONData := baseUrl queryAt: 'name' put: aFileName. queryForJSONData := baseUrl queryAt: 'name' put: aFileName.
^ (ZnEasy get: queryForJSONData) contents. ^ (ZnEasy get: queryForJSONData) contents.
] ]
@ -86,6 +85,17 @@ FossilRepo >> lastHashNumberFor: aFileName [
^ (self checkinsFor: aFileName) first at: 'uuid' ^ (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 } { #category : #accessing }
FossilRepo >> local [ FossilRepo >> local [
^ local ^ local
@ -124,15 +134,6 @@ FossilRepo >> rawCapabilities [
^ NeoJSONReader fromString: (self jsonDataFor: 'cap') ^ 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 } { #category : #accessing }
FossilRepo >> remote [ FossilRepo >> remote [
^ remote ^ remote
@ -143,6 +144,15 @@ FossilRepo >> remote: anUrlString [
remote := anUrlString asUrl 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 } { #category : #authentication }
FossilRepo >> whoAmI [ FossilRepo >> whoAmI [
^ NeoJSONReader fromString: (self jsonDataFor: 'whoami') ^ NeoJSONReader fromString: (self jsonDataFor: 'whoami')

View File

@ -1,8 +0,0 @@
"
A FossilRepoTest is a test class for testing the behavior of FossilRepo
"
Class {
#name : #FossilRepoTest,
#superclass : #TestCase,
#category : #'Fossil-Tests'
}