Skip to content

Commit

Permalink
Add support for remotes with non-HTTP(S) URLs via external git
Browse files Browse the repository at this point in the history
  • Loading branch information
MariusDoe committed Nov 10, 2024
1 parent 8ae6dc3 commit 9d3e35e
Show file tree
Hide file tree
Showing 13 changed files with 58 additions and 33 deletions.
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]
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]]].
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@ fetchFrom: aRemoteName
do: [:exception |
self
handleConnectionClosed: exception
whileTryingTo: 'fetch'
while: 'fetching'
ifRetry: [self fetchFrom: aRemoteName]]].
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ fetchInternalFrom: aRemoteName
| remote url fetchSpec packFile protocol remoteRefs wantRefs wantSignatures packFileData |
remote := self unitOfWork remoteNamed: aRemoteName.
url := remote url ifNil: [(GitRemoteUndefined remote: remote) signal: 'No URL configured.'].
(self shouldHandleUrlExternally: url) ifTrue: [^ self fetchAllExternalFrom: aRemoteName].
fetchSpec := remote fetchSpecs
ifEmpty: [GitFetchSpec
fromString: '+refs/heads/*:refs/remotes/', aRemoteName, '/*'
Expand Down
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].

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ push: aCollectionOfBranchNamesAndAssociations toRemote: remoteName force: forceB
do: [:exception |
self
handleConnectionClosed: exception
whileTryingTo: 'push'
while: 'pushing'
ifRetry: [self
push: aCollectionOfBranchNamesAndAssociations
toRemote: remoteName
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@ pushToRemote: remoteName update: aCollectionOfBranchNamesAndAssociations deleteR
| remote url protocol updateRefs deleteRefs pushBlock report |
remote := self unitOfWork remoteNamed: remoteName.
url := remote url.
(self shouldHandleUrlExternally: url) ifTrue: [
^ self
externalPush: aCollectionOfBranchNamesAndAssociations
toRemote: remoteName
force: forceBoolean].
updateRefs := aCollectionOfBranchNamesAndAssociations collect: [:each |
each value == each
ifTrue: [(self unitOfWork expandRef: each) -> (self unitOfWork objectReferenced: each)]
Expand Down
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
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.
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@
"branchNamed:" : "jr 3/2/2020 22:13",
"branchNames" : "jr 3/3/2020 21:45",
"branches" : "jr 3/4/2020 00:46",
"canHandleUrlInternally:" : "mad 11/10/2024 15:41",
"cloneExternalFrom:" : "mad 5/23/2024 21:12",
"cloneFrom:" : "mad 5/23/2024 18:12",
"cloneFrom:" : "mad 11/10/2024 15:45",
"cloneInternalFrom:" : "mad 5/23/2024 18:11",
"commandExists:" : "mad 4/3/2024 15:10",
"commitNamed:" : "jr 8/13/2020 23:08",
Expand All @@ -18,13 +19,13 @@
"externalGitDo:" : "mad 5/22/2024 13:29",
"externalPush:toRemote:force:" : "mad 5/18/2024 12:26",
"fetchAllExternalFrom:" : "mad 5/23/2024 18:46",
"fetchFrom:" : "mad 5/23/2024 18:10",
"fetchFrom:" : "mad 11/10/2024 15:45",
"fetchFromAll:" : "mad 4/22/2024 17:25",
"fetchInternalFrom:" : "mad 4/22/2024 17:24",
"fetchInternalFrom:" : "mad 11/10/2024 15:36",
"filesystemOn:" : "CamilloBruni 8/30/2012 14:06",
"flushCaches" : "jr 7/2/2017 19:12",
"gitStoreOn:" : "CamilloBruni 9/2/2012 12:33",
"handleConnectionClosed:whileTryingTo:ifRetry:" : "mad 4/22/2024 17:21",
"handleConnectionClosed:while:ifRetry:" : "mad 11/10/2024 15:48",
"handleTerminalCommandTemplateCharacter:from:into:withCommand:" : "mad 10/9/2024 15:07",
"head" : "jr 8/13/2020 23:10",
"headReference" : "jr 3/4/2020 00:47",
Expand All @@ -34,10 +35,10 @@
"performTerminalCommandTemplateReplacement:in:" : "mad 10/9/2024 15:07",
"pruneRefs:keep:" : "mad 4/7/2024 14:44",
"push:toRemote:" : "mad 5/18/2024 11:30",
"push:toRemote:force:" : "mad 5/18/2024 11:30",
"push:toRemote:force:" : "mad 11/10/2024 15:45",
"pushToRemote:deleteRemoteBranches:" : "jr 1/2/2017 10:18",
"pushToRemote:update:deleteRemoteBranches:" : "mad 5/18/2024 11:28",
"pushToRemote:update:deleteRemoteBranches:force:" : "mad 5/18/2024 11:27",
"pushToRemote:update:deleteRemoteBranches:force:" : "mad 11/10/2024 15:34",
"pushToUpstreamBranchOf:ifNone:" : "jr 3/4/2020 00:49",
"recursivelyCollectCommits:into:limit:" : "jr 3/2/2017 10:39",
"refsChangedExternally" : "mad 5/18/2024 11:48",
Expand All @@ -47,6 +48,8 @@
"removeRemoteNamed:" : "jr 3/4/2020 00:49",
"repository" : "CamilloBruni 6/22/2011 05:08",
"requestTerminalCommand" : "mad 10/31/2024 17:50",
"requestToEnableExternalFetchAndPushBecause:" : "mad 11/10/2024 15:51",
"shouldHandleUrlExternally:" : "mad 11/10/2024 15:48",
"tagNamed:" : "MCGitRepositoryTest 3/3/2020 23:40",
"tagNames" : "MCGitRepositoryTest 3/3/2020 23:42",
"tags" : "jr 3/4/2020 00:49",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
instance creation
nameFromURL: aString
| url path name |
url := Url absoluteFromText: aString.
path := url path.
path ifEmpty: [^ self requestUnregisteredName].
| path name |
path := aString splitBy: '/'.
name := (path
reversed
collect: [:each | self withoutGitSuffix: each])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"initializeLastImageHash" : "mad 11/28/2023 19:18",
"lastImageHash" : "mad 11/28/2023 19:20",
"lastImageHash:" : "mad 11/28/2023 19:24",
"nameFromURL:" : "mad 4/10/2024 19:40",
"nameFromURL:" : "mad 11/10/2024 15:19",
"newFromUserAndRegister" : "mad 10/22/2023 00:12",
"onFSGitRepository:named:" : "mad 9/19/2023 11:53",
"onFSReference:named:" : "mad 9/19/2023 11:53",
Expand Down

0 comments on commit 9d3e35e

Please sign in to comment.