diff --git a/src/FileSystem-Git.package/FileSystemGitRepository.class/instance/externalCommand..st b/src/FileSystem-Git.package/FileSystemGitRepository.class/instance/externalCommand..st new file mode 100644 index 000000000..4e252adf1 --- /dev/null +++ b/src/FileSystem-Git.package/FileSystemGitRepository.class/instance/externalCommand..st @@ -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'] \ No newline at end of file diff --git a/src/FileSystem-Git.package/FileSystemGitRepository.class/instance/externalGitDo.showText..st b/src/FileSystem-Git.package/FileSystemGitRepository.class/instance/externalGitDo.showText..st new file mode 100644 index 000000000..710b3b068 --- /dev/null +++ b/src/FileSystem-Git.package/FileSystemGitRepository.class/instance/externalGitDo.showText..st @@ -0,0 +1,7 @@ +git porcelain - external +externalGitDo: aCommandLineSuffix showText: aBoolean + | res | + res := self externalCommand: ('git -C {1} {2}' format: {repository workingDir pathName copyReplaceAll: ' ' with: '\ '. aCommandLineSuffix}). + res first + ifFalse: [self error: res second] + ifTrue: [aBoolean ifTrue: [self inform: res second] ifFalse: [Transcript showln: res second]] \ No newline at end of file diff --git a/src/FileSystem-Git.package/FileSystemGitRepository.class/instance/externalPush.toRemote..st b/src/FileSystem-Git.package/FileSystemGitRepository.class/instance/externalPush.toRemote..st new file mode 100644 index 000000000..a67499b6b --- /dev/null +++ b/src/FileSystem-Git.package/FileSystemGitRepository.class/instance/externalPush.toRemote..st @@ -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] \ No newline at end of file diff --git a/src/FileSystem-Git.package/FileSystemGitRepository.class/instance/fetchAllExternalFrom..st b/src/FileSystem-Git.package/FileSystemGitRepository.class/instance/fetchAllExternalFrom..st new file mode 100644 index 000000000..720f56473 --- /dev/null +++ b/src/FileSystem-Git.package/FileSystemGitRepository.class/instance/fetchAllExternalFrom..st @@ -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 \ No newline at end of file diff --git a/src/FileSystem-Git.package/FileSystemGitRepository.class/instance/fetchFromAll..st b/src/FileSystem-Git.package/FileSystemGitRepository.class/instance/fetchFromAll..st index 13b0d50ad..2a58482d1 100644 --- a/src/FileSystem-Git.package/FileSystemGitRepository.class/instance/fetchFromAll..st +++ b/src/FileSystem-Git.package/FileSystemGitRepository.class/instance/fetchFromAll..st @@ -1,3 +1,5 @@ git porcelain fetchFromAll: aCollectionOfRemoteNames - aCollectionOfRemoteNames do: [:each | self fetchFrom: each]. \ No newline at end of file + GitFeatureFlags externalFetchAndPush + ifTrue: [aCollectionOfRemoteNames do: [:each | self fetchAllExternalFrom: each]] + ifFalse: [aCollectionOfRemoteNames do: [:each | self fetchFrom: each]] \ No newline at end of file diff --git a/src/FileSystem-Git.package/FileSystemGitRepository.class/instance/push.toRemote..st b/src/FileSystem-Git.package/FileSystemGitRepository.class/instance/push.toRemote..st index 856033672..22021bfb5 100644 --- a/src/FileSystem-Git.package/FileSystemGitRepository.class/instance/push.toRemote..st +++ b/src/FileSystem-Git.package/FileSystemGitRepository.class/instance/push.toRemote..st @@ -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 \ No newline at end of file + GitFeatureFlags externalFetchAndPush + ifTrue: [self externalPush: aCollectionOfBranchNamesAndAssociations toRemote: remoteName] + ifFalse: [self pushToRemote: remoteName update: aCollectionOfBranchNamesAndAssociations deleteRemoteBranches: Array empty] \ No newline at end of file diff --git a/src/FileSystem-Git.package/FileSystemGitRepository.class/methodProperties.json b/src/FileSystem-Git.package/FileSystemGitRepository.class/methodProperties.json index 28bee1fae..b1c2bbdee 100644 --- a/src/FileSystem-Git.package/FileSystemGitRepository.class/methodProperties.json +++ b/src/FileSystem-Git.package/FileSystemGitRepository.class/methodProperties.json @@ -10,8 +10,12 @@ "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 14:35", + "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", @@ -19,7 +23,7 @@ "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", diff --git a/src/FileSystem-Git.package/GitFeatureFlags.class/class/externalFetchAndPush..st b/src/FileSystem-Git.package/GitFeatureFlags.class/class/externalFetchAndPush..st new file mode 100644 index 000000000..05a30839d --- /dev/null +++ b/src/FileSystem-Git.package/GitFeatureFlags.class/class/externalFetchAndPush..st @@ -0,0 +1,3 @@ +accessing +externalFetchAndPush: aBoolean + ExternalFetchAndPush := aBoolean \ No newline at end of file diff --git a/src/FileSystem-Git.package/GitFeatureFlags.class/class/externalFetchAndPush.st b/src/FileSystem-Git.package/GitFeatureFlags.class/class/externalFetchAndPush.st new file mode 100644 index 000000000..b0ac51b66 --- /dev/null +++ b/src/FileSystem-Git.package/GitFeatureFlags.class/class/externalFetchAndPush.st @@ -0,0 +1,5 @@ +accessing +externalFetchAndPush + + + ^ ExternalFetchAndPush ifNil: [false] \ No newline at end of file diff --git a/src/FileSystem-Git.package/GitFeatureFlags.class/methodProperties.json b/src/FileSystem-Git.package/GitFeatureFlags.class/methodProperties.json index 36b0a5742..cd2dfb705 100644 --- a/src/FileSystem-Git.package/GitFeatureFlags.class/methodProperties.json +++ b/src/FileSystem-Git.package/GitFeatureFlags.class/methodProperties.json @@ -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" : { diff --git a/src/FileSystem-Git.package/GitFeatureFlags.class/properties.json b/src/FileSystem-Git.package/GitFeatureFlags.class/properties.json index 29838e4a4..eca3b5f21 100644 --- a/src/FileSystem-Git.package/GitFeatureFlags.class/properties.json +++ b/src/FileSystem-Git.package/GitFeatureFlags.class/properties.json @@ -4,6 +4,7 @@ ], "classvars" : [ "EvictFromObjectCache", + "ExternalFetchAndPush", "UseUnitOfWorkInterface", "WarnAboutUseOfDeprecatedMethods" ], "commentStamp" : "", diff --git a/src/Squit.package/SquitBrowser.class/instance/chooseableRemoteNamesFrom..st b/src/Squit.package/SquitBrowser.class/instance/chooseableRemoteNamesFrom..st index 1c507733c..90b8054c5 100644 --- a/src/Squit.package/SquitBrowser.class/instance/chooseableRemoteNamesFrom..st +++ b/src/Squit.package/SquitBrowser.class/instance/chooseableRemoteNamesFrom..st @@ -1,4 +1,5 @@ user requests chooseableRemoteNamesFrom: gitRepository + GitFeatureFlags externalFetchAndPush ifTrue: [^ gitRepository remoteNames]. ^ gitRepository remoteNames select: [:each | (gitRepository remoteUrl: each) beginsWith: 'http'] \ No newline at end of file diff --git a/src/Squit.package/SquitBrowser.class/methodProperties.json b/src/Squit.package/SquitBrowser.class/methodProperties.json index 301065b9f..710143f76 100644 --- a/src/Squit.package/SquitBrowser.class/methodProperties.json +++ b/src/Squit.package/SquitBrowser.class/methodProperties.json @@ -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",