Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

External fetch/push #394

Open
wants to merge 4 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
git porcelain - external
externalCommand: aString
^ (Smalltalk classNamed: #OSProcess)
ifNotNil: [:osProcess | | pipeline err out |
osProcess isWindows
ifTrue: [ | tmpFile output process |
" on windows, the osvm does not support reading stdout/stderr. as a workaround, we put the output into a file that we delete right after reading it. note that we place the file into FileDirectory default because it is likely that we can read that one (is also the place where we are saving the image to) "
tmpFile := (FileDirectory default / (UUID new asString, '.txt')) fullName.
output := [
process := OSProcess waitForCommand: ('cmd.exe /c "{1} > {2} 2>&1"' format: {aString copyReplaceAll: '"' with: '\"'. tmpFile}).
FileStream readOnlyFileNamed: tmpFile do: [:s | s contents]
] ensure: [FileDirectory deleteFilePath: tmpFile].
{process exitStatus = 0. output}]
ifFalse: [
pipeline := osProcess evaluate: aString.
out := pipeline upToEndOfFile.
err := pipeline errorUpToEndOfFile.
pipeline waitForAllToComplete.
{pipeline last exitCode = 0. out, err}]]
ifNil: [self error: 'For external commands, OSProcess must be installed']
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
git porcelain - external
externalGitDo: aCommandLineSuffix showText: aBoolean
| res |
res := self externalCommand: ('git -C {1} {2}' format: {repository workingDir. aCommandLineSuffix}).
LinqLover marked this conversation as resolved.
Show resolved Hide resolved
res first
ifFalse: [self error: res second]
ifTrue: [aBoolean ifTrue: [self inform: res second] ifFalse: [Transcript showln: res second]]
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
git porcelain - external
externalPush: aCollectionOfBranchNamesAndAssociations toRemote: remoteName
aCollectionOfBranchNamesAndAssociations do: [:branch |
self externalGitDo: ('push {1} {2}' format: {remoteName. branch value}) showText: true]
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
git porcelain - external
fetchAllExternalFrom: aRemoteName
| remote |
remote := self unitOfWork remoteNamed: aRemoteName.
remote ifNil: [(GitRemoteUndefined remote: remote) signal: 'No URL configured.'].
self externalGitDo: ('fetch {1}' format: {aRemoteName}) showText: false
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
git porcelain
fetchFromAll: aCollectionOfRemoteNames
aCollectionOfRemoteNames do: [:each | self fetchFrom: each].
GitFeatureFlags externalFetchAndPush
ifTrue: [aCollectionOfRemoteNames do: [:each | self fetchAllExternalFrom: each]]
ifFalse: [aCollectionOfRemoteNames do: [:each | self fetchFrom: each]]
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,6 @@ git porcelain
push: aCollectionOfBranchNamesAndAssociations toRemote: remoteName
"self push: { 'master' } toRemote: 'origin'.
self push: { 'branch' -> 'remoteBranchName' } toRemote: 'origin'"
^ self pushToRemote: remoteName update: aCollectionOfBranchNamesAndAssociations deleteRemoteBranches: Array empty
GitFeatureFlags externalFetchAndPush
ifTrue: [self externalPush: aCollectionOfBranchNamesAndAssociations toRemote: remoteName]
ifFalse: [self pushToRemote: remoteName update: aCollectionOfBranchNamesAndAssociations deleteRemoteBranches: Array empty]
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,20 @@
"commitNamed:" : "jr 8/13/2020 23:08",
"createBranchNamed:at:" : "jr 3/4/2020 00:47",
"expandRemoteRef:" : "pre 6/15/2018 16:04",
"externalCommand:" : "tobe 10/15/2022 03:44",
"externalGitDo:showText:" : "tobe 10/15/2022 03:15",
"externalPush:toRemote:" : "tobe 10/15/2022 07:45",
"fetchAllExternalFrom:" : "tobe 10/15/2022 03:42",
"fetchFrom:" : "jr 5/14/2021 22:08",
"fetchFromAll:" : "jr 4/12/2017 11:26",
"fetchFromAll:" : "tobe 10/15/2022 07:55",
"filesystemOn:" : "CamilloBruni 8/30/2012 14:06",
"flushCaches" : "jr 7/2/2017 19:12",
"gitStoreOn:" : "CamilloBruni 9/2/2012 12:33",
"head" : "jr 8/13/2020 23:10",
"headReference" : "jr 3/4/2020 00:47",
"initializeOn:" : "MaxLeske 7/23/2010 09:59",
"orphanedHead" : "jr 1/29/2017 22:52",
"push:toRemote:" : "jr 1/2/2017 10:20",
"push:toRemote:" : "tobe 10/15/2022 07:38",
"pushToRemote:deleteRemoteBranches:" : "jr 1/2/2017 10:18",
"pushToRemote:update:deleteRemoteBranches:" : "jr 7/23/2020 00:43",
"pushToUpstreamBranchOf:ifNone:" : "jr 3/4/2020 00:49",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
accessing
externalFetchAndPush: aBoolean
ExternalFetchAndPush := aBoolean
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
accessing
externalFetchAndPush
<preference: 'Use external git CLI for fetch and push' categoryList: #('Git expert settings') description: 'If true, the external git CLI command is used when fetching and pushing. Activate if you want to authenticate via SSH, for example.' type: #Boolean>

^ ExternalFetchAndPush ifNil: [false]
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
"evictFromObjectCache" : "jr 8/10/2020 23:42",
"evictFromObjectCache:" : "jr 4/20/2020 21:59",
"evictFromObjectCacheForTests:" : "jr 4/20/2020 23:33",
"externalFetchAndPush" : "tobe 10/15/2022 07:17",
"externalFetchAndPush:" : "tobe 10/15/2022 07:17",
"warnAboutUseOfDeprecatedMethods" : "jr 9/21/2020 23:10",
"warnAboutUseOfDeprecatedMethods:" : "jr 4/17/2020 11:49" },
"instance" : {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
],
"classvars" : [
"EvictFromObjectCache",
"ExternalFetchAndPush",
"UseUnitOfWorkInterface",
"WarnAboutUseOfDeprecatedMethods" ],
"commentStamp" : "",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
user requests
chooseableRemoteNamesFrom: gitRepository
GitFeatureFlags externalFetchAndPush ifTrue: [^ gitRepository remoteNames].
^ gitRepository remoteNames select:
[:each | (gitRepository remoteUrl: each) beginsWith: 'http']
2 changes: 1 addition & 1 deletion src/Squit.package/SquitBrowser.class/methodProperties.json
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@
"cherryPick:toWorkingCopy:" : "ct 9/15/2022 19:15",
"chooseOneRemoteFrom:" : "jr 7/24/2020 11:33",
"chooseRemotesFrom:" : "jr 8/3/2020 01:07",
"chooseableRemoteNamesFrom:" : "jr 4/26/2017 13:38",
"chooseableRemoteNamesFrom:" : "tobe 10/15/2022 08:03",
"clone" : "jr 12/23/2021 18:24",
"commitList" : "jr 7/2/2022 22:31",
"commitListKey:from:" : "fn 4/12/2017 10:52",
Expand Down