From bebe72c40483661cc9bcb81f769f732985656fe5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marius=20D=C3=B6rbandt?= Date: Fri, 8 Dec 2023 19:44:37 +0100 Subject: [PATCH] Set upstream branch when creating a branch from a remote-tracking branch --- .../instance/setUpstreamRemoteNameAndRef.for..st | 6 ++++++ .../SqueakWorkingCopy.class/methodProperties.json | 1 + .../actionCreateBranchAtActiveCommitFromRef..st | 6 ++++-- .../actionCreateGitBranchAtActiveCommitFromRef..st | 1 + .../instance/checkSetUpstreamForCreatedBranch.to..st | 11 +++++++++++ .../SquotBrowser.class/methodProperties.json | 5 +++-- 6 files changed, 26 insertions(+), 4 deletions(-) create mode 100644 src/Squot.package/SqueakWorkingCopy.class/instance/setUpstreamRemoteNameAndRef.for..st create mode 100644 src/Squot.package/SquotBrowser.class/instance/checkSetUpstreamForCreatedBranch.to..st diff --git a/src/Squot.package/SqueakWorkingCopy.class/instance/setUpstreamRemoteNameAndRef.for..st b/src/Squot.package/SqueakWorkingCopy.class/instance/setUpstreamRemoteNameAndRef.for..st new file mode 100644 index 000000000..378062f11 --- /dev/null +++ b/src/Squot.package/SqueakWorkingCopy.class/instance/setUpstreamRemoteNameAndRef.for..st @@ -0,0 +1,6 @@ +upstream +setUpstreamRemoteNameAndRef: aStringAssociation for: aString + self + setUpstreamRemoteName: aStringAssociation key + andRef: aStringAssociation value + for: aString. \ No newline at end of file diff --git a/src/Squot.package/SqueakWorkingCopy.class/methodProperties.json b/src/Squot.package/SqueakWorkingCopy.class/methodProperties.json index ee767507e..46a146dd7 100644 --- a/src/Squot.package/SqueakWorkingCopy.class/methodProperties.json +++ b/src/Squot.package/SqueakWorkingCopy.class/methodProperties.json @@ -133,6 +133,7 @@ "requestUnmappedPathWithTitle:initialAnswer:" : "mad 11/21/2023 14:31", "serializeChangeSets:onCommit:" : "mad 9/20/2023 12:45", "setUpstreamRemoteName:andRef:for:" : "mad 9/18/2023 20:01", + "setUpstreamRemoteNameAndRef:for:" : "mad 12/8/2023 19:31", "splitRemoteRef:" : "mad 12/8/2023 19:28", "unitOfWork" : "mad 6/3/2023 14:15", "unmappedReferencesIn:do:" : "mad 10/21/2023 23:37", diff --git a/src/Squot.package/SquotBrowser.class/instance/actionCreateBranchAtActiveCommitFromRef..st b/src/Squot.package/SquotBrowser.class/instance/actionCreateBranchAtActiveCommitFromRef..st index 8c02a6daf..b57e8b919 100644 --- a/src/Squot.package/SquotBrowser.class/instance/actionCreateBranchAtActiveCommitFromRef..st +++ b/src/Squot.package/SquotBrowser.class/instance/actionCreateBranchAtActiveCommitFromRef..st @@ -1,8 +1,10 @@ actions actionCreateBranchAtActiveCommitFromRef: aStringOrNil - | name | + | name branch | self activeWorkingCopyIfNilInformAnd: [^ nil]. self activeCommit ifNil: [^ self inform: 'Please select a commit first.']. name := self requestBranchNameFor: 'a branch' fromRef: aStringOrNil. name isEmptyOrNil ifTrue: [^ self]. - ^ self activeWorkingCopy createBranchNamed: name at: self activeCommit \ No newline at end of file + branch := self activeWorkingCopy createBranchNamed: name at: self activeCommit. + self checkSetUpstreamForCreatedBranch: branch to: aStringOrNil. + ^ branch \ No newline at end of file diff --git a/src/Squot.package/SquotBrowser.class/instance/actionCreateGitBranchAtActiveCommitFromRef..st b/src/Squot.package/SquotBrowser.class/instance/actionCreateGitBranchAtActiveCommitFromRef..st index b8ef4d877..0dce66314 100644 --- a/src/Squot.package/SquotBrowser.class/instance/actionCreateGitBranchAtActiveCommitFromRef..st +++ b/src/Squot.package/SquotBrowser.class/instance/actionCreateGitBranchAtActiveCommitFromRef..st @@ -10,4 +10,5 @@ actionCreateGitBranchAtActiveCommitFromRef: aStringOrNil updateRef: gitRef to: commit message: 'export from squeak'. + aStringOrNil ifNotNil: [self checkSetUpstreamForCreatedBranch: gitRef to: aStringOrNil]. ^ gitRef \ No newline at end of file diff --git a/src/Squot.package/SquotBrowser.class/instance/checkSetUpstreamForCreatedBranch.to..st b/src/Squot.package/SquotBrowser.class/instance/checkSetUpstreamForCreatedBranch.to..st new file mode 100644 index 000000000..d31ae2a8d --- /dev/null +++ b/src/Squot.package/SquotBrowser.class/instance/checkSetUpstreamForCreatedBranch.to..st @@ -0,0 +1,11 @@ +actions +checkSetUpstreamForCreatedBranch: aString to: anotherString + (self activeWorkingCopy isRemoteRef: anotherString) ifFalse: [^ self]. + (self confirm: + ('You created a branch ''{1}'' from the remote-tracking branch ''{2}''. ', + 'Do you want to set the upstream branch of ''{1}'' to ''{2}''?' + format: ({aString. anotherString} collect: [:each | GitReference shortName: each]))) + ifFalse: [^ self]. + self activeWorkingCopy + setUpstreamRemoteNameAndRef: (self activeWorkingCopy splitRemoteRef: anotherString) + for: aString. \ No newline at end of file diff --git a/src/Squot.package/SquotBrowser.class/methodProperties.json b/src/Squot.package/SquotBrowser.class/methodProperties.json index ac0e14656..00590964d 100644 --- a/src/Squot.package/SquotBrowser.class/methodProperties.json +++ b/src/Squot.package/SquotBrowser.class/methodProperties.json @@ -14,11 +14,11 @@ "actionCompareActiveCommitToParent" : "mad 10/22/2023 00:57", "actionCreateBranchAtActiveCommit" : "mad 11/29/2023 16:11", "actionCreateBranchAtActiveCommitAndSwitchToIt" : "mad 11/29/2023 16:35", - "actionCreateBranchAtActiveCommitFromRef:" : "mad 11/29/2023 16:31", + "actionCreateBranchAtActiveCommitFromRef:" : "mad 12/8/2023 19:16", "actionCreateBranchAtActiveRef" : "mad 11/29/2023 16:13", "actionCreateBranchAtActiveRefAndSwitchToIt" : "mad 11/29/2023 16:36", "actionCreateGitBranchAtActiveCommit" : "mad 11/29/2023 16:32", - "actionCreateGitBranchAtActiveCommitFromRef:" : "mad 11/29/2023 16:31", + "actionCreateGitBranchAtActiveCommitFromRef:" : "mad 12/8/2023 19:41", "actionCreateGitBranchAtActiveRef" : "mad 11/29/2023 16:32", "actionDeleteActiveRef" : "mad 10/16/2023 22:43", "actionFetchAll" : "mad 9/19/2023 12:29", @@ -68,6 +68,7 @@ "buildUpperLayout:" : "mad 9/19/2023 12:12", "buildWindow:" : "mad 9/15/2023 16:22", "buildWith:" : "mad 9/1/2023 14:44", + "checkSetUpstreamForCreatedBranch:to:" : "mad 12/8/2023 19:33", "commitList" : "mad 11/30/2023 17:11", "commitListMenu:" : "mad 11/29/2023 15:58", "commitListStartingCommits" : "mad 9/19/2023 12:32",