Skip to content

Commit

Permalink
Rename Git CLI support classes
Browse files Browse the repository at this point in the history
  • Loading branch information
refactoringdr committed May 17, 2024
1 parent 346bb22 commit 3e022b6
Show file tree
Hide file tree
Showing 11 changed files with 118 additions and 118 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Class {
#name : #GtGitCommitFileReader,
#name : #GitCliCommitFileReader,
#superclass : #Object,
#instVars : [
'workingDirectory',
Expand All @@ -14,24 +14,24 @@ Class {
}

{ #category : #accessing }
GtGitCommitFileReader >> eatNewline [
GitCliCommitFileReader >> eatNewline [
self getNextByte
]

{ #category : #accessing }
GtGitCommitFileReader >> getNext: anInteger [
GitCliCommitFileReader >> getNext: anInteger [
^ ByteArray
streamContents: [ :str | anInteger timesRepeat: [ str nextPut: self getNextByte ] ]
]

{ #category : #accessing }
GtGitCommitFileReader >> getNextByte [
GitCliCommitFileReader >> getNextByte [
[ buffer isEmpty ] whileTrue: [ buffer addAll: stdout pollBytes ].
^ buffer removeFirst
]

{ #category : #accessing }
GtGitCommitFileReader >> getNextLine [
GitCliCommitFileReader >> getNextLine [
^ String
streamContents: [ :str |
| ch lfCode |
Expand All @@ -42,7 +42,7 @@ GtGitCommitFileReader >> getNextLine [
]

{ #category : #accessing }
GtGitCommitFileReader >> readStreamFor: aString [
GitCliCommitFileReader >> readStreamFor: aString [
| out line bytes |
lock
critical: [ stdin
Expand All @@ -56,7 +56,7 @@ GtGitCommitFileReader >> readStreamFor: aString [
]

{ #category : #accessing }
GtGitCommitFileReader >> start [
GitCliCommitFileReader >> start [
externalProcess := (GtExternalProcessBuilder new: 'git')
workingDirectory: workingDirectory;
args: {'cat-file'.
Expand All @@ -73,7 +73,7 @@ GtGitCommitFileReader >> start [
]

{ #category : #accessing }
GtGitCommitFileReader >> terminate [
GitCliCommitFileReader >> terminate [
externalProcess
ifNotNil: [ externalProcess terminate.
externalProcess := nil ].
Expand All @@ -89,6 +89,6 @@ GtGitCommitFileReader >> terminate [
]

{ #category : #accessing }
GtGitCommitFileReader >> workingDirectory: aFileRef [
GitCliCommitFileReader >> workingDirectory: aFileRef [
workingDirectory := aFileRef
]
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Class {
#name : #GtGitCommitStore,
#name : #GitCliCommitStore,
#superclass : #FileSystemStore,
#instVars : [
'id',
Expand All @@ -14,55 +14,55 @@ Class {
}

{ #category : #'instance creation' }
GtGitCommitStore class >> on: aCommitId inRepo: aGtIceGitRepository [
GitCliCommitStore class >> on: aCommitId inRepo: aGtIceGitRepository [
^ self new
commit: aCommitId;
repository: aGtIceGitRepository;
yourself
]

{ #category : #finalization }
GtGitCommitStore class >> register: anObject [
GitCliCommitStore class >> register: anObject [
^self registry add: anObject
]

{ #category : #accessing }
GtGitCommitStore class >> registry [
GitCliCommitStore class >> registry [
^Registry ifNil: [Registry := WeakRegistry new]
]

{ #category : #accessing }
GtGitCommitStore >> basenameFromEntry: aNode [
GitCliCommitStore >> basenameFromEntry: aNode [
^ aNode path
]

{ #category : #accessing }
GtGitCommitStore >> basicCreationTimeOf: anEntry [
GitCliCommitStore >> basicCreationTimeOf: anEntry [
^ DateAndTime now
]

{ #category : #accessing }
GtGitCommitStore >> basicEntry: directoryEntry path: aPath nodesDo: aBlock [
GitCliCommitStore >> basicEntry: directoryEntry path: aPath nodesDo: aBlock [
| lines |
lines := repository runGitWithArgs: {
'ls-tree'.
'--format=%(objectmode) %(objecttype) %(objectname) %(objectsize)%x09%(path)'.
directoryEntry id }.
lines do: [ :each | aBlock value: (GtGitFileEntry fromLine: each) ]
lines do: [ :each | aBlock value: (GitCliFileEntry fromLine: each) ]
]

{ #category : #accessing }
GtGitCommitStore >> basicIsDirectory: aNode [
GitCliCommitStore >> basicIsDirectory: aNode [
^ aNode type = 'tree'
]

{ #category : #accessing }
GtGitCommitStore >> basicIsFile: aNode [
GitCliCommitStore >> basicIsFile: aNode [
^ aNode type = 'blob'
]

{ #category : #accessing }
GtGitCommitStore >> basicOpen: path writable: aBoolean [
GitCliCommitStore >> basicOpen: path writable: aBoolean [
^ self
nodeAt: path
ifPresent: [ :entry | entry ]
Expand All @@ -72,22 +72,22 @@ GtGitCommitStore >> basicOpen: path writable: aBoolean [
]

{ #category : #abstract }
GtGitCommitStore >> basicSizeOf: aNode [
GitCliCommitStore >> basicSizeOf: aNode [
^ aNode size
]

{ #category : #'instance creation' }
GtGitCommitStore >> commit: aCommitId [
GitCliCommitStore >> commit: aCommitId [
id := aCommitId
]

{ #category : #accessing }
GtGitCommitStore >> delimiter [
GitCliCommitStore >> delimiter [
^ $/
]

{ #category : #accessing }
GtGitCommitStore >> entries [
GitCliCommitStore >> entries [
| entryList lines |
entries ifNotNil: [ ^ entries ].
entries := Dictionary new.
Expand All @@ -96,48 +96,48 @@ GtGitCommitStore >> entries [
'-rt'.
'--format=%(objectmode) %(objecttype) %(objectname) %(objectsize)%x09%(path)'.
self treeIdFromCommit }.
entryList := lines collect: [ :each | GtGitFileEntry fromLine: each ].
entryList := lines collect: [ :each | GitCliFileEntry fromLine: each ].
entryList do: [ :each | entries at: (self basenameFromEntry: each) put: each ].
^ entries
]

{ #category : #accessing }
GtGitCommitStore >> entryByPath: aString ifAbsent: aBlock [
GitCliCommitStore >> entryByPath: aString ifAbsent: aBlock [
^ self entries at: aString ifAbsent: aBlock
]

{ #category : #public }
GtGitCommitStore >> entryFromNode: node path: path for: aFileSystem [
GitCliCommitStore >> entryFromNode: node path: path for: aFileSystem [
^ aFileSystem referenceTo: path / node path
]

{ #category : #accessing }
GtGitCommitStore >> finalize [
GitCliCommitStore >> finalize [
gitFileReader ifNotNil: [ :reader | reader terminate ].
super finalize
]

{ #category : #printing }
GtGitCommitStore >> forReferencePrintOn: aStream [
GitCliCommitStore >> forReferencePrintOn: aStream [
aStream nextPutAll: 'git://'
]

{ #category : #accessing }
GtGitCommitStore >> gitFileReader [
GitCliCommitStore >> gitFileReader [
^ gitFileReader
ifNil: [ self class register: self.
gitFileReader := GtGitCommitFileReader new
gitFileReader := GitCliCommitFileReader new
workingDirectory: repository location;
start ]
]

{ #category : #accessing }
GtGitCommitStore >> handleClass [
^ GtGitFileHandle
GitCliCommitStore >> handleClass [
^ GitCliFileHandle
]

{ #category : #accessing }
GtGitCommitStore >> nodeAt: anAbsolutePath ifPresent: aBlockClosure ifAbsent: aBlockClosure3 [
GitCliCommitStore >> nodeAt: anAbsolutePath ifPresent: aBlockClosure ifAbsent: aBlockClosure3 [
anAbsolutePath isRoot ifTrue: [ ^ aBlockClosure value: self rootEntry ].
^ aBlockClosure
value: (self
Expand All @@ -146,23 +146,23 @@ GtGitCommitStore >> nodeAt: anAbsolutePath ifPresent: aBlockClosure ifAbsent: aB
]

{ #category : #accessing }
GtGitCommitStore >> readStreamOn: aGtGitFileHandle [
GitCliCommitStore >> readStreamOn: aGtGitFileHandle [
^ self gitFileReader readStreamFor: aGtGitFileHandle entry id
]

{ #category : #accessing }
GtGitCommitStore >> repository [
GitCliCommitStore >> repository [
^ repository
]

{ #category : #'instance creation' }
GtGitCommitStore >> repository: aGtIceGitRepository [
GitCliCommitStore >> repository: aGtIceGitRepository [
repository := aGtIceGitRepository
]

{ #category : #accessing }
GtGitCommitStore >> rootEntry [
^ GtGitFileEntry new
GitCliCommitStore >> rootEntry [
^ GitCliFileEntry new
mode: '040000';
type: 'tree';
id: self treeIdFromCommit;
Expand All @@ -172,7 +172,7 @@ GtGitCommitStore >> rootEntry [
]

{ #category : #accessing }
GtGitCommitStore >> treeIdFromCommit [
GitCliCommitStore >> treeIdFromCommit [
^ (repository runGitWithArgs: {
'show'.
'-s'.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Class {
#name : #GtGitFileEntry,
#name : #GitCliFileEntry,
#superclass : #Object,
#instVars : [
'mode',
Expand All @@ -12,7 +12,7 @@ Class {
}

{ #category : #'instance creation' }
GtGitFileEntry class >> fromLine: aString [
GitCliFileEntry class >> fromLine: aString [
"Create an entry from a git ls-tree line produced with: '--format=%(objectmode) %(objecttype) %(objectname) %(objectsize)%x09%(path)'."

| tabSplit path spaceSplit mode type id size |
Expand All @@ -33,63 +33,63 @@ GtGitFileEntry class >> fromLine: aString [
]

{ #category : #accessing }
GtGitFileEntry >> filename [
GitCliFileEntry >> filename [
^path
]

{ #category : #accessing }
GtGitFileEntry >> id [
GitCliFileEntry >> id [
^ id
]

{ #category : #accessing }
GtGitFileEntry >> id: anObject [
GitCliFileEntry >> id: anObject [
id := anObject
]

{ #category : #accessing }
GtGitFileEntry >> mode [
GitCliFileEntry >> mode [
^ mode
]

{ #category : #accessing }
GtGitFileEntry >> mode: anObject [
GitCliFileEntry >> mode: anObject [
mode := anObject
]

{ #category : #accessing }
GtGitFileEntry >> path [
GitCliFileEntry >> path [
^ path
]

{ #category : #accessing }
GtGitFileEntry >> path: anObject [
GitCliFileEntry >> path: anObject [
path := anObject
]

{ #category : #printing }
GtGitFileEntry >> printOn: aStream [
GitCliFileEntry >> printOn: aStream [
aStream
nextPutAll: self className , ' ' , mode , ' ' , type , ' ' , id , ' ' , size printString
, ' ' , path
]

{ #category : #accessing }
GtGitFileEntry >> size [
GitCliFileEntry >> size [
^ size
]

{ #category : #accessing }
GtGitFileEntry >> size: anObject [
GitCliFileEntry >> size: anObject [
size := anObject
]

{ #category : #accessing }
GtGitFileEntry >> type [
GitCliFileEntry >> type [
^ type
]

{ #category : #accessing }
GtGitFileEntry >> type: anObject [
GitCliFileEntry >> type: anObject [
type := anObject
]
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Class {
#name : #GtGitFileHandle,
#name : #GitCliFileHandle,
#superclass : #FileSystemHandle,
#instVars : [
'entry'
Expand All @@ -8,26 +8,26 @@ Class {
}

{ #category : #accessing }
GtGitFileHandle >> binaryReadStream [
GitCliFileHandle >> binaryReadStream [
^ self readStream
]

{ #category : #accessing }
GtGitFileHandle >> entry [
GitCliFileHandle >> entry [
^ entry
]

{ #category : #accessing }
GtGitFileHandle >> entry: anObject [
GitCliFileHandle >> entry: anObject [
entry := anObject
]

{ #category : #accessing }
GtGitFileHandle >> open [
GitCliFileHandle >> open [
entry := self basicOpen
]

{ #category : #accessing }
GtGitFileHandle >> readStream [
GitCliFileHandle >> readStream [
^ reference fileSystem store readStreamOn: self
]

0 comments on commit 3e022b6

Please sign in to comment.