-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Use externalFetchAndPush for cloning (which calls fetchFrom:, not fetchFromAll:) * Catch ConnectionClosed when fetching
- Loading branch information
Showing
6 changed files
with
52 additions
and
41 deletions.
There are no files selected for viewing
39 changes: 9 additions & 30 deletions
39
src/FileSystem-Git.package/FileSystemGitRepository.class/instance/fetchFrom..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,32 +1,11 @@ | ||
git porcelain | ||
fetchFrom: 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.']. | ||
fetchSpec := remote fetchSpecs | ||
ifEmpty: [GitFetchSpec | ||
fromString: '+refs/heads/*:refs/remotes/', aRemoteName, '/*' | ||
forRemote: remote] | ||
ifNotEmpty: [:fetchSpecs | fetchSpecs first]. | ||
self flag: #todo. "regard all fetch specs, not just the first one" | ||
protocol := GitAbstractProtocol url: url. | ||
protocol | ||
remote: remote; | ||
withOpenConnection: | ||
[remoteRefs := protocol refs. | ||
wantRefs := remoteRefs keys select: [:each | fetchSpec remoteRefPattern match: each]. | ||
wantRefs ifEmpty: [^ (GitNothingToFetch from: remote) signal ifNil: [Dictionary new]]. | ||
wantSignatures := wantRefs collect: [:each | remoteRefs at: each]. | ||
packFileData := protocol wantAll: wantSignatures. | ||
packFile := GitPackFile readFrom: packFileData readStream]. | ||
packFile repository: repository. | ||
packFile unpack. | ||
wantRefs do: | ||
[:each | self unitOfWork | ||
updateRef: (remote trackingRefOf: each) | ||
to: (remoteRefs at: each)]. | ||
GitFeatureFlags pruneWhenFetching ifTrue: [ | ||
self | ||
pruneRefs: fetchSpec | ||
keep: (wantRefs collect: [:each | fetchSpec trackingRefOf: each])]. | ||
^ protocol refs | ||
^ GitFeatureFlags externalFetchAndPush | ||
ifTrue: [self fetchAllExternalFrom: aRemoteName] | ||
ifFalse: [[self fetchInternalFrom: aRemoteName] | ||
on: ConnectionClosed | ||
do: [:exception | | ||
self | ||
handleConnectionClosed: exception | ||
whileTryingTo: 'fetch' | ||
ifRetry: [self fetchFrom: aRemoteName]]]. |
4 changes: 1 addition & 3 deletions
4
src/FileSystem-Git.package/FileSystemGitRepository.class/instance/fetchFromAll..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,5 +1,3 @@ | ||
git porcelain | ||
fetchFromAll: aCollectionOfRemoteNames | ||
GitFeatureFlags externalFetchAndPush | ||
ifTrue: [aCollectionOfRemoteNames do: [:each | self fetchAllExternalFrom: each]] | ||
ifFalse: [aCollectionOfRemoteNames do: [:each | self fetchFrom: each]] | ||
aCollectionOfRemoteNames do: [:each | self fetchFrom: each]. |
32 changes: 32 additions & 0 deletions
32
src/FileSystem-Git.package/FileSystemGitRepository.class/instance/fetchInternalFrom..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,32 @@ | ||
git porcelain | ||
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.']. | ||
fetchSpec := remote fetchSpecs | ||
ifEmpty: [GitFetchSpec | ||
fromString: '+refs/heads/*:refs/remotes/', aRemoteName, '/*' | ||
forRemote: remote] | ||
ifNotEmpty: [:fetchSpecs | fetchSpecs first]. | ||
self flag: #todo. "regard all fetch specs, not just the first one" | ||
protocol := GitAbstractProtocol url: url. | ||
protocol | ||
remote: remote; | ||
withOpenConnection: | ||
[remoteRefs := protocol refs. | ||
wantRefs := remoteRefs keys select: [:each | fetchSpec remoteRefPattern match: each]. | ||
wantRefs ifEmpty: [^ (GitNothingToFetch from: remote) signal ifNil: [Dictionary new]]. | ||
wantSignatures := wantRefs collect: [:each | remoteRefs at: each]. | ||
packFileData := protocol wantAll: wantSignatures. | ||
packFile := GitPackFile readFrom: packFileData readStream]. | ||
packFile repository: repository. | ||
packFile unpack. | ||
wantRefs do: | ||
[:each | self unitOfWork | ||
updateRef: (remote trackingRefOf: each) | ||
to: (remoteRefs at: each)]. | ||
GitFeatureFlags pruneWhenFetching ifTrue: [ | ||
self | ||
pruneRefs: fetchSpec | ||
keep: (wantRefs collect: [:each | fetchSpec trackingRefOf: each])]. | ||
^ protocol refs |
8 changes: 4 additions & 4 deletions
8
...stance/handleConnectionClosed.ifRetry..st → ...onnectionClosed.whileTryingTo.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
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