Skip to content

Commit

Permalink
IceGitCliRepository handle working directory doesn't exist or isn't s…
Browse files Browse the repository at this point in the history
…upplied.
  • Loading branch information
akgrant43 committed Jun 27, 2024
1 parent 1215069 commit e099946
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 18 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Class {
#name : #GtGitCliError,
#superclass : #Error,
#name : #GtGitCliCommandError,
#superclass : #GtGitError,
#instVars : [
'stderr',
'args',
Expand All @@ -10,37 +10,37 @@ Class {
}

{ #category : #accessing }
GtGitCliError >> args [
GtGitCliCommandError >> args [
^ args ifNil: [ #() ]
]

{ #category : #accessing }
GtGitCliError >> args: anObject [
GtGitCliCommandError >> args: anObject [
args := anObject
]

{ #category : #accessing }
GtGitCliError >> commandLine [
GtGitCliCommandError >> commandLine [
^ Character space join: ({ 'git' } , self args)
]

{ #category : #accessing }
GtGitCliError >> errorLine [
GtGitCliCommandError >> errorLine [
^ self stderr detect: [ :line | line beginsWith: 'ERROR' ] ifNone: [ nil ]
]

{ #category : #accessing }
GtGitCliError >> exitCode [
GtGitCliCommandError >> exitCode [
^ exitCode
]

{ #category : #accessing }
GtGitCliError >> exitCode: anObject [
GtGitCliCommandError >> exitCode: anObject [
exitCode := anObject
]

{ #category : #'gt extensions' }
GtGitCliError >> gtGitExitCodeFor: aView [
GtGitCliCommandError >> gtGitExitCodeFor: aView [
<gtView>
^ aView textEditor
title: 'Exitcode';
Expand All @@ -49,7 +49,7 @@ GtGitCliError >> gtGitExitCodeFor: aView [
]

{ #category : #accessing }
GtGitCliError >> gtGitInvocationFor: aView [
GtGitCliCommandError >> gtGitInvocationFor: aView [
<gtView>
^ aView list
title: 'Args';
Expand All @@ -58,7 +58,7 @@ GtGitCliError >> gtGitInvocationFor: aView [
]

{ #category : #accessing }
GtGitCliError >> gtGitOutputFor: aView [
GtGitCliCommandError >> gtGitOutputFor: aView [
<gtView>
^ aView list
title: 'Stderr';
Expand All @@ -67,7 +67,7 @@ GtGitCliError >> gtGitOutputFor: aView [
]

{ #category : #'gt extensions' }
GtGitCliError >> gtGitSummaryFor: aView [
GtGitCliCommandError >> gtGitSummaryFor: aView [
<gtExceptionView>
^ aView textEditor
title: 'Git CLI failed';
Expand All @@ -85,7 +85,7 @@ GtGitCliError >> gtGitSummaryFor: aView [
]

{ #category : #accessing }
GtGitCliError >> messageText [
GtGitCliCommandError >> messageText [
^ messageText ifNil: [
messageText := String streamContents: [ :out |
out
Expand All @@ -98,11 +98,11 @@ GtGitCliError >> messageText [
]

{ #category : #accessing }
GtGitCliError >> stderr [
GtGitCliCommandError >> stderr [
^ stderr ifNil: [ #() ]
]

{ #category : #accessing }
GtGitCliError >> stderr: anObject [
GtGitCliCommandError >> stderr: anObject [
stderr := anObject
]
5 changes: 5 additions & 0 deletions src/GToolkit4Git/GtGitError.class.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Class {
#name : #GtGitError,
#superclass : #Error,
#category : #'GToolkit4Git-Libgit-CLI'
}
29 changes: 29 additions & 0 deletions src/GToolkit4Git/GtGitRepositoryLocationDoesntExist.class.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
Class {
#name : #GtGitRepositoryLocationDoesntExist,
#superclass : #GtGitError,
#instVars : [
'fileReference',
'repository'
],
#category : #'GToolkit4Git-Libgit-CLI'
}

{ #category : #accessing }
GtGitRepositoryLocationDoesntExist >> fileReference [
^ fileReference
]

{ #category : #accessing }
GtGitRepositoryLocationDoesntExist >> fileReference: anObject [
fileReference := anObject
]

{ #category : #accessing }
GtGitRepositoryLocationDoesntExist >> repository [
^ repository
]

{ #category : #accessing }
GtGitRepositoryLocationDoesntExist >> repository: anObject [
repository := anObject
]
12 changes: 9 additions & 3 deletions src/GToolkit4Git/IceGitCliRepository.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ IceGitCliRepository >> contentsOfFile: aHash [
ifFalse: [
result := output stderr lines.
self logEnded: #contentsOfFile: args: args output: result.
^ GtGitCliError new
^ GtGitCliCommandError new
args: args;
stderr: result;
exitCode: output status code;
Expand Down Expand Up @@ -357,6 +357,12 @@ IceGitCliRepository >> getStatusByFile [

{ #category : #actions }
IceGitCliRepository >> git [

(location isNil or: [ location exists not ]) ifTrue:
[ GtGitRepositoryLocationDoesntExist new
fileReference: location;
repository: self;
signal ].
^ GtExternalProcessBuilder new
command: 'git';
workingDirectory: location
Expand Down Expand Up @@ -771,7 +777,7 @@ IceGitCliRepository >> remoteTrackedBranches [
{ #category : #'API - remotes' }
IceGitCliRepository >> remotes [
| lines |
remoteMap isEmpty
(remoteMap isEmpty and: [ location isNotNil and: [ location exists ] ])
ifTrue: [ lines := self runGitWithArgs: {'remote'}.
lines
do: [ :each |
Expand Down Expand Up @@ -858,7 +864,7 @@ IceGitCliRepository >> runGitWithArgs: args [
ifFalse: [
lines := output stderr lines.
self logEnded: operation args: args output: lines.
^ GtGitCliError new
^ GtGitCliCommandError new
args: args;
stderr: lines;
exitCode: output status code;
Expand Down

0 comments on commit e099946

Please sign in to comment.