-
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.
- Loading branch information
Showing
10 changed files
with
80 additions
and
32 deletions.
There are no files selected for viewing
34 changes: 10 additions & 24 deletions
34
src/Squit.package/SquitBrowser.class/instance/actionBranchPush.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,26 +1,12 @@ | ||
actions on branches | ||
actionBranchPush | ||
| historian branchName workingCopy repository gitRepository | | ||
self hasBranchSelection ifFalse: [^ self]. | ||
selectedHistorian isRemoteTrackingHistorian ifTrue: | ||
[^ self inform: 'You should not push a remote-tracking branch. Push a local branch instead.']. | ||
historian := selectedHistorian. | ||
branchName := historian name. | ||
workingCopy := self projectSelection. | ||
repository := workingCopy repository. | ||
gitRepository := repository gitRepository. | ||
self checkTrackedBranchOrOfferChange: historian ifUnsupported: [^ self]. | ||
[self withRemoteErrorHandlingDo: | ||
[self handlingCredentialsOf: historian | ||
do: [workingCopy repository | ||
exportToUpstream: historian | ||
ifNone: [ | ||
self offerToSetUpstreamBranchOf: historian shortName | ||
in: gitRepository | ||
ifCanceled: [^ self]. | ||
^ self actionBranchPush "try again"]] | ||
ifCanceled: [^ self]]] | ||
on: GitNonFastForwardPushUpdatesDetected do: [:e | | ||
(self confirm: 'Warning: the tip of your branch is behind its remote counterpart. Do you want to force the push anyway?') | ||
ifTrue: [e proceedWithForcedPush] | ||
ifFalse: [^ self]]. | ||
self pushSelectedHistorianByDoing: | ||
[:gitRepository | | ||
self checkTrackedBranchOrOfferChange: selectedHistorian ifUnsupported: [^ self]. | ||
selectedHistorian repository | ||
exportToUpstream: selectedHistorian | ||
ifNone: [ | ||
self offerToSetUpstreamBranchOf: selectedHistorian shortName | ||
in: gitRepository | ||
ifCanceled: [^ self]. | ||
^ self actionBranchPush "try again"]]. |
9 changes: 9 additions & 0 deletions
9
src/Squit.package/SquitBrowser.class/instance/actionPushToRemote..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,9 @@ | ||
actions on branches | ||
actionPushToRemote: aString | ||
self pushSelectedHistorianByDoing: | ||
[selectedHistorian repository | ||
export: selectedHistorian | ||
withName: (UIManager default | ||
request: 'Branch name at remote:' | ||
initialAnswer: selectedHistorian shortName) | ||
toRemoteNamed: aString]. |
15 changes: 9 additions & 6 deletions
15
src/Squit.package/SquitBrowser.class/instance/menuBranchListHook..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,35 +1,38 @@ | ||
ui menu | ||
menuBranchListHook: aMenu | ||
<menuBranchListShifted: false> | ||
| commands activeBranchName branchStatus onlyActive onlyInactive onlyLocal onlyRemote onlyWithUpstream | | ||
| activeBranchName branchStatus onlyActive onlyInactive onlyLocal onlyRemote onlyWithUpstream hasRemotes | | ||
self hasBranchSelection ifFalse: [^ aMenu]. | ||
activeBranchName := self projectSelection loadedHistorian shortName. | ||
onlyLocal := selectedHistorian isRemoteTrackingHistorian not. | ||
onlyRemote := selectedHistorian isRemoteTrackingHistorian. | ||
onlyActive := selectedHistorian = self projectSelection loadedHistorian. | ||
onlyInactive := selectedHistorian ~= self projectSelection loadedHistorian. | ||
onlyWithUpstream := selectedHistorian hasUpstreamHistorian. | ||
hasRemotes := self projectSelection repository hasRemotes. | ||
branchStatus := true caseOf: | ||
{[onlyRemote] -> ['(remote-tracking branch)']. | ||
[onlyActive] -> ['(currently checked out)']} | ||
otherwise: ''. | ||
aMenu addTitle: 'Branch ', selectedHistorian shortName, | ||
(branchStatus ifNotEmpty: [String cr, branchStatus]). | ||
commands := | ||
self buildMenu: aMenu from: | ||
{{'Switch to this branch'. #actionBranchSwitch. 'Stash uncommitted changes on the active branch, then checkout the selected branch.'. onlyLocal & onlyInactive}. | ||
{'Switch, but keep uncommitted changes'. #actionBranchSwitchMoveOver. 'Checkout the selected branch and try to move over uncommitted changes to it.'. onlyLocal & onlyInactive}. | ||
{'Create a new branch and switch to it'. #actionBranchCreateAndSwitch. 'Create a new branch at the same commit as this branch and switch to the new branch'. onlyRemote}. | ||
{'Discard uncommitted changes'. #actionBranchResetToTip. nil. onlyActive}. | ||
{'Merge into ', activeBranchName. #actionBranchMerge. 'Merge this branch into your active branch ', activeBranchName. onlyInactive}. | ||
'-'. | ||
{'Push'. #actionBranchPush. nil. onlyLocal}. | ||
{'Set upstream branch'. #actionSetUpstreamBranch. nil. onlyLocal}. | ||
{'Push'. #actionBranchPush. nil. onlyLocal}}. | ||
(onlyLocal and: [hasRemotes]) ifTrue: | ||
[aMenu add: 'Push to' subMenu: self remotesPushSubMenu]. | ||
self buildMenu: aMenu from: | ||
{{'Set upstream branch'. #actionSetUpstreamBranch. nil. onlyLocal}. | ||
{'Remove upstream branch at the remote'. #actionBranchRemoveUpstream. 'Push the deletion of the remote branch'. onlyWithUpstream}. | ||
'-'. | ||
{'Rename'. #actionBranchRename. nil. onlyLocal}. | ||
{'Remove'. #actionBranchRemove}. | ||
'-'. | ||
{'Compare with working copy'. #actionBranchDiffWithWorkingCopy}}. | ||
|
||
self buildMenu: aMenu from: commands. | ||
|
||
^ aMenu |
19 changes: 19 additions & 0 deletions
19
src/Squit.package/SquitBrowser.class/instance/pushSelectedHistorianByDoing..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,19 @@ | ||
private | ||
pushSelectedHistorianByDoing: aBlock | ||
| historian branchName workingCopy repository gitRepository | | ||
self hasBranchSelection ifFalse: [^ self]. | ||
selectedHistorian isRemoteTrackingHistorian ifTrue: | ||
[^ self inform: 'You should not push a remote-tracking branch. Push a local branch instead.']. | ||
historian := selectedHistorian. | ||
branchName := historian name. | ||
workingCopy := self projectSelection. | ||
repository := workingCopy repository. | ||
gitRepository := repository gitRepository. | ||
[self withRemoteErrorHandlingDo: | ||
[self handlingCredentialsOf: historian | ||
do: [aBlock cull: gitRepository] | ||
ifCanceled: [^ self]]] | ||
on: GitNonFastForwardPushUpdatesDetected do: [:e | | ||
(self confirm: 'Warning: the tip of your branch is behind its remote counterpart. Do you want to force the push anyway?') | ||
ifTrue: [e proceedWithForcedPush] | ||
ifFalse: [^ self]]. |
8 changes: 8 additions & 0 deletions
8
src/Squit.package/SquitBrowser.class/instance/remotesMenuWithItems..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,8 @@ | ||
ui menu | ||
remotesMenuWithItems: aBlock | ||
| remotesMenuSpec | | ||
remotesMenuSpec := ToolBuilder default pluggableMenuSpec new. | ||
(self chooseableRemoteNamesFrom: self projectSelection repository gitRepository) sorted do: | ||
[:each | aBlock value: remotesMenuSpec value: each]. | ||
^ ToolBuilder default buildPluggableMenu: remotesMenuSpec | ||
|
10 changes: 10 additions & 0 deletions
10
src/Squit.package/SquitBrowser.class/instance/remotesPushSubMenu.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,10 @@ | ||
ui menu | ||
remotesPushSubMenu | ||
^ self remotesMenuWithItems: | ||
[:menu :remote | | ||
menu | ||
add: remote | ||
action: (MessageSend | ||
receiver: self | ||
selector: #actionPushToRemote: | ||
argument: remote)] |
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
4 changes: 4 additions & 0 deletions
4
src/Squit.package/SquitRepository.class/instance/export.withName.toRemoteNamed..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,4 @@ | ||
synchronizing | ||
export: aHistorian withName: branchString toRemoteNamed: remoteString | ||
self withCredentialsDo: | ||
[gitRepository push: {aHistorian name -> branchString} toRemote: remoteString] |
3 changes: 3 additions & 0 deletions
3
src/Squit.package/SquitRepository.class/instance/hasRemotes.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,3 @@ | ||
testing | ||
hasRemotes | ||
^ gitRepository remoteNames notEmpty |
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