-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'wip/external-git-improvements'
- Loading branch information
Showing
31 changed files
with
154 additions
and
57 deletions.
There are no files selected for viewing
3 changes: 3 additions & 0 deletions
3
src/FileSystem-Git.package/FileSystemGitRepository.class/instance/canHandleUrlInternally..st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
git porcelain | ||
canHandleUrlInternally: aString | ||
^ {'http://'. 'https://'} anySatisfy: [:each | aString beginsWith: each] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
src/FileSystem-Git.package/FileSystemGitRepository.class/instance/cloneFrom..st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,11 @@ | ||
git porcelain | ||
cloneFrom: aStringOrUrl | ||
GitFeatureFlags externalFetchAndPush | ||
(self shouldHandleUrlExternally: aStringOrUrl) | ||
ifTrue: [self cloneExternalFrom: aStringOrUrl] | ||
ifFalse: [[self cloneInternalFrom: aStringOrUrl] | ||
on: ConnectionClosed | ||
do: [:exception | | ||
self | ||
handleConnectionClosed: exception | ||
whileTryingTo: 'clone' | ||
while: 'cloning' | ||
ifRetry: [self cloneFrom: aStringOrUrl]]]. |
4 changes: 3 additions & 1 deletion
4
src/FileSystem-Git.package/FileSystemGitRepository.class/instance/commandExists..st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
git porcelain - external | ||
commandExists: aString | ||
^ (ShellSyntax new findExecutablePathFor: (aString copyUpTo: Character space) inDirectoryPath: nil) notNil | ||
^ ((self osProcessClass: #ShellSyntax) new | ||
findExecutablePathFor: (aString copyUpTo: Character space) | ||
inDirectoryPath: nil) notNil |
26 changes: 18 additions & 8 deletions
26
src/FileSystem-Git.package/FileSystemGitRepository.class/instance/externalCommand..st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,23 @@ | ||
git porcelain - external | ||
externalCommand: aString | ||
| osProcess | | ||
osProcess := (Smalltalk classNamed: #OSProcess) ifNil: [ | ||
(self confirm: 'OSProcess is not installed, but is needed to run git externally. Install it?') ifFalse: [^ self]. | ||
Installer ss project: 'OSProcess'; install: 'OSProcess'. | ||
Installer ss project: 'CommandShell'; install: 'CommandShell'. | ||
^ self externalCommand: aString]. | ||
| osProcess exitCodeReference exitCode errorMessage | | ||
osProcess := self osProcess. | ||
exitCodeReference := FileSystem disk referenceTo: self externalCommandExitCodePath. | ||
exitCodeReference ensureDeleted. | ||
UIManager default informUser: 'Running a git command in a terminal...' during: [ | ||
osProcess waitForCommand: | ||
(osProcess isWindows | ||
ifTrue: ['cmd.exe /c "{1} & pause"' format: {aString}] | ||
ifFalse: [self terminalCommand: aString])]. | ||
ifTrue: [self windowsTerminalCommand: aString] | ||
ifFalse: [self terminalCommand: aString]) | ||
squeakToUtf8. | ||
[exitCodeReference exists] whileFalse: [0.1 seconds wait]]. | ||
exitCode := exitCodeReference contents asString withBlanksTrimmed asNumber. | ||
exitCode = 0 ifTrue: [^ self]. | ||
errorMessage := 'An external git command failed.'. | ||
(self confirm: | ||
('{1} Please check its output before closing the terminal. | ||
Do you want to run it again?' | ||
withoutLineEndings withBlanksCondensed | ||
format: {errorMessage})) | ||
ifFalse: [self error: errorMessage] | ||
ifTrue: [self externalCommand: aString]. |
5 changes: 5 additions & 0 deletions
5
...eSystem-Git.package/FileSystemGitRepository.class/instance/externalCommandExitCodePath.st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
git porcelain - external | ||
externalCommandExitCodePath | ||
| tempDirectory | | ||
tempDirectory := self osProcess isWindows ifTrue: ['\Windows\Temp\'] ifFalse: ['/tmp/']. | ||
^ tempDirectory, 'git-s-external-command-exit-code' |
5 changes: 4 additions & 1 deletion
5
src/FileSystem-Git.package/FileSystemGitRepository.class/instance/externalGitDo..st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,6 @@ | ||
git porcelain - external | ||
externalGitDo: aCommandLineSuffix | ||
self externalCommand: ('git -C "{1}" {2}' format: {repository workingDir pathName. aCommandLineSuffix}). | ||
self externalCommand: ('{1} -C "{2}" {3}' format: { | ||
self gitExecutable. | ||
repository workingDir pathName. | ||
aCommandLineSuffix}). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
src/FileSystem-Git.package/FileSystemGitRepository.class/instance/gitExecutable.st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
git porcelain - external | ||
gitExecutable | ||
| exec | | ||
exec := GitFeatureFlags externalGitExecutable. | ||
(self commandExists: exec) ifTrue: [^ exec]. | ||
exec := UIManager default | ||
request: | ||
('Git could not be found at the path below. | ||
Please install it or provide a path to the git executable. {1}' | ||
withoutLineEndings withBlanksCondensed | ||
format: {self suggestWSLGitInstallation}) | ||
initialAnswer: exec. | ||
exec isEmptyOrNil ifTrue: [^ self error: 'Missing external git installation']. | ||
GitFeatureFlags externalGitExecutable: exec. | ||
^ self gitExecutable |
7 changes: 7 additions & 0 deletions
7
...t.package/FileSystemGitRepository.class/instance/handleConnectionClosed.while.ifRetry..st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
git porcelain | ||
handleConnectionClosed: aConnectionClosed while: aString ifRetry: aBlock | ||
(self requestToEnableExternalFetchAndPushBecause: | ||
('{1} failed with the internal git implementation.' | ||
format: {aString capitalized})) | ||
ifFalse: [aConnectionClosed pass] | ||
ifTrue: [aBlock value]. |
18 changes: 0 additions & 18 deletions
18
...e/FileSystemGitRepository.class/instance/handleConnectionClosed.whileTryingTo.ifRetry..st
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 3 additions & 0 deletions
3
src/FileSystem-Git.package/FileSystemGitRepository.class/instance/osProcess.st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
git porcelain - external | ||
osProcess | ||
^ self osProcessClass: #OSProcess |
8 changes: 8 additions & 0 deletions
8
src/FileSystem-Git.package/FileSystemGitRepository.class/instance/osProcessClass..st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
git porcelain - external | ||
osProcessClass: aSymbol | ||
(Smalltalk classNamed: aSymbol) ifNotNil: [:class | ^ class]. | ||
(self confirm: 'OSProcess is not installed, but is needed to run git externally. Install it?') | ||
ifFalse: [^ self error: 'OSProcess is needed to run git externally.']. | ||
Installer ss project: 'OSProcess'; install: 'OSProcess'. | ||
Installer ss project: 'CommandShell'; install: 'CommandShell'. | ||
^ Smalltalk classNamed: aSymbol |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
...age/FileSystemGitRepository.class/instance/requestToEnableExternalFetchAndPushBecause..st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
git porcelain | ||
requestToEnableExternalFetchAndPushBecause: aString | ||
| preference answer | | ||
preference := Preferences | ||
pragmaPreferenceFor: GitFeatureFlags | ||
getter: #externalFetchAndPush. | ||
answer := (self confirm: | ||
('{1} Do you want to automatically use the git commandline? | ||
This will enable {2} to remember your decision.' | ||
withoutLineEndings withBlanksCondensed asText | ||
format: { | ||
aString. | ||
('a preference' asText | ||
addAttribute: (PluggableTextAttribute evalBlock: [preference open]); | ||
yourself)})). | ||
answer ifTrue: [preference preferenceValue: true]. | ||
^ answer |
9 changes: 9 additions & 0 deletions
9
...leSystem-Git.package/FileSystemGitRepository.class/instance/shouldHandleUrlExternally..st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
git porcelain | ||
shouldHandleUrlExternally: aString | ||
| errorMessage | | ||
GitFeatureFlags externalFetchAndPush ifTrue: [^ true]. | ||
(self canHandleUrlInternally: aString) ifTrue: [^ false]. | ||
errorMessage := 'The url {1} cannot be handled by the internal git implementation.' | ||
format: {aString printString}. | ||
(self requestToEnableExternalFetchAndPushBecause: errorMessage) ifTrue: [^ true]. | ||
self error: errorMessage. |
4 changes: 4 additions & 0 deletions
4
...ileSystem-Git.package/FileSystemGitRepository.class/instance/suggestWSLGitInstallation.st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
git porcelain - external | ||
suggestWSLGitInstallation | ||
(self osProcess isWindows and: [self commandExists: 'wsl']) ifFalse: [^ '']. | ||
^ 'If git is installed in WSL, you can also enter ''wsl git''.' |
4 changes: 4 additions & 0 deletions
4
src/FileSystem-Git.package/FileSystemGitRepository.class/instance/windowsTerminalCommand..st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
git porcelain - external | ||
windowsTerminalCommand: aString | ||
^ 'cmd.exe /v:on /c "{1} & set Code=!ErrorLevel!& pause & echo !Code!> {2}"' | ||
format: {aString. self externalCommandExitCodePath} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 3 additions & 0 deletions
3
src/FileSystem-Git.package/GitFeatureFlags.class/class/externalGitExecutable..st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
accessing | ||
externalGitExecutable: aString | ||
ExternalGitExecutable := aString |
5 changes: 5 additions & 0 deletions
5
src/FileSystem-Git.package/GitFeatureFlags.class/class/externalGitExecutable.st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
accessing | ||
externalGitExecutable | ||
<preference: 'External git executable' categoryList: #('Git expert settings') description: 'A replacement for ''git'' in commands like ''git fetch''. Can be a path to an executable or something like ''wsl git'' to use the git installation in wsl. Spaces (in paths) are not escaped to support the latter use case.' type: #String> | ||
|
||
^ ExternalGitExecutable ifNil: ['git'] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 2 additions & 4 deletions
6
src/GitS-Core.package/GSGitWorkingCopy.class/class/nameFromURL..st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters